]> git.lyx.org Git - lyx.git/commitdiff
Make scripts python3 compatible
authorGeorg Baum <baum@lyx.org>
Wed, 8 Jun 2016 18:02:33 +0000 (20:02 +0200)
committerGeorg Baum <baum@lyx.org>
Wed, 8 Jun 2016 18:02:33 +0000 (20:02 +0200)
Again using 2to3 and manual checking

lib/generate_contributions.py
lib/scripts/fig_copy.py
lib/scripts/legacy_lyxpreview2ppm.py
lib/scripts/lyxpreview_tools.py

index 822e023c1c31c9c6b777e6888e7cb965cfb7d91b..fb22c2f9b0a56f2fab83337fda37c0a1b28fe48e 100755 (executable)
@@ -296,19 +296,31 @@ def main(argv, contributors):
      if len(argv) != 4:
           error(usage(argv[0]))
 
-     txt_credits_data = unicode(as_txt_credits(contributors)).encode("utf-8")
+     if sys.version_info[0] < 3:
+         txt_credits_data = unicode(as_txt_credits(contributors)).encode("utf-8")
+     else:
+         txt_credits_data = str(as_txt_credits(contributors)).encode("utf-8")
      txt_credits = open(argv[1], "w")
      txt_credits.write(txt_credits_data)
 
-     php_credits_data = unicode(as_php_credits(contributors, argv[2])).encode("utf-8")
+     if sys.version_info[0] < 3:
+         php_credits_data = unicode(as_php_credits(contributors, argv[2])).encode("utf-8")
+     else:
+         php_credits_data = str(as_php_credits(contributors, argv[2])).encode("utf-8")
      php_credits = open(argv[2], "w")
      php_credits.write(php_credits_data)
 
-     php_blanket_data = unicode(as_php_blanket(contributors, argv[3])).encode("utf-8")
+     if sys.version_info[0] < 3:
+         php_blanket_data = unicode(as_php_blanket(contributors, argv[3])).encode("utf-8")
+     else:
+         php_blanket_data = str(as_php_blanket(contributors, argv[3])).encode("utf-8")
      php_blanket = open(argv[3], "w")
      php_blanket.write(php_blanket_data)
 
-     warning_data =  unicode(collate_incomplete(contributors) + '\n').encode("utf-8")
+     if sys.version_info[0] < 3:
+         warning_data =  unicode(collate_incomplete(contributors) + '\n').encode("utf-8")
+     else:
+         warning_data =  str(collate_incomplete(contributors) + '\n').encode("utf-8")
      sys.stderr.write(warning_data)
 
 
index 1c66b3295e1de22a2509dfde91c96d90af4c6dab..d5e0421668558dff0f7cd9949f412f268ac6981b 100644 (file)
@@ -58,7 +58,7 @@ output = open(sys.argv[2], 'w')
 os.chdir(from_dir)
 
 found = False
-for line in input.xreadlines():
+for line in input:
     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.
index ee49e6afa3465310ec0de6950377e10fedef24be..3049b44efa079276696a2c8c6ec0650e2f0f597a 100644 (file)
@@ -146,7 +146,7 @@ def legacy_extract_metrics_info(log_file):
         # Unable to open the file, but do nothing here because
         # the calling function will act on the value of 'success'.
         warning('Warning in legacy_extract_metrics_info! Unable to open "%s"' % log_file)
-        warning(`sys.exc_type` + ',' + `sys.exc_value`)
+        warning(repr(sys.exc_info()[0]) + ',' + repr(sys.exc_info()[1]))
 
     if success == 0:
         error("Failed to extract metrics info from %s" % log_file)
@@ -193,7 +193,7 @@ def extract_resolution(log_file, dpi):
 
     except:
         warning('Warning in extract_resolution! Unable to open "%s"' % log_file)
-        warning(`sys.exc_type` + ',' + `sys.exc_value`)
+        warning(repr(sys.exc_info()[0]) + ',' + repr(sys.exc_info()[1]))
 
     # This is safe because both fontsize and magnification have
     # non-zero default values.
@@ -214,7 +214,7 @@ def legacy_latex_file(latex_file, fg_color, bg_color):
         # Unable to open the file, but do nothing here because
         # the calling function will act on the value of 'success'.
         warning('Warning in legacy_latex_file! Unable to open "%s"' % latex_file)
-        warning(`sys.exc_type` + ',' + `sys.exc_value`)
+        warning(repr(sys.exc_info()[0]) + ',' + repr(sys.exc_info()[1]))
 
     for line in f.readlines():
         if success:
index de2e5c5762cc98942560bf483206a4ac4d45e4af..2012927c05003e662621a29ecf2bd75cb33a01d3 100644 (file)
@@ -168,7 +168,7 @@ def run_command_win32(cmd):
             if hr != winerror.ERROR_IO_PENDING:
                 data = data + buffer
 
-        except pywintypes.error, e:
+        except pywintypes.error as e:
             if e.args[0] != winerror.ERROR_BROKEN_PIPE:
                 error = 1
             break
@@ -406,6 +406,6 @@ def check_latex_log(log_file):
 
     except:
         warning('check_latex_log: Unable to open "%s"' % log_file)
-        warning(`sys.exc_type` + ',' + `sys.exc_value`)
+        warning(repr(sys.exc_info()[0]) + ',' + repr(sys.exc_info()[1]))
 
     return error_pages