Permalink
Browse files

[gi-demos] some python 3 compat fixes

  • Loading branch information...
1 parent fd5d5ef commit 097e5efab29d3d2d91d0b9fc75bf00219e9b7810 John (J5) Palmieri committed Mar 7, 2011
@@ -106,6 +106,12 @@ def sort_func(self, store, a_iter, b_iter, user_data):
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):
@@ -102,7 +102,7 @@ def spinner_timeout(self):
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
@@ -38,9 +38,9 @@
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
@@ -124,7 +124,7 @@ def load_demos_from_list(self, file_list, demo_list):
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 @@ def load_demos(self, top_dir='demos', demo_list=None):
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)

0 comments on commit 097e5ef

Please sign in to comment.