def main():
parser = argparse.ArgumentParser()
parser.add_argument('-t', '--template', help='Template file', required=True)
parser.add_argument('-o', '--output', help='Output file', required=True)
parser.add_argument('-n', '--image-name', help='Image name', required=True)
parser.add_argument('-d', '--image-descriptors', help='Image descriptors', required=True)
args = parser.parse_args()
# Get the image descriptors json file
with open(args.image_descriptors, 'r') as f:
images = json.loads(f.read())['images']
if args.image_name not in images.keys():
print('%s does not exist in %s' % (args.image_name, args.image_descriptors))
sys.exit(-1)
with open(args.template) as fp:
template = jinja2.Template(fp.read())
context = images[args.image_name]
output = template.render(**context)
with open(args.output, 'w') as f:
f.write(output)
评论列表
文章目录