Make __cmp__() functions stable
This commit is contained in:
parent
d95db25720
commit
0ba7aa7ab5
@ -37,9 +37,8 @@ class DefaultTable:
|
||||
return "<'%s' table at %x>" % (self.tableTag, id(self))
|
||||
|
||||
def __cmp__(self, other):
|
||||
if type(self) != type(other) or \
|
||||
self.__class__ != other.__class__:
|
||||
return cmp(id(self), id(other))
|
||||
if type(self) != type(other): return cmp(type(self), type(other))
|
||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||
|
||||
return cmp(self.__dict__, other.__dict__)
|
||||
|
||||
|
@ -238,9 +238,8 @@ class GlyphRecord:
|
||||
"""Compare method, so a list of NameRecords can be sorted
|
||||
according to the spec by just sorting it..."""
|
||||
|
||||
if type(self) != type(other) or \
|
||||
self.__class__ != other.__class__:
|
||||
return cmp(id(self), id(other))
|
||||
if type(self) != type(other): return cmp(type(self), type(other))
|
||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||
|
||||
return cmp(self.glyphID, other.glyphID)
|
||||
|
||||
@ -328,9 +327,8 @@ class StringRecord:
|
||||
"""Compare method, so a list of NameRecords can be sorted
|
||||
according to the spec by just sorting it..."""
|
||||
|
||||
if type(self) != type(other) or \
|
||||
self.__class__ != other.__class__:
|
||||
return cmp(id(self), id(other))
|
||||
if type(self) != type(other): return cmp(type(self), type(other))
|
||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||
|
||||
return cmp(self.labelID, other.labelID)
|
||||
|
||||
|
@ -151,9 +151,8 @@ class CmapSubtable:
|
||||
writer.newline()
|
||||
|
||||
def __cmp__(self, other):
|
||||
if type(self) != type(other) or \
|
||||
self.__class__ != other.__class__:
|
||||
return cmp(id(self), id(other))
|
||||
if type(self) != type(other): return cmp(type(self), type(other))
|
||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||
|
||||
# implemented so that list.sort() sorts according to the cmap spec.
|
||||
selfTuple = (
|
||||
|
@ -721,9 +721,8 @@ class Glyph:
|
||||
self.data = data
|
||||
|
||||
def __cmp__(self, other):
|
||||
if type(self) != type(other) or \
|
||||
self.__class__ != other.__class__:
|
||||
return cmp(id(self), id(other))
|
||||
if type(self) != type(other): return cmp(type(self), type(other))
|
||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||
|
||||
return cmp(self.__dict__, other.__dict__)
|
||||
|
||||
@ -885,9 +884,8 @@ class GlyphComponent:
|
||||
self.flags = safeEval(attrs["flags"])
|
||||
|
||||
def __cmp__(self, other):
|
||||
if type(self) != type(other) or \
|
||||
self.__class__ != other.__class__:
|
||||
return cmp(id(self), id(other))
|
||||
if type(self) != type(other): return cmp(type(self), type(other))
|
||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||
|
||||
return cmp(self.__dict__, other.__dict__)
|
||||
|
||||
|
@ -90,9 +90,8 @@ class table__h_e_a_d(DefaultTable.DefaultTable):
|
||||
setattr(self, name, value)
|
||||
|
||||
def __cmp__(self, other):
|
||||
if type(self) != type(other) or \
|
||||
self.__class__ != other.__class__:
|
||||
return cmp(id(self), id(other))
|
||||
if type(self) != type(other): return cmp(type(self), type(other))
|
||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||
|
||||
selfdict = self.__dict__.copy()
|
||||
otherdict = other.__dict__.copy()
|
||||
|
@ -164,9 +164,8 @@ class KernTable_format_0:
|
||||
del self.kernTable[pair]
|
||||
|
||||
def __cmp__(self, other):
|
||||
if type(self) != type(other) or \
|
||||
self.__class__ != other.__class__:
|
||||
return cmp(id(self), id(other))
|
||||
if type(self) != type(other): return cmp(type(self), type(other))
|
||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||
|
||||
return cmp(self.__dict__, other.__dict__)
|
||||
|
||||
|
@ -60,9 +60,8 @@ class table__l_o_c_a(DefaultTable.DefaultTable):
|
||||
return len(self.locations)
|
||||
|
||||
def __cmp__(self, other):
|
||||
if type(self) != type(other) or \
|
||||
self.__class__ != other.__class__:
|
||||
return cmp(id(self), id(other))
|
||||
if type(self) != type(other): return cmp(type(self), type(other))
|
||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||
|
||||
return cmp(self.locations, other.locations)
|
||||
|
||||
|
@ -89,9 +89,8 @@ class table__n_a_m_e(DefaultTable.DefaultTable):
|
||||
return None # not found
|
||||
|
||||
def __cmp__(self, other):
|
||||
if type(self) != type(other) or \
|
||||
self.__class__ != other.__class__:
|
||||
return cmp(id(self), id(other))
|
||||
if type(self) != type(other): return cmp(type(self), type(other))
|
||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||
|
||||
return cmp(self.names, other.names)
|
||||
|
||||
@ -139,9 +138,8 @@ class NameRecord:
|
||||
"""Compare method, so a list of NameRecords can be sorted
|
||||
according to the spec by just sorting it..."""
|
||||
|
||||
if type(self) != type(other) or \
|
||||
self.__class__ != other.__class__:
|
||||
return cmp(id(self), id(other))
|
||||
if type(self) != type(other): return cmp(type(self), type(other))
|
||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||
|
||||
selftuple = (self.platformID,
|
||||
self.platEncID,
|
||||
|
@ -288,9 +288,8 @@ class OTTableWriter:
|
||||
return hash(self.items)
|
||||
|
||||
def __cmp__(self, other):
|
||||
if type(self) != type(other) or \
|
||||
self.__class__ != other.__class__:
|
||||
return cmp(id(self), id(other))
|
||||
if type(self) != type(other): return cmp(type(self), type(other))
|
||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||
|
||||
return cmp(self.items, other.items)
|
||||
|
||||
@ -671,9 +670,8 @@ class BaseTable:
|
||||
setattr(self, conv.name, value)
|
||||
|
||||
def __cmp__(self, other):
|
||||
if type(self) != type(other) or \
|
||||
self.__class__ != other.__class__:
|
||||
return cmp(id(self), id(other))
|
||||
if type(self) != type(other): return cmp(type(self), type(other))
|
||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||
|
||||
return cmp(self.__dict__, other.__dict__)
|
||||
|
||||
@ -835,8 +833,7 @@ class ValueRecord:
|
||||
setattr(self, name, value)
|
||||
|
||||
def __cmp__(self, other):
|
||||
if type(self) != type(other) or \
|
||||
self.__class__ != other.__class__:
|
||||
return cmp(id(self), id(other))
|
||||
if type(self) != type(other): return cmp(type(self), type(other))
|
||||
if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
|
||||
|
||||
return cmp(self.__dict__, other.__dict__)
|
||||
|
Loading…
x
Reference in New Issue
Block a user