From bb61c325dabfc80bbd8404b2892575948b77496b Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 19 Apr 2012 00:50:18 -0700 Subject: volk: code simplification, overrule macro and python opts --- volk/gen/volk_tmpl_utils.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'volk/gen/volk_tmpl_utils.py') diff --git a/volk/gen/volk_tmpl_utils.py b/volk/gen/volk_tmpl_utils.py index c215e389e..6c08a8213 100644 --- a/volk/gen/volk_tmpl_utils.py +++ b/volk/gen/volk_tmpl_utils.py @@ -23,6 +23,7 @@ import os import re import sys +import optparse import volk_arch_defs import volk_machine_defs import volk_kernel_defs @@ -60,11 +61,14 @@ def __parse_tmpl(_tmpl, **kwargs): """ + _tmpl return str(Template.Template(_tmpl, defs)) -if __name__ == '__main__': - input_file = sys.argv[1] - output_file = sys.argv[2] - try: which = sys.argv[3] - except: which = '' - output = __parse_tmpl(open(input_file).read(), which=which) - if output_file: open(output_file, 'w').write(output) +def main(): + parser = optparse.OptionParser() + parser.add_option('--input', type='string') + parser.add_option('--output', type='string') + (opts, args) = parser.parse_args() + + output = __parse_tmpl(open(opts.input).read(), args=args) + if opts.output: open(opts.output, 'w').write(output) else: print output + +if __name__ == '__main__': main() -- cgit