improve generate script
This commit is contained in:
parent
e9aeeb12cc
commit
f33d4f4d25
@ -5,9 +5,14 @@ import argparse
|
|||||||
|
|
||||||
parser = argparse.ArgumentParser(description="generate.py")
|
parser = argparse.ArgumentParser(description="generate.py")
|
||||||
parser.add_argument('--schema', '-s',
|
parser.add_argument('--schema', '-s',
|
||||||
help='Schema file',
|
help='Schema file. Default: schema.json in the current folder.',
|
||||||
required=False,
|
required=False,
|
||||||
default='./schema.json')
|
default='./schema.json')
|
||||||
|
parser.add_argument('--template', '-t',
|
||||||
|
help="""Template file, templates files must be named as the final output file
|
||||||
|
with an additional .tmpl extension. Default: all template files in the current folder.""",
|
||||||
|
required=False,
|
||||||
|
default="*.tmpl")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
@ -35,7 +40,7 @@ for table in schema["tables"]:
|
|||||||
column["apitype"] = 'number'
|
column["apitype"] = 'number'
|
||||||
column["jstype"] = 'number'
|
column["jstype"] = 'number'
|
||||||
|
|
||||||
for f in glob.glob("*.tmpl"):
|
for f in glob.glob(args.template):
|
||||||
print(f"process {f}")
|
print(f"process {f}")
|
||||||
tmpl = Template(file=f, searchList=[schema])
|
tmpl = Template(file=f, searchList=[schema])
|
||||||
with open(f[:-5], 'w') as outFile:
|
with open(f[:-5], 'w') as outFile:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user