don't use __len__ for arbitrary length method

git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@287 4cde692c-a291-49d1-8350-778aa11640f8
This commit is contained in:
jvr 2002-07-23 08:19:38 +00:00
parent 1f8a4bb02a
commit 8e48312f88

View File

@ -142,16 +142,6 @@ class OTTableWriter:
else:
return cmp(id(self), id(other))
def __len__(self):
"""Return the length of this table in bytes, without subtables."""
l = 0
for item in self.items:
if hasattr(item, "getData") or hasattr(item, "getCountData"):
l = l + 2 # sizeof(UShort)
else:
l = l + len(item)
return l
def _doneWriting(self, internedTables=None):
if internedTables is None:
internedTables = {}
@ -190,7 +180,7 @@ class OTTableWriter:
pos = 0
for table in tables:
table.pos = pos
pos = pos + len(table)
pos = pos + table.getDataLength()
data = []
for table in tables:
@ -199,6 +189,16 @@ class OTTableWriter:
return "".join(data)
def getDataLength(self):
"""Return the length of this table in bytes, without subtables."""
l = 0
for item in self.items:
if hasattr(item, "getData") or hasattr(item, "getCountData"):
l = l + 2 # sizeof(UShort)
else:
l = l + len(item)
return l
def getData(self):
"""Return the data for this writer/table, without any subtables."""
items = list(self.items) # make a shallow copy