1 __all__ = ('INT', 'UINT', 'FLOAT', 'STRING', 'UNICODE', 'DATE', 'BINARY', 'CONTAINER', 'Element', 'EBML')
4 INT, UINT, FLOAT, STRING, UNICODE, DATE, BINARY, CONTAINER = range(0, 8)
16 class EBMLElement(Element):
23 class EBMLVersionElement(Element):
25 class_name = 'EBMLVersion'
26 class_parents = (EBMLElement,)
30 class EBMLReadVersionElement(Element):
32 class_name = 'EBMLReadVersion'
33 class_parents = (EBMLElement,)
37 class EBMLMaxIDLengthElement(Element):
39 class_name = 'EBMLMaxIDLength'
40 class_parents = (EBMLElement,)
44 class EBMLMaxSizeLengthElement(Element):
46 class_name = 'EBMLMaxSizeLength'
47 class_parents = (EBMLElement,)
51 class DocTypeElement(Element):
53 class_name = 'DocType'
54 class_parents = (EBMLElement,)
58 class DocTypeVersionElement(Element):
60 class_name = 'DocTypeVersion'
61 class_parents = (EBMLElement,)
65 class DocTypeReadVersionElement(Element):
67 class_name = 'DocTypeReadVersion'
68 class_parents = (EBMLElement,)
72 class CRC32Element(Element):
79 class VoidElement(Element):
86 class SignatureSlotElement(Element):
88 class_name = 'SignatureSlot'
93 class SignatureAlgoElement(Element):
95 class_name = 'SignatureAlgo'
96 class_parents = (SignatureSlotElement,)
100 class SignatureHashElement(Element):
102 class_name = 'SignatureHash'
103 class_parents = (SignatureSlotElement,)
107 class SignaturePublicKeyElement(Element):
109 class_name = 'SignaturePublicKey'
110 class_parents = (SignatureSlotElement,)
114 class SignatureElement(Element):
116 class_name = 'Signature'
117 class_parents = (SignatureSlotElement,)
121 class SignatureElementsElement(Element):
123 class_name = 'SignatureElements'
124 class_parents = (SignatureSlotElement,)
125 data_type = CONTAINER
128 class SignatureElementListElement(Element):
130 class_name = 'SignatureElementList'
131 class_parents = (SignatureElementsElement,)
132 data_type = CONTAINER
135 class SignedElementElement(Element):
137 class_name = 'SignedElement'
138 class_parents = (SignatureElementListElement,)
142 class Schema(object):
145 elements_by_class_id = None
148 def element_with_class_id(cls, class_id):
149 if cls.elements_by_class_id is None:
150 cls.elements_by_class_id = {}
151 for element in cls.elements:
152 cls.elements_by_class_id[element.class_id] = element
153 return cls.elements_by_class_id[class_id]
156 def global_elements(cls):
157 return [element for element in cls.elements if element.class_global]
160 def root_elements(cls):
161 return [element for element in cls.elements if element.class_root]
164 def child_elements_of_element(cls, parent):
165 children = [element for element in cls.elements if parent in element.class_parents]
166 children += cls.global_elements()
167 if 'self' in parent.class_parents and parent not in children:
168 children.append(parent)
176 EBMLReadVersionElement,
177 EBMLMaxIDLengthElement,
178 EBMLMaxSizeLengthElement,
180 DocTypeVersionElement,
181 DocTypeReadVersionElement,
184 SignatureSlotElement,
185 SignatureAlgoElement,
186 SignatureHashElement,
187 SignaturePublicKeyElement,
189 SignatureElementsElement,
190 SignatureElementListElement,