Merge pull request #303 from anthrotype/fix_program_len

[ttProgram] add missing __len__ method to Program class
This commit is contained in:
Cosimo Lupo 2015-06-25 20:06:05 +02:00
commit ca6e5c4f0a
2 changed files with 10 additions and 2 deletions

View File

@ -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__

View File

@ -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():
"""