# 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.
# 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*#.*$')
-input = open(sys.argv[1], 'r')
-output = open(sys.argv[2], 'w')
+input = open(sys.argv[1], 'rb')
+output = open(sys.argv[2], 'wb')
if found and not emptyline.match(line) and not commentline.match(line):
# The contents of the final line containing the file name
# are ' X <file name>', where X = 0 or 1.
if found and not emptyline.match(line) and not commentline.match(line):
# The contents of the final line containing the file name
# are ' X <file name>', where X = 0 or 1.