Merge pull request #303 from anthrotype/fix_program_len
[ttProgram] add missing __len__ method to Program class
This commit is contained in:
commit
ca6e5c4f0a
@ -22,5 +22,7 @@ class table__f_p_g_m(DefaultTable.DefaultTable):
|
||||
program.fromXML(name, attrs, content, ttFont)
|
||||
self.program = program
|
||||
|
||||
def __len__(self):
|
||||
return len(self.program)
|
||||
def __bool__(self):
|
||||
return hasattr(self, 'program') and bool(self.program)
|
||||
|
||||
__nonzero__ = __bool__
|
||||
|
@ -448,6 +448,12 @@ class Program(object):
|
||||
i = i + 1
|
||||
self.assembly = assembly
|
||||
|
||||
def __bool__(self):
|
||||
return ((hasattr(self, 'assembly') and len(self.assembly) > 0) or
|
||||
(hasattr(self, 'bytecode') and len(self.bytecode) > 0))
|
||||
|
||||
__nonzero__ = __bool__
|
||||
|
||||
|
||||
def _test():
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user