]> git.lyx.org Git - lyx.git/blobdiff - lib/scripts/layout2layout.py
Improve the svg2*tex.py scripts.
[lyx.git] / lib / scripts / layout2layout.py
index f16aba0cbb5633dcf48a15633e05c68c076f3348..56b433994c204d127f127727741b3a42774c349f 100644 (file)
@@ -1172,14 +1172,14 @@ def main(argv):
 
     parser = argparse.ArgumentParser(**args)
 
-    parser.add_argument("-t", "--to", type=int, dest="format",
+    parser.add_argument("-t", "--to", type=int, dest="format", default= currentFormat,
                         help=("destination layout format, default %i (latest)") % currentFormat)
     parser.add_argument("input_file", nargs='?', type=cmd_arg, default=None,
                         help="input file (default stdin)")
     parser.add_argument("output_file", nargs='?', type=cmd_arg, default=None,
                         help="output file (default stdout)")
 
-    options = parser.parse_args()
+    options = parser.parse_args(argv[1:])
 
     # Open files
     if options.input_file:
@@ -1192,19 +1192,14 @@ def main(argv):
     else:
         output = sys.stdout
 
-    if options.format:
-        end_format = options.format
-    else:
-        end_format = currentFormat
-
-    if end_format > currentFormat:
-        error("Format %i does not exist" % end_format);
+    if options.format > currentFormat:
+        error("Format %i does not exist" % options.format);
 
     # Do the real work
     lines = read(source)
     format = 1
-    while (format < end_format):
-        format = convert(lines, end_format)
+    while (format < options.format):
+        format = convert(lines, options.format)
     write(output, lines)
 
     # Close files