-
# file lyxpreview_tools.py
# This file is part of LyX, the document processor.
# Licence details can be found in the file COPYING.
latex_status, latex_stdout = run_tex(latex, latex_file)
# Rerun latex if necessary
progress("Checking if a latex rerun is necessary")
- if string_in_file("Warning: Citation", log_file):
+ if string_in_file("Warning: (Citation|Reference)", log_file):
latex_status, latex_stdout = run_tex(latex, latex_file)
return latex_status, latex_stdout
def string_in_file(string, infile):
if not os.path.isfile(infile):
return False
- f = open(infile, 'r')
+ string_re = re.compile(string.encode())
+ f = open(infile, 'rb')
for line in f.readlines():
- if string in line:
+ if string_re.search(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: