Ensure that action category names are unicode, to prevent warnings on comparison.

This commit is contained in:
Mattias Põldaru 2011-12-06 23:25:04 +02:00
parent 73d0050b95
commit 1830cfbe9e

View File

@ -149,6 +149,8 @@ class CategoryList(object):
return self.__next__()
def has_key(self, key):
if key != None and not isinstance(key, unicode):
key = unicode(key)
for category in self.categories:
if category.name == key:
return True
@ -164,6 +166,8 @@ class CategoryList(object):
self.add(name, weight)
def add(self, name, weight=0, actions=None):
if name != None and not isinstance(name, unicode):
name = unicode(name)
category = ActionCategory(name, weight)
if actions:
for action in actions:
@ -270,6 +274,8 @@ class ActionList(object):
``weight``
The category's weight (int).
"""
if name != None and not isinstance(name, unicode):
name = unicode(name)
if name in self.categories:
# Only change the weight and resort the categories again.
for category in self.categories: