def __cmp__(self, other): """Compare Messages, taking into account plural ids""" def values_to_compare(obj): if isinstance(obj, Message) and obj.pluralizable: return obj.id[0], obj.context or '' return obj.id, obj.context or '' return cmp(values_to_compare(self), values_to_compare(other))
def __cmp__(self, other): """Compare Messages, taking into account plural ids""" def values_to_compare(obj): if isinstance(obj, Message) and obj.pluralizable: return obj.id[0], obj.context or '' return obj.id, obj.context or '' return cmp(values_to_compare(self), values_to_compare(other))
def __cmp__(self, obj): """Compare Messages, taking into account plural ids""" def values_to_compare(): if isinstance(obj, Message): plural = self.pluralizable obj_plural = obj.pluralizable if plural and obj_plural: return self.id[0], obj.id[0] elif plural: return self.id[0], obj.id elif obj_plural: return self.id, obj.id[0] return self.id, obj.id this, other = values_to_compare() return cmp(this, other)
def __cmp__(self, obj): """Compare Messages, taking into account plural ids""" def values_to_compare(): if isinstance(obj, Message): plural = self.pluralizable obj_plural = obj.pluralizable if plural and obj_plural: return self.id[0], obj.id[0] elif plural: return self.id[0], obj.id elif obj_plural: return self.id, obj.id[0] return self.id, obj.id this, other = values_to_compare() return cmp(this, other)
def __cmp__(self, other): if not other: return 1 return cmp(text_type(self), text_type(other))
def __cmp__(self, other): if not other: return 1 return cmp(text_type(self), text_type(other))