[evolution-data-server] Bug #705028 - gen-western-table.py is not compatible with python3



commit 86a6596c05187022a9fd95a66cc43bbd7481cce3
Author: Arfrever Frehtes Taifersar Arahesis <Arfrever FTA GMail Com>
Date:   Tue Feb 25 16:04:47 2014 +0100

    Bug #705028 - gen-western-table.py is not compatible with python3

 addressbook/libebook-contacts/gen-western-table.py |   25 ++++++++++++-------
 1 files changed, 16 insertions(+), 9 deletions(-)
---
diff --git a/addressbook/libebook-contacts/gen-western-table.py 
b/addressbook/libebook-contacts/gen-western-table.py
index cdd2514..3456fd8 100755
--- a/addressbook/libebook-contacts/gen-western-table.py
+++ b/addressbook/libebook-contacts/gen-western-table.py
@@ -18,30 +18,37 @@
 
 import sys
 
+if sys.version_info[0] >= 3:
+    stdin = sys.stdin.buffer
+    stdout = sys.stdout.buffer
+else:
+    stdin = sys.stdin
+    stdout = sys.stdout
+
 var = None
 strings = []
 
 def output():
-    print "static const gchar %s_table[] = {" % var
+    stdout.write(b"static const gchar " + var + b"_table[] = {\n")
     for s in strings:
-        print "  \"%s\\0\"" % s
-    print "};"
+        stdout.write(b"  \"" + s + b"\\0\"\n")
+    stdout.write(b"};\n")
 
-    print "static const guint %s_index[] = {" % var
+    stdout.write(b"static const guint " + var + b"_index[] = {\n")
     index = 0
     for s in strings:
-        print "  %d," % index
+        stdout.write(b"  " + str(index).encode() + b",\n")
         index += len(s) + 1
-    print "};\n"
+    stdout.write(b"};\n\n")
     
 (S_VAR, S_STRING) = range(0, 2)
 state = S_VAR
 
-print "/* This file is generated by gen-western-table.py. DO NOT EDIT */"
+stdout.write(b"/* This file is generated by gen-western-table.py. DO NOT EDIT */\n")
 
-for l in sys.stdin.readlines():
+for l in stdin.readlines():
     l = l.strip()
-    if l == "":
+    if l == b"":
         state = S_VAR
         output()
         var = None


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]