]> git.lyx.org Git - lyx.git/blobdiff - lib/scripts/listerrors
update layout files to format 101
[lyx.git] / lib / scripts / listerrors
index e9b0da957ffe7aea1a691a5d21dadd0cd5ad6cb4..92ffa2c6c4d415df60ded0b9be88ab190d9d501a 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 
 # file listerrors
 # This file is part of LyX, the document processor.
@@ -12,6 +12,7 @@
 
 Expects to read from stdin and output to stdout.
 """
+from __future__ import print_function
 
 __author__ = "Kayvan A. Sylvan <kayvan@sylvan.com>"
 __date__ = "$Date: 2003/10/13 09:50:10 $"
@@ -28,14 +29,14 @@ def write_error(msg, tool = "noweb", line_number = 1):
   """Write out the given message in TeX error style.
 
   called like: write_error(msg, tool, line_number)."""
-  print "! Build Error: ==> %s ==>\n" % (tool),
-  print " ...\n\nl.%d ...\n" % (line_number),
+  print ("! Build Error: ==> %s ==>" % tool)
+  print (" ...\n\nl.%d ..." % line_number)
   if type(msg) == type("str"): # simple string
-    print msg
+    print (msg)
   else: # some kind of list (sequence or tuple)
     for m in msg:
-        if m != "": print m,
-    print
+        if m != "": print (m, end=" ")
+    print ()
 
 __lines = [] # lines pushed back
 
@@ -62,19 +63,20 @@ def main():
 
   Reads stdin and writes to stdout. Filter errors"""
 
-  while 1:
+  while True:
     line = getline()
     if line == "": break
     try_patterns_dispatch = [ noweb_try, gcc_try, xlc_try ]
     for predicate in try_patterns_dispatch:
       if predicate(line): break
+
 def noweb_try(line):
   """see if line is a noweb error.
 
   Returns 1 on success, 0 otherwise. Outputs on stdout."""
   retval = 0
-  if string.find(line, ": unescaped << in documentation chunk") != -1:
-    line_parts = string.split(line, ':')
+  if line.find(": unescaped << in documentation chunk") != -1:
+    line_parts = line.split(':')
     num_str = line_parts[1]
     num_len = len(num_str)
     i = 0
@@ -83,9 +85,9 @@ def noweb_try(line):
       write_error(":" + line_parts[2], "noweb", int(num_str))
       retval = 1
   if (not retval):
-    left = string.find(line, "<<")
+    left = line.find("<<")
     if (left != -1) and ((left + 2) < len(line)) and \
-       (string.find(line[left+2:], ">>") != -1):
+       (line[left+2:].find(">>") != -1):
       write_error(line, "noweb");
       retval = 1;
   if (not retval):
@@ -102,7 +104,7 @@ def noweb_try(line):
       "This can't happen:",
       "non-numeric line number in")
     for msg in msgs_to_try:
-      if string.find(line, msg) != -1:
+      if line.find(msg) != -1:
         write_error(line, "noweb")
         retval = 1
         break
@@ -113,7 +115,7 @@ def gcc_try(line):
 
   Returns 1 on success, 0 otherwise. Outputs on stdout."""
   retval = 0
-  first_space = string.find(line, ' ')
+  first_space = line.find(' ')
   if first_space > 1: # The smallest would be "X: "
     if line[first_space - 1] == ':':
       header_to_see = line[:first_space - 1]
@@ -145,8 +147,8 @@ def xlc_try(line):
   Returns 1 on success, 0 otherwise. Outputs on stdout."""
   retval = 0
   if line[0] == '"': # This is the first character of all xlc errors
-    next_quote = string.find(line, '"', 1)
-    first_space = string.find(line, ' ')
+    next_quote = line.find('"', 1)
+    first_space = line.find(' ')
     if (next_quote != -1) and (first_space > next_quote): # no space inisde quotes
       if line[first_space - 1:first_space + 6] == ", line ":
         num_start = num_end = first_space + 6