X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fscripts%2Ffig_copy.py;h=a398c1dbf526b249b34098dddec5f40aa0e58fbd;hb=dd60e2d9f4bdf091d38590f83546147610eca9a1;hp=d5e0421668558dff0f7cd9949f412f268ac6981b;hpb=d0aa7d24ab5a45cf28cda74b3f6e77b53365abf3;p=lyx.git diff --git a/lib/scripts/fig_copy.py b/lib/scripts/fig_copy.py index d5e0421668..a398c1dbf5 100644 --- a/lib/scripts/fig_copy.py +++ b/lib/scripts/fig_copy.py @@ -17,14 +17,15 @@ # picture files that are stored as relative paths are replaced # with the absolute path. +from __future__ import print_function import os, sys if len(sys.argv) != 3: - print >> sys.stderr, "Usage: fig_copy.py " + print ("Usage: fig_copy.py ", file=sys.stderr) sys.exit(1) if not os.path.isfile(sys.argv[1]): - print >> sys.stderr, "Unable to read", sys.argv[1] + print ("Unable to read", sys.argv[1], file=sys.stderr) sys.exit(1) from_dir = os.path.split(os.path.realpath(sys.argv[1]))[0] @@ -45,14 +46,14 @@ import re # We're looking for a line of text that defines an entry of # type '2' (a polyline), subtype '5' (an external picture file). # The line has 14 other data fields. -patternline = re.compile(r'^\s*2\s+5(\s+[0-9.+-]+){14}\s*$') -emptyline = re.compile(r'^\s*$') -commentline = re.compile(r'^\s*#.*$') +patternline = re.compile(br'^\s*2\s+5(\s+[0-9.+-]+){14}\s*$') +emptyline = re.compile(br'^\s*$') +commentline = re.compile(br'^\s*#.*$') # we allow space in path name -figureline = re.compile(r'^(\s*[01]\s*)(\S[\S ]*)(\s*)$') +figureline = re.compile(br'^(\s*[01]\s*)(\S[\S ]*)(\s*)$') -input = open(sys.argv[1], 'r') -output = open(sys.argv[2], 'w') +input = open(sys.argv[1], 'rb') +output = open(sys.argv[2], 'wb') # path in the fig is relative to this path os.chdir(from_dir) @@ -68,7 +69,7 @@ for line in input: found = False elif patternline.match(line): found = True - print >> output, line, + output.write(line) input.close() output.close()