From: Tim Vieira Date: Wed, 10 Jul 2013 20:34:35 +0000 (-0400) Subject: Issue #40: Dyna will concatenate files for you, but it won't give you nice error... X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=39990dc66237550fe9130325b9610564215913d5;p=dyna2 Issue #40: Dyna will concatenate files for you, but it won't give you nice error messages. --- diff --git a/src/Dyna/Backend/Python/interpreter.py b/src/Dyna/Backend/Python/interpreter.py index 4a4c564..1a8115e 100644 --- a/src/Dyna/Backend/Python/interpreter.py +++ b/src/Dyna/Backend/Python/interpreter.py @@ -602,7 +602,7 @@ def peel(fn, item): def main(): parser = argparse.ArgumentParser(description="The dyna interpreter!") - parser.add_argument('source', nargs='?', type=path, + parser.add_argument('source', nargs='*', type=path, help='Path to Dyna source file (or plan if --plan=true).') parser.add_argument('-i', dest='interactive', action='store_true', help='Fire-up REPL after runing solver..') @@ -626,6 +626,24 @@ def main(): if args.source: + if len(args.source) > 1: + # concatenate files + with file(interp.tmp / 'tmp.dyna', 'wb') as g: + for f in args.source: + if not os.path.exists(f): + print 'File %r does not exist.' % f + with file(f) as f: + g.write('\n') + g.write('%'*80) + g.write('\n') + g.write('%% ') + g.write(f.name) + g.write('\n') + g.write(f.read()) + args.source = g.name + else: + [args.source] = args.source + if not os.path.exists(args.source): print 'File %r does not exist.' % args.source return