commit d0aa7d24ab5a45cf28cda74b3f6e77b53365abf3
Author: Georg Baum <b...@lyx.org>
Date:   Wed Jun 8 20:02:33 2016 +0200

    Make scripts python3 compatible
    
    Again using 2to3 and manual checking

diff --git a/lib/generate_contributions.py b/lib/generate_contributions.py
index 822e023..fb22c2f 100755
--- a/lib/generate_contributions.py
+++ b/lib/generate_contributions.py
@@ -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)
 
 
diff --git a/lib/scripts/fig_copy.py b/lib/scripts/fig_copy.py
index 1c66b32..d5e0421 100644
--- a/lib/scripts/fig_copy.py
+++ b/lib/scripts/fig_copy.py
@@ -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.
diff --git a/lib/scripts/legacy_lyxpreview2ppm.py 
b/lib/scripts/legacy_lyxpreview2ppm.py
index ee49e6a..3049b44 100644
--- a/lib/scripts/legacy_lyxpreview2ppm.py
+++ b/lib/scripts/legacy_lyxpreview2ppm.py
@@ -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:
diff --git a/lib/scripts/lyxpreview_tools.py b/lib/scripts/lyxpreview_tools.py
index de2e5c5..2012927 100644
--- a/lib/scripts/lyxpreview_tools.py
+++ b/lib/scripts/lyxpreview_tools.py
@@ -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

Reply via email to