Fix build and other scripts on Python3. release-2.x.y

Sat, 11 May 2013 17:58:52 -0400

author
Ashish Gupta <ashmew2@gmail.com>
date
Sat, 11 May 2013 17:58:52 -0400
branch
release-2.x.y
changeset 33932
c49bfe98716d
parent 33897
f7d55c9c57d3
child 33933
bd00e2d2b32e
child 34216
1578a94420d8

Fix build and other scripts on Python3.

Closes #15624.

COPYRIGHT file | annotate | diff | comparison | revisions
ChangeLog file | annotate | diff | comparison | revisions
configure.ac file | annotate | diff | comparison | revisions
libpurple/dbus-analyze-functions.py file | annotate | diff | comparison | revisions
libpurple/dbus-analyze-signals.py file | annotate | diff | comparison | revisions
libpurple/dbus-analyze-types.py file | annotate | diff | comparison | revisions
libpurple/plugins/dbus-buddyicons-example.py file | annotate | diff | comparison | revisions
libpurple/plugins/startup.py file | annotate | diff | comparison | revisions
--- a/COPYRIGHT	Wed Apr 17 23:55:31 2013 +0200
+++ b/COPYRIGHT	Sat May 11 17:58:52 2013 -0400
@@ -214,6 +214,7 @@
 Vladislav Guberinić
 Gideon N. Guillen
 Aman Gupta
+Ashish Gupta
 Christian Hammond
 Erick Hamness
 Fred Hampton
--- a/ChangeLog	Wed Apr 17 23:55:31 2013 +0200
+++ b/ChangeLog	Sat May 11 17:58:52 2013 -0400
@@ -4,6 +4,9 @@
 	Stock market:
 	* Didn't really increase, but didn't plummet, either.
 
+	General:
+	* Add support for Python3 in build scripts. (Ashish Gupta) (#15624)
+
 	Windows-Specific Changes:
 	* Updates to dependencies:
 		* NSS 3.14.3 and NSPR 4.9.5
--- a/configure.ac	Wed Apr 17 23:55:31 2013 +0200
+++ b/configure.ac	Sat May 11 17:58:52 2013 -0400
@@ -1493,13 +1493,13 @@
 dnl (Thanks to XChat)
 if test "x$enable_consoleui" = "xyes" -a ! -z "$PYTHON" -a x"$PYTHON" != x"no" ; then
 	AC_MSG_CHECKING(for Python compile flags)
-	PY_PREFIX=`$PYTHON -c 'import sys ; print sys.prefix'`
-	PY_EXEC_PREFIX=`$PYTHON -c 'import sys ; print sys.exec_prefix'`
+	PY_PREFIX=`$PYTHON -c 'import sys ; sys.stdout.write(sys.prefix)'`
+	PY_EXEC_PREFIX=`$PYTHON -c 'import sys ; sys.stdout.write(sys.exec_prefix)'`
 	changequote(<<, >>)dnl
-	PY_VERSION=`$PYTHON -c 'import sys ; print sys.version[0:3]'`
-	PY_MAJOR=`$PYTHON -c 'import sys ; print sys.version[0:2]'`
+	PY_VERSION=`$PYTHON -c 'import sys ; sys.stdout.write(sys.version[0:3])'`
+	PY_MAJOR=`$PYTHON -c 'import sys ; sys.stdout.write(sys.version[0:2])'`
 	changequote([, ])dnl
-	if test -f $PY_PREFIX/include/python$PY_VERSION/Python.h -a "$PY_MAJOR" = "2."; then
+	if test -f $PY_PREFIX/include/python$PY_VERSION/Python.h; then
 		AC_MSG_RESULT()
 		AC_CHECK_LIB(pthread, pthread_create, )
 		AC_CHECK_LIB(util, openpty, )
--- a/libpurple/dbus-analyze-functions.py	Wed Apr 17 23:55:31 2013 +0200
+++ b/libpurple/dbus-analyze-functions.py	Sat May 11 17:58:52 2013 -0400
@@ -1,3 +1,4 @@
+from __future__ import print_function
 import re
 import string
 import sys
@@ -236,38 +237,38 @@
         paramslist = ", ".join(self.paramshdr)
         if (paramslist == "") :
             paramslist = "void"
-        print "%s %s(%s)" % (self.functiontype, self.function.name,
-                             paramslist),
+        print("%s %s(%s)" % (self.functiontype, self.function.name,
+                             paramslist), end=' ')
 
         if self.headersonly:
-            print ";"
+            print(";")
             return
 
-        print "{"
+        print("{")
 
         for decl in self.decls:
-            print decl
+            print(decl)
 
-        print 'dbus_g_proxy_call(purple_proxy, "%s", NULL,' % ctopascal(self.function.name)
+        print('dbus_g_proxy_call(purple_proxy, "%s", NULL,' % ctopascal(self.function.name))
         
         for type_name in self.inputparams:
-            print "\t%s, %s, " % type_name,
-        print "G_TYPE_INVALID,"
+            print("\t%s, %s, " % type_name, end=' ')
+        print("G_TYPE_INVALID,")
 
         for type_name in self.outputparams:
-            print "\t%s, &%s, " % type_name,
-        print "G_TYPE_INVALID);"
+            print("\t%s, &%s, " % type_name, end=' ')
+        print("G_TYPE_INVALID);")
         
         for code in self.returncode:
-            print code
+            print(code)
 
-        print "}\n"
+        print("}\n")
         
 
     def definepurplestructure(self, type):
         if (self.headersonly) and (type[0] not in self.knowntypes):
-            print "struct _%s;" % type[0]
-            print "typedef struct _%s %s;" % (type[0], type[0])
+            print("struct _%s;" % type[0])
+            print("typedef struct _%s %s;" % (type[0], type[0]))
             self.knowntypes.append(type[0])
 
     def inputsimple(self, type, name, us):
@@ -353,39 +354,39 @@
         self.argfunc = "dbus_message_get_args"
 
     def flush(self):
-        print "static DBusMessage*"
-        print "%s_DBUS(DBusMessage *message_DBUS, DBusError *error_DBUS) {" % \
-              self.function.name
+        print("static DBusMessage*")
+        print("%s_DBUS(DBusMessage *message_DBUS, DBusError *error_DBUS) {" % \
+              self.function.name)
         
-        print "\tDBusMessage *reply_DBUS;"
+        print("\tDBusMessage *reply_DBUS;")
 
         for decl in self.cdecls:
-            print decl
+            print(decl)
 
-        print "\t%s(message_DBUS, error_DBUS," % self.argfunc,
+        print("\t%s(message_DBUS, error_DBUS," % self.argfunc,end=' ')
         for param in self.cparams:
-            print "DBUS_TYPE_%s, &%s," % param,
-        print "DBUS_TYPE_INVALID);"
+            print("DBUS_TYPE_%s, &%s," % param, end=' ')
+        print("DBUS_TYPE_INVALID);")
 
-        print "\tCHECK_ERROR(error_DBUS);"
+        print("\tCHECK_ERROR(error_DBUS);")
 
         for code in self.ccode:
-            print code
+            print(code)
 
-        print "\treply_DBUS = dbus_message_new_method_return (message_DBUS);"
+        print("\treply_DBUS = dbus_message_new_method_return (message_DBUS);")
 
-        print "\tdbus_message_append_args(reply_DBUS,",
+        print("\tdbus_message_append_args(reply_DBUS,", end=' ')
         for param in self.cparamsout:
             if type(param) is str:
-                print "%s," % param,
+                print("%s," % param, end=' ')
             else:
-                print "DBUS_TYPE_%s, &%s," % param,
-        print "DBUS_TYPE_INVALID);"
+                print("DBUS_TYPE_%s, &%s," % param, end=' ')
+        print("DBUS_TYPE_INVALID);")
 
         for code in self.ccodeout:
-            print code
+            print(code)
 
-        print "\treturn reply_DBUS;\n}\n"
+        print("\treturn reply_DBUS;\n}\n")
 
 
     def addstring(self, *items):
@@ -436,7 +437,7 @@
         self.cdecls.append("\t%s *%s;" % (type[0], name))
         self.cparams.append(("INT32", name + "_ID"))
         self.ccode.append("\tPURPLE_DBUS_ID_TO_POINTER(%s, %s_ID, %s, error_DBUS);"  % \
-                       (name, name, type[0]))
+                          (name, name, type[0]))
         self.addintype("i", name)
 
     def inputpointer(self, type, name):
@@ -539,7 +540,7 @@
 
                 
     def process(self):
-        print "/* Generated by %s.  Do not edit! */" % sys.argv[0]
+        print("/* Generated by %s.  Do not edit! */" % sys.argv[0])
 
         for line in self.inputiter:
             words = line.split()
@@ -554,7 +555,7 @@
             # empty line has been encountered
             myline = line.strip()
             while (myline.count("(") > myline.count(")")) or self.typeregexp.match(myline):
-                newline = self.inputiter.next().strip()
+                newline = next(self.inputiter).strip()
                 if len(newline) == 0:
                     break
                 myline += " " + newline
@@ -597,15 +598,15 @@
         self.functions.append((binding.function.name, binding.dparams))
         
     def flush(self):
-        print "static PurpleDBusBinding bindings_DBUS[] = { "
+        print("static PurpleDBusBinding bindings_DBUS[] = { ")
         for function, params in self.functions:
-            print '{"%s", "%s", %s_DBUS},' % \
-                  (ctopascal(function), params, function)
+            print('{"%s", "%s", %s_DBUS},' % \
+                  (ctopascal(function), params, function))
 
-        print "{NULL, NULL, NULL}"
-        print "};"
+        print("{NULL, NULL, NULL}")
+        print("};")
 
-        print "#define PURPLE_DBUS_REGISTER_BINDINGS(handle) purple_dbus_register_bindings(handle, bindings_DBUS)"
+        print("#define PURPLE_DBUS_REGISTER_BINDINGS(handle) purple_dbus_register_bindings(handle, bindings_DBUS)")
         
 class ClientBindingSet (BindingSet):
     def __init__(self, inputfile, fprefix, headersonly):
@@ -643,7 +644,7 @@
 
 if "client" in options:
     bindings = ClientBindingSet(sys.stdin, fprefix,
-                                options.has_key("headers"))
+                                "headers" in options)
 else:
     bindings = ServerBindingSet(sys.stdin, fprefix)
 bindings.process()
--- a/libpurple/dbus-analyze-signals.py	Wed Apr 17 23:55:31 2013 +0200
+++ b/libpurple/dbus-analyze-signals.py	Sat May 11 17:58:52 2013 -0400
@@ -5,7 +5,7 @@
 #   <signal name="Changed">
 #       <arg name="new_value" type="b"/>
 #   </signal>
-
+from __future__ import print_function
 import re
 import sys
 
@@ -23,8 +23,8 @@
 registerregex = re.compile("purple_signal_register[^;]+\"([\w\-]+)\"[^;]+(purple_marshal_\w+)[^;]+;")
 nameregex = re.compile('[-_][a-z]')
 
-print "/* Generated by %s.  Do not edit! */" % sys.argv[0]
-print "const char *dbus_signals = "
+print("/* Generated by %s.  Do not edit! */" % sys.argv[0])
+print("const char *dbus_signals = ")
 for match in registerregex.finditer(sys.stdin.read()):
     signal = match.group(1)
     marshal = match.group(2)
@@ -32,7 +32,7 @@
         continue
 
     signal = nameregex.sub(lambda x:x.group()[1].upper(), '-'+signal)
-    print "\"    <signal name='%s'>\\n\""%signal
+    print("\"    <signal name='%s'>\\n\"" % signal)
 
     args = marshal.split('_')
     # ['purple', 'marshal', <return type>, '', args...]
@@ -52,9 +52,9 @@
                 type = 't'
             elif arg == "BOOLEAN":
                 type = 'b'
-            print "\"      <arg type='%s'/>\\n\""%type
+            print("\"      <arg type='%s'/>\\n\"" % type)
 
-    print "\"    </signal>\\n\""
+    print("\"    </signal>\\n\"")
 
-print ";"
+print(";")
 
--- a/libpurple/dbus-analyze-types.py	Wed Apr 17 23:55:31 2013 +0200
+++ b/libpurple/dbus-analyze-types.py	Sat May 11 17:58:52 2013 -0400
@@ -7,14 +7,14 @@
 #
 # --enum    DBUS_POINTER_NAME1,
 #           DBUS_POINTER_NAME2,
-#           DBUS_POINTER_NAME3, 
-# 
+#           DBUS_POINTER_NAME3,
+#
 # --list    NAME1
 #           NAME2
 #           NAME3
-# 
+#
 
-
+from __future__ import print_function
 import re
 import sys
 
@@ -37,39 +37,33 @@
 
 keyword = options.get("keyword", "struct")
 pattern = options.get("pattern", "%s")
-verbatim = options.has_key("verbatim")
+verbatim = "verbatim" in options
 
 structregexp1 = re.compile(r"^(typedef\s+)?%s\s+\w+\s+(\w+)\s*;" % keyword)
 structregexp2 = re.compile(r"^(typedef\s+)?%s" % keyword)
 structregexp3 = re.compile(r"^}\s+(\w+)\s*;")
 
-print "/* Generated by %s.  Do not edit! */" % sys.argv[0]
+print("/* Generated by %s.  Do not edit! */" % sys.argv[0])
 
 myinput = iter(sys.stdin)
 
 for line in myinput:
     match = structregexp1.match(line)
     if match is not None:
-        print toprint(match.group(2), line)
+        print(toprint(match.group(2), line))
         continue
 
     match = structregexp2.match(line)
     if match is not None:
         while True:
             if verbatim:
-                print line.rstrip()
-            line = myinput.next()
+                print(line.rstrip())
+            line = next(myinput)
             match = structregexp3.match(line)
             if match is not None:
-                print toprint(match.group(1), line)
+                print(toprint(match.group(1), line))
                 break
             if line[0] not in [" ", "\t", "{", "\n"]:
                 if verbatim:
-                    print line
+                    print(line)
                 break
-        
-
-
-
-    
-    
--- a/libpurple/plugins/dbus-buddyicons-example.py	Wed Apr 17 23:55:31 2013 +0200
+++ b/libpurple/plugins/dbus-buddyicons-example.py	Sat May 11 17:58:52 2013 -0400
@@ -21,6 +21,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
 #
 
+from __future__ import print_function
 import dbus
 
 bus = dbus.SessionBus()
@@ -32,5 +33,5 @@
 	if purple.PurpleBlistNodeIsBuddy(node):
 		icon = purple.PurpleBuddyGetIcon(node)
 		if icon != 0:
-			print purple.PurpleBuddyGetAlias(node)
+			print(purple.PurpleBuddyGetAlias(node))
 	node = purple.PurpleBlistNodeNext(node, 0)
--- a/libpurple/plugins/startup.py	Wed Apr 17 23:55:31 2013 +0200
+++ b/libpurple/plugins/startup.py	Sat May 11 17:58:52 2013 -0400
@@ -21,16 +21,15 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
 #
 
+from __future__ import print_function
 import sys
 import dbus
 import os
 
 if len(sys.argv) == 1:
-	print "Usage:", sys.argv[0], """<purple-client> [arguments]
-
-Example:
-	""", sys.argv[0], "pidgin -d -c /my/home"
-	sys.exit(1)
+    print("Usage:", sys.argv[0], "<purple-client> [arguments]")
+    print("\nExample:\n   ", sys.argv[0], "pidgin -d -c /my/home")
+    sys.exit(1)
 
 home = os.path.expanduser('~/.purple/')
 for arg in range(1, len(sys.argv[1:])):
@@ -47,10 +46,10 @@
 	if not os.path.isabs(userdir):
 		userdir = os.path.join(purple.PurpleHomeDir(), userdir)
 	if home == userdir:
-		print "Already running."
+		print("Already running.")
 		purple.PurpleBlistShow()
 	else:
-		print "Starting client from a different home directory."
+		print("Starting client from a different home directory.")
 		raise
 except:
 	os.execlp(sys.argv[1], " ".join(sys.argv[2:]))

mercurial