[pygobject] [gi-demos] some python 3 compat fixes



commit 097e5efab29d3d2d91d0b9fc75bf00219e9b7810
Author: John (J5) Palmieri <johnp redhat com>
Date:   Mon Mar 7 18:09:18 2011 -0500

    [gi-demos] some python 3 compat fixes

 demos/gtk-demo/demos/Icon View/iconviewbasics.py |    6 ++++++
 demos/gtk-demo/demos/Tree View/liststore.py      |    2 +-
 demos/gtk-demo/demos/rotatedtext.py              |    4 ++--
 demos/gtk-demo/gtk-demo.py                       |    4 ++--
 4 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/demos/gtk-demo/demos/Icon View/iconviewbasics.py b/demos/gtk-demo/demos/Icon View/iconviewbasics.py
index 5632046..e2cf45c 100644
--- a/demos/gtk-demo/demos/Icon View/iconviewbasics.py	
+++ b/demos/gtk-demo/demos/Icon View/iconviewbasics.py	
@@ -106,6 +106,12 @@ class IconViewApp:
                                        self.COL_DISPLAY_NAME, 
                                        self.COL_IS_DIRECTORY)
 
+        if a_name is None:
+            a_name = ''
+
+        if b_name is None:
+            b_name = ''
+
         if (not a_is_dir) and b_is_dir:
             return 1
         elif a_is_dir and (not b_is_dir):
diff --git a/demos/gtk-demo/demos/Tree View/liststore.py b/demos/gtk-demo/demos/Tree View/liststore.py
index 30ff97e..0be862e 100644
--- a/demos/gtk-demo/demos/Tree View/liststore.py	
+++ b/demos/gtk-demo/demos/Tree View/liststore.py	
@@ -102,7 +102,7 @@ class ListStoreApp:
             
         iter_ = self.model.get_iter_first()
         pulse = self.model.get(iter_, self.COLUMN_PULSE)[0]
-        if pulse == sys.maxint:
+        if pulse == 999999999:
             pulse = 0
         else:
             pulse += 1
diff --git a/demos/gtk-demo/demos/rotatedtext.py b/demos/gtk-demo/demos/rotatedtext.py
index 30d606c..af33319 100644
--- a/demos/gtk-demo/demos/rotatedtext.py
+++ b/demos/gtk-demo/demos/rotatedtext.py
@@ -38,9 +38,9 @@ if sys.version_info < (3, 0):
     HEART = unicode(BYTES_HEART, 'UTF-8')
 else:
     UTF8_TEXT = "I â?¥ GTK+"
-    BYTES_TEXT = bytes(UTF8_TEXT)
+    BYTES_TEXT = bytes(UTF8_TEXT, 'utf-8')
     HEART = "â?¥"
-    BYTES_HEART = bytes(HEART)
+    BYTES_HEART = bytes(HEART, 'utf-8')
 
 class RotatedTextApp:
     RADIUS = 150
diff --git a/demos/gtk-demo/gtk-demo.py b/demos/gtk-demo/gtk-demo.py
index 74c0e69..fe24939 100755
--- a/demos/gtk-demo/gtk-demo.py
+++ b/demos/gtk-demo/gtk-demo.py
@@ -124,7 +124,7 @@ class GtkDemoApp(object):
 
                 try:
                     demo = Demo(module.title, module, f)
-                except AttributeError, e:
+                except AttributeError as e:
                     raise AttributeError('(%s): %s' % (f, e.message))
 
             demo_list.append(demo)
@@ -146,7 +146,7 @@ class GtkDemoApp(object):
             if filename.endswith('.py'):
                 demo_file_list.append(fullname)
 
-        demo_file_list.sort(lambda a, b: cmp(a.lower(), b.lower()))
+        demo_file_list = sorted(demo_file_list, key=str.lower)
 
         self.load_demos_from_list(demo_file_list, demo_list)
 



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