diff --git a/Lib/fontTools/ttLib/tables/DefaultTable.py b/Lib/fontTools/ttLib/tables/DefaultTable.py index ff45bc387..8d68ec073 100644 --- a/Lib/fontTools/ttLib/tables/DefaultTable.py +++ b/Lib/fontTools/ttLib/tables/DefaultTable.py @@ -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__) diff --git a/Lib/fontTools/ttLib/tables/M_E_T_A_.py b/Lib/fontTools/ttLib/tables/M_E_T_A_.py index 492ed60f1..b8fb640af 100644 --- a/Lib/fontTools/ttLib/tables/M_E_T_A_.py +++ b/Lib/fontTools/ttLib/tables/M_E_T_A_.py @@ -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) diff --git a/Lib/fontTools/ttLib/tables/_c_m_a_p.py b/Lib/fontTools/ttLib/tables/_c_m_a_p.py index b33d951a8..ecc5668e7 100644 --- a/Lib/fontTools/ttLib/tables/_c_m_a_p.py +++ b/Lib/fontTools/ttLib/tables/_c_m_a_p.py @@ -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 = ( diff --git a/Lib/fontTools/ttLib/tables/_g_l_y_f.py b/Lib/fontTools/ttLib/tables/_g_l_y_f.py index 418d4502f..6a370c1f6 100644 --- a/Lib/fontTools/ttLib/tables/_g_l_y_f.py +++ b/Lib/fontTools/ttLib/tables/_g_l_y_f.py @@ -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__) diff --git a/Lib/fontTools/ttLib/tables/_h_e_a_d.py b/Lib/fontTools/ttLib/tables/_h_e_a_d.py index 060930f24..61d9a1678 100644 --- a/Lib/fontTools/ttLib/tables/_h_e_a_d.py +++ b/Lib/fontTools/ttLib/tables/_h_e_a_d.py @@ -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() diff --git a/Lib/fontTools/ttLib/tables/_k_e_r_n.py b/Lib/fontTools/ttLib/tables/_k_e_r_n.py index 005d1ed08..22c5552d4 100644 --- a/Lib/fontTools/ttLib/tables/_k_e_r_n.py +++ b/Lib/fontTools/ttLib/tables/_k_e_r_n.py @@ -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__) diff --git a/Lib/fontTools/ttLib/tables/_l_o_c_a.py b/Lib/fontTools/ttLib/tables/_l_o_c_a.py index 87b047dd2..21c31ad01 100644 --- a/Lib/fontTools/ttLib/tables/_l_o_c_a.py +++ b/Lib/fontTools/ttLib/tables/_l_o_c_a.py @@ -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) diff --git a/Lib/fontTools/ttLib/tables/_n_a_m_e.py b/Lib/fontTools/ttLib/tables/_n_a_m_e.py index 307fbb543..227098392 100644 --- a/Lib/fontTools/ttLib/tables/_n_a_m_e.py +++ b/Lib/fontTools/ttLib/tables/_n_a_m_e.py @@ -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, diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py index 0f6a4e8a6..8eec6b0f9 100644 --- a/Lib/fontTools/ttLib/tables/otBase.py +++ b/Lib/fontTools/ttLib/tables/otBase.py @@ -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__)