From 58bd6951597b13533401d4bb61bf68312a8360db Mon Sep 17 00:00:00 2001
From: Benjamin Piwowarski <bpiwowar@lyx.org>
Date: Sun, 16 Mar 2014 18:49:24 +0100
Subject: [PATCH] Python 3 compatibility: configure.py and prefs2prefs.py

Minor changes:
- print as function
- open a file as text (and not binary)
---
 lib/configure.py           |  6 +++---
 lib/scripts/prefs2prefs.py | 22 +++++++++++-----------
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/lib/configure.py b/lib/configure.py
index aa14a01..c937a76 100644
--- a/lib/configure.py
+++ b/lib/configure.py
@@ -1418,7 +1418,7 @@ if __name__ == '__main__':
     ## Parse the command line
     for op in sys.argv[1:]:   # default shell/for list is $*, the options
         if op in [ '-help', '--help', '-h' ]:
-            print '''Usage: configure [options]
+            print('''Usage: configure [options]
 Options:
     --help                   show this help lines
     --keep-temps             keep temporary files (for debug. purposes)
@@ -1426,7 +1426,7 @@ Options:
     --without-latex-config   do not run LaTeX to determine configuration
     --with-version-suffix=suffix suffix of binary installed files
     --binary-dir=directory   directory of binary installed files
-'''
+''')
             sys.exit(0)
         elif op == '--without-kpsewhich':
             lyx_kpsewhich = False
@@ -1439,7 +1439,7 @@ Options:
         elif op[0:13] == '--binary-dir=':
             lyx_binary_dir = op[13:]
         else:
-            print "Unknown option", op
+            print("Unknown option", op)
             sys.exit(1)
     #
     # check if we run from the right directory
diff --git a/lib/scripts/prefs2prefs.py b/lib/scripts/prefs2prefs.py
index f98b6e8..d9814f4 100644
--- a/lib/scripts/prefs2prefs.py
+++ b/lib/scripts/prefs2prefs.py
@@ -115,11 +115,11 @@ def update_format(lines):
 ###########################################################
 
 def usage():
-	print "%s [-l] [-p] infile outfile" % sys.argv[0]
-	print "or: %s [-l] [-p] <infile >outfile" % sys.argv[0]
-	print "  -l: convert LFUNs (bind and ui files)"
-	print "  -p: convert preferences"
-	print "Note that exactly one of -l and -p is required."
+	print("%s [-l] [-p] infile outfile" % sys.argv[0])
+	print("or: %s [-l] [-p] <infile >outfile" % sys.argv[0])
+	print("  -l: convert LFUNs (bind and ui files)")
+	print("  -p: convert preferences")
+	print("Note that exactly one of -l and -p is required.")
 
 
 def main(argv):
@@ -127,7 +127,7 @@ def main(argv):
 		(options, args) = getopt(sys.argv[1:], "lp")
 	except:
 		usage()
-		print "\nUnrecognized option"
+		print("\nUnrecognized option")
 		sys.exit(1)
 
 	opened_files = False
@@ -136,12 +136,12 @@ def main(argv):
 		source = sys.stdin
 		output = sys.stdout
 	elif len(args) == 2:
-		source = open(args[0], 'rb')
-		output = open(args[1], 'wb')
+		source = open(args[0], 'rt')
+		output = open(args[1], 'wt')
 		opened_files = True
 	else:
 		usage()
-		print "\nEither zero or two arguments must be given."
+		print("\nEither zero or two arguments must be given.")
 		sys.exit(1)
 
 	conversions = False
@@ -154,11 +154,11 @@ def main(argv):
 	
 	if not conversions:
 		usage()
-		print "\nNeither -l nor -p given."
+		print("\nNeither -l nor -p given.")
 		sys.exit(1)
 	elif len(options) > 1:
 		usage()
-		print "\nOnly one of -l or -p should be given."
+		print("\nOnly one of -l or -p should be given.")
 		sys.exit(1)
 
 	current_format = len(conversions)
-- 
1.8.4.2

