]> hydra-www.ietfng.org Git - dyna2/commitdiff
Issue #40: Dyna will concatenate files for you, but it won't give you nice error...
authorTim Vieira <tim.f.vieira@gmail.com>
Wed, 10 Jul 2013 20:34:35 +0000 (16:34 -0400)
committerTim Vieira <tim.f.vieira@gmail.com>
Wed, 10 Jul 2013 20:34:35 +0000 (16:34 -0400)
src/Dyna/Backend/Python/interpreter.py

index 4a4c5642e195c4df8016d7785a7ff3d04154da01..1a8115ecb8b6a07dbb2d18c39372516fc1f35892 100644 (file)
@@ -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