]> git.lyx.org Git - lyx.git/blobdiff - lib/scripts/lyxpreview_tools.py
Autoconf: use included boost when system boost is not available
[lyx.git] / lib / scripts / lyxpreview_tools.py
index 2f8c2f8d643a7b13a48ea00645d96d5e52834591..7783fe2b7ddde61529d3d5307642ebb828887870 100644 (file)
@@ -219,7 +219,7 @@ def write_metrics_info(metrics_info, metrics_file):
 # Reads a .tex files and create an identical file but only with
 # pages whose index is in pages_to_keep
 def filter_pages(source_path, destination_path, pages_to_keep):
-    def_re = re.compile(rb"(\\newcommandx|\\renewcommandx|\\global\\long\\def)(\\[a-zA-Z]+)(.+)")
+    def_re = re.compile(b"(\\\\newcommandx|\\\\renewcommandx|\\\\global\\\\long\\\\def)(\\[a-zA-Z]+)(.+)")
     source_file = open(source_path, "rb")
     destination_file = open(destination_path, "wb")
 
@@ -313,9 +313,9 @@ def run_tex(tex, tex_file):
 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()
@@ -325,15 +325,15 @@ def string_in_file(string, infile):
 # 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: