-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdatalist_spec.py
50 lines (36 loc) · 1.6 KB
/
datalist_spec.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
from pkg_resources import parse_version
from kaitaistruct import __version__ as ks_version, KaitaiStruct, KaitaiStream, BytesIO
if parse_version(ks_version) < parse_version('0.7'):
raise Exception("Incompatible Kaitai Struct Python API: 0.7 or later is required, but you have %s" % (ks_version))
class DatalistSpec(KaitaiStruct):
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._read()
def _read(self):
self.dl_header = self._root.DatalistHeader(self._io, self, self._root)
self.entries = []
i = 0
while not self._io.is_eof():
self.entries.append(self._root.DatalistEntry(self._io, self, self._root))
i += 1
class DatalistHeader(KaitaiStruct):
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._read()
def _read(self):
self.version = self._io.read_u4le()
self.num_entries = self._io.read_u4le()
class DatalistEntry(KaitaiStruct):
def __init__(self, _io, _parent=None, _root=None):
self._io = _io
self._parent = _parent
self._root = _root if _root else self
self._read()
def _read(self):
self.data_size = self._io.read_u4le()
self.data = self._io.read_bytes(self.data_size)