DefaultTable.py revision 7ed91eca1eaa96b79eae780778e89bb9ec44c1ee
1from fontTools.misc.py23 import *
2
3class DefaultTable:
4
5	dependencies = []
6
7	def __init__(self, tag):
8		self.tableTag = tag
9
10	def decompile(self, data, ttFont):
11		self.data = data
12
13	def compile(self, ttFont):
14		return self.data
15
16	def toXML(self, writer, ttFont):
17		if hasattr(self, "ERROR"):
18			writer.comment("An error occurred during the decompilation of this table")
19			writer.newline()
20			writer.comment(self.ERROR)
21			writer.newline()
22		writer.begintag("hexdata")
23		writer.newline()
24		writer.dumphex(self.compile(ttFont))
25		writer.endtag("hexdata")
26		writer.newline()
27
28	def fromXML(self, name, attrs, content, ttFont):
29		from fontTools.misc.textTools import readHex
30		from fontTools import ttLib
31		if name != "hexdata":
32			raise ttLib.TTLibError("can't handle '%s' element" % name)
33		self.decompile(readHex(content), ttFont)
34
35	def __repr__(self):
36		return "<'%s' table at %x>" % (self.tableTag, id(self))
37
38	def __cmp__(self, other):
39		if not isinstance(self, type(other)): return cmp(type(self), type(other))
40		if self.__class__ != other.__class__: return cmp(self.__class__, other.__class__)
41
42		return cmp(self.__dict__, other.__dict__)
43
44