mirror of
https://github.com/sasjs/core.git
synced 2025-12-10 14:04:36 +00:00
feat: ms_createwebservice macro (and update to build.py)
This commit is contained in:
70
build.py
70
build.py
@@ -4,8 +4,8 @@ from pathlib import Path
|
||||
# Prepare Lua Macros
|
||||
files = [f for f in Path('lua').iterdir() if f.match("*.lua")]
|
||||
for file in files:
|
||||
basename=os.path.basename(file)
|
||||
name='ml_' + os.path.splitext(basename)[0]
|
||||
basename = os.path.basename(file)
|
||||
name = 'ml_' + os.path.splitext(basename)[0]
|
||||
ml = open('lua/' + name + '.sas', "w")
|
||||
ml.write("/**\n")
|
||||
ml.write(" @file " + name + '.sas\n')
|
||||
@@ -20,50 +20,61 @@ for file in files:
|
||||
ml.write(" file \"%sysfunc(pathname(work))/" + name + ".lua\";\n")
|
||||
with open(file) as infile:
|
||||
for line in infile:
|
||||
ml.write(" put '" + line.rstrip().replace("'","''") + " ';\n")
|
||||
ml.write(" put '" + line.rstrip().replace("'", "''") + " ';\n")
|
||||
ml.write("run;\n\n")
|
||||
ml.write("%inc \"%sysfunc(pathname(work))/" + name + ".lua\" /source2;\n\n")
|
||||
ml.write("%inc \"%sysfunc(pathname(work))/" +
|
||||
name + ".lua\" /source2;\n\n")
|
||||
ml.write("%mend " + name + ";\n")
|
||||
|
||||
ml.close()
|
||||
|
||||
# prepare web files
|
||||
files=['viya/mv_createwebservice.sas','meta/mm_createwebservice.sas']
|
||||
files = ['viya/mv_createwebservice.sas',
|
||||
'meta/mm_createwebservice.sas', 'server/ms_createwebservice.sas']
|
||||
for file in files:
|
||||
webout0=open('base/mp_jsonout.sas','r')
|
||||
if file=='viya/mv_createwebservice.sas':
|
||||
webout1=open('viya/mv_webout.sas',"r")
|
||||
webout0 = open('base/mp_jsonout.sas', 'r')
|
||||
webout1 = open('base/mf_getuser.sas', 'r')
|
||||
|
||||
if file == 'viya/mv_createwebservice.sas':
|
||||
webout2 = open('viya/mv_webout.sas', "r")
|
||||
weboutfiles = [webout0, webout1, webout2]
|
||||
elif file == 'server/ms_createwebservice.sas':
|
||||
webout2 = open('server/ms_webout.sas', "r")
|
||||
webout3 = open('server/mfs_httpheader.sas', 'r')
|
||||
weboutfiles = [webout0, webout1, webout2, webout3]
|
||||
else:
|
||||
webout1=open('meta/mm_webout.sas','r')
|
||||
webout2=open('base/mf_getuser.sas','r')
|
||||
outfile=open(file + 'TEMP','w')
|
||||
infile=open(file,'r')
|
||||
delrow=0
|
||||
webout2 = open('meta/mm_webout.sas', 'r')
|
||||
weboutfiles = [webout0, webout1, webout2]
|
||||
outfile = open(file + 'TEMP', 'w')
|
||||
infile = open(file, 'r')
|
||||
delrow = 0
|
||||
for line in infile:
|
||||
if line=='/* WEBOUT BEGIN */\n':
|
||||
delrow=1
|
||||
if line == '/* WEBOUT BEGIN */\n':
|
||||
delrow = 1
|
||||
outfile.write('/* WEBOUT BEGIN */\n')
|
||||
weboutfiles=[webout0,webout1,webout2]
|
||||
for weboutfile in weboutfiles:
|
||||
stripcomment=1
|
||||
stripcomment = 1
|
||||
for w in weboutfile:
|
||||
if w=='**/\n': stripcomment=0
|
||||
elif stripcomment==0:
|
||||
outfile.write(" put '" + w.rstrip().replace("'","''") + " ';\n")
|
||||
elif delrow==1 and line=='/* WEBOUT END */\n':
|
||||
delrow=0
|
||||
outfile.write('/* WEBOUT END */\n')
|
||||
elif delrow==0:
|
||||
if w == '**/\n':
|
||||
stripcomment = 0
|
||||
elif stripcomment == 0:
|
||||
outfile.write(
|
||||
" put '" + w.rstrip().replace("'", "''") + " ';\n")
|
||||
elif delrow == 1 and line == '/* WEBOUT END */\n':
|
||||
delrow = 0
|
||||
outfile.write('/* WEBOUT END */\n')
|
||||
elif delrow == 0:
|
||||
outfile.write(line.rstrip() + "\n")
|
||||
webout0.close()
|
||||
webout1.close()
|
||||
webout2.close()
|
||||
outfile.close()
|
||||
infile.close()
|
||||
os.remove(file)
|
||||
os.rename(file + 'TEMP',file)
|
||||
os.rename(file + 'TEMP', file)
|
||||
|
||||
# Concatenate all macros into a single file
|
||||
header="""
|
||||
header = """
|
||||
/**
|
||||
@file
|
||||
@brief Auto-generated file
|
||||
@@ -84,14 +95,15 @@ options noquotelenmax;
|
||||
"""
|
||||
f = open('all.sas', "w") # r / r+ / rb / rb+ / w / wb
|
||||
f.write(header)
|
||||
folders=['base','ddl','meta','metax','server','viya','lua','fcmp']
|
||||
folders = ['base', 'ddl', 'meta', 'metax', 'server', 'viya', 'lua', 'fcmp']
|
||||
for folder in folders:
|
||||
filenames = [fn for fn in Path('./' + folder).iterdir() if fn.match("*.sas")]
|
||||
filenames = [fn for fn in Path(
|
||||
'./' + folder).iterdir() if fn.match("*.sas")]
|
||||
filenames.sort()
|
||||
with open('mc_' + folder + '.sas', 'w') as outfile:
|
||||
for fname in filenames:
|
||||
with open(fname) as infile:
|
||||
outfile.write(infile.read())
|
||||
with open('mc_' + folder + '.sas','r') as c:
|
||||
with open('mc_' + folder + '.sas', 'r') as c:
|
||||
f.write(c.read())
|
||||
f.close()
|
||||
|
||||
Reference in New Issue
Block a user