# Use write_metrics_info to create the .metrics file with this info
def legacy_extract_metrics_info(log_file):
- log_re = re.compile("Preview: ([ST])")
- data_re = re.compile("(-?[0-9]+) (-?[0-9]+) (-?[0-9]+) (-?[0-9]+)")
+ log_re = re.compile(b"Preview: ([ST])")
+ data_re = re.compile(b"(-?[0-9]+) (-?[0-9]+) (-?[0-9]+) (-?[0-9]+)")
tp_ascent = 0.0
tp_descent = 0.0
success = 0
results = []
try:
- for line in open(log_file, 'r').readlines():
+ for line in open(log_file, 'rb').readlines():
match = log_re.match(line)
if match == None:
continue
return results
def extract_resolution(log_file, dpi):
- fontsize_re = re.compile("Preview: Fontsize")
- magnification_re = re.compile("Preview: Magnification")
- extract_decimal_re = re.compile("([0-9\.]+)")
- extract_integer_re = re.compile("([0-9]+)")
+ fontsize_re = re.compile(b"Preview: Fontsize")
+ magnification_re = re.compile(b"Preview: Magnification")
+ extract_decimal_re = re.compile(b"([0-9\.]+)")
+ extract_integer_re = re.compile(b"([0-9]+)")
found_fontsize = 0
found_magnification = 0
fontsize = 10.0
try:
- for line in open(log_file, 'r').readlines():
+ for line in open(log_file, 'rb').readlines():
if found_fontsize and found_magnification:
break
def string_in_file(string, infile):
if not os.path.isfile(infile):
return False
- f = open(infile, 'r')
+ f = open(infile, 'rb')
for line in f.readlines():
- if string in line:
+ if string.encode() in line:
f.close()
return True
f.close()
# Returns a list of indexes of pages giving errors extracted from the latex log
def check_latex_log(log_file):
- error_re = re.compile("^! ")
- snippet_re = re.compile("^Preview: Snippet ")
- data_re = re.compile("([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)")
+ error_re = re.compile(b"^! ")
+ snippet_re = re.compile(b"^Preview: Snippet ")
+ data_re = re.compile(b"([0-9]+) ([0-9]+) ([0-9]+) ([0-9]+)")
found_error = False
error_pages = []
try:
- for line in open(log_file, 'r').readlines():
+ for line in open(log_file, 'rb').readlines():
if not found_error:
match = error_re.match(line)
if match != None: