Merge pull request #544 from anthrotype/ttProgram-eq
test for NotImplemented in __ne__; add __eq__ and __ne__ to ttProgram.Program
This commit is contained in:
commit
8bf333facb
@ -68,7 +68,6 @@ class TTGlyphPenTest(unittest.TestCase):
|
||||
pen.endPath()
|
||||
endPathGlyph = pen.glyph()
|
||||
|
||||
endPathGlyph.program = closePathGlyph.program
|
||||
self.assertEqual(closePathGlyph, endPathGlyph)
|
||||
|
||||
def test_glyph_errorOnUnendedContour(self):
|
||||
@ -105,7 +104,6 @@ class TTGlyphPenTest(unittest.TestCase):
|
||||
pen.closePath()
|
||||
plainGlyph = pen.glyph()
|
||||
|
||||
plainGlyph.program = compositeGlyph.program
|
||||
self.assertEqual(plainGlyph, compositeGlyph)
|
||||
|
||||
|
||||
|
@ -39,9 +39,11 @@ class DefaultTable(object):
|
||||
def __repr__(self):
|
||||
return "<'%s' table at %x>" % (self.tableTag, id(self))
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
def __eq__(self, other):
|
||||
if type(self) != type(other):
|
||||
return NotImplemented
|
||||
return self.__dict__ == other.__dict__
|
||||
|
||||
def __ne__(self, other):
|
||||
result = self.__eq__(other)
|
||||
return result if result is NotImplemented else not result
|
||||
|
@ -979,13 +979,14 @@ class Glyph(object):
|
||||
cFlags = cFlags[nextOnCurve:]
|
||||
pen.closePath()
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
def __eq__(self, other):
|
||||
if type(self) != type(other):
|
||||
return NotImplemented
|
||||
return self.__dict__ == other.__dict__
|
||||
|
||||
def __ne__(self, other):
|
||||
result = self.__eq__(other)
|
||||
return result if result is NotImplemented else not result
|
||||
|
||||
class GlyphComponent(object):
|
||||
|
||||
@ -1141,13 +1142,15 @@ class GlyphComponent(object):
|
||||
self.transform = [[scale, 0], [0, scale]]
|
||||
self.flags = safeEval(attrs["flags"])
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
def __eq__(self, other):
|
||||
if type(self) != type(other):
|
||||
return NotImplemented
|
||||
return self.__dict__ == other.__dict__
|
||||
|
||||
def __ne__(self, other):
|
||||
result = self.__eq__(other)
|
||||
return result if result is NotImplemented else not result
|
||||
|
||||
class GlyphCoordinates(object):
|
||||
|
||||
def __init__(self, iterable=[], typecode="h"):
|
||||
@ -1261,13 +1264,14 @@ class GlyphCoordinates(object):
|
||||
py = x * t[0][1] + y * t[1][1]
|
||||
self[i] = (px, py)
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
def __eq__(self, other):
|
||||
if type(self) != type(other):
|
||||
return NotImplemented
|
||||
return self._a == other._a
|
||||
|
||||
def __ne__(self, other):
|
||||
result = self.__eq__(other)
|
||||
return result if result is NotImplemented else not result
|
||||
|
||||
def reprflag(flag):
|
||||
bin = ""
|
||||
|
@ -305,11 +305,10 @@ class TrackTableEntry(MutableMapping):
|
||||
return "TrackTableEntry({}, nameIndex={})".format(self._map, self.nameIndex)
|
||||
|
||||
def __eq__(self, other):
|
||||
if (isinstance(other, TrackTableEntry)
|
||||
and self.nameIndex == other.nameIndex
|
||||
and dict(self) == dict(other)):
|
||||
return True
|
||||
return False
|
||||
if not isinstance(other, self.__class__):
|
||||
return NotImplemented
|
||||
return self.nameIndex == other.nameIndex and dict(self) == dict(other)
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
result = self.__eq__(other)
|
||||
return result if result is NotImplemented else not result
|
||||
|
@ -345,7 +345,9 @@ class OTTableWriter(object):
|
||||
return hash(self.items)
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
result = self.__eq__(other)
|
||||
return result if result is NotImplemented else not result
|
||||
|
||||
def __eq__(self, other):
|
||||
if type(self) != type(other):
|
||||
return NotImplemented
|
||||
@ -754,7 +756,9 @@ class BaseTable(object):
|
||||
setattr(self, conv.name, value)
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
result = self.__eq__(other)
|
||||
return result if result is NotImplemented else not result
|
||||
|
||||
def __eq__(self, other):
|
||||
if type(self) != type(other):
|
||||
return NotImplemented
|
||||
@ -933,7 +937,9 @@ class ValueRecord(object):
|
||||
setattr(self, name, value)
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
result = self.__eq__(other)
|
||||
return result if result is NotImplemented else not result
|
||||
|
||||
def __eq__(self, other):
|
||||
if type(self) != type(other):
|
||||
return NotImplemented
|
||||
|
@ -496,6 +496,15 @@ class Program(object):
|
||||
|
||||
__nonzero__ = __bool__
|
||||
|
||||
def __eq__(self, other):
|
||||
if type(self) != type(other):
|
||||
return NotImplemented
|
||||
return self.__dict__ == other.__dict__
|
||||
|
||||
def __ne__(self, other):
|
||||
result = self.__eq__(other)
|
||||
return result if result is NotImplemented else not result
|
||||
|
||||
|
||||
def _test():
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user