/soc/2013/ashmew2/filetransferX: 62abcbd82f30: Enabled build for...

Ashish Gupta ashmew2 at gmail.com
Tue Jun 4 18:24:27 EDT 2013


Changeset: 62abcbd82f30a81aa47109b61194e162d82a3a3b
Author:	 Ashish Gupta <ashmew2 at gmail.com>
Date:	 2013-05-06 00:42 +0530
Branch:	 default
URL: https://hg.pidgin.im/soc/2013/ashmew2/filetransferX/rev/62abcbd82f30

Description:

Enabled build for both Python2 and Python 3

diffstat:

 configure.ac                                 |  10 +-
 libpurple/dbus-analyze-functions.py          |  83 ++++++++++++++-------------
 libpurple/dbus-analyze-signals.py            |  14 ++--
 libpurple/dbus-analyze-types.py              |  24 ++-----
 libpurple/plugins/dbus-buddyicons-example.py |   3 +-
 libpurple/plugins/startup.py                 |  14 ++--
 6 files changed, 70 insertions(+), 78 deletions(-)

diffs (truncated from 362 to 300 lines):

diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -1635,13 +1635,13 @@ dnl Check for Python headers (currently 
 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, )
diff --git a/libpurple/dbus-analyze-functions.py b/libpurple/dbus-analyze-functions.py
--- a/libpurple/dbus-analyze-functions.py
+++ b/libpurple/dbus-analyze-functions.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
 import re
 import string
 import sys
@@ -240,38 +241,38 @@ class ClientBinding (Binding):
         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):
@@ -357,39 +358,39 @@ class ServerBinding (Binding):
         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):
@@ -440,7 +441,7 @@ class ServerBinding (Binding):
         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):
@@ -543,7 +544,7 @@ class BindingSet:
 
                 
     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()
@@ -558,7 +559,7 @@ class BindingSet:
             # 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
@@ -601,15 +602,15 @@ class ServerBindingSet (BindingSet):
         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):
@@ -647,7 +648,7 @@ else:
 
 if "client" in options:
     bindings = ClientBindingSet(sys.stdin, fprefix,
-                                options.has_key("headers"))
+                                "headers" in options)
 else:
     bindings = ServerBindingSet(sys.stdin, fprefix)
 bindings.process()
diff --git a/libpurple/dbus-analyze-signals.py b/libpurple/dbus-analyze-signals.py
--- a/libpurple/dbus-analyze-signals.py
+++ b/libpurple/dbus-analyze-signals.py
@@ -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 @@ excluded = [\
 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 @@ for match in registerregex.finditer(sys.
         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 @@ for match in registerregex.finditer(sys.
                 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(";")
 
diff --git a/libpurple/dbus-analyze-types.py b/libpurple/dbus-analyze-types.py
--- a/libpurple/dbus-analyze-types.py
+++ b/libpurple/dbus-analyze-types.py
@@ -13,11 +13,9 @@
 #           NAME2
 #           NAME3
 # 
-
-
+from __future__ import print_function
 import re
 import sys
-
 options = {}
 
 def toprint(match, line):
@@ -37,39 +35,33 @@ for arg in sys.argv[1:]:
 
 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



More information about the Commits mailing list