Skip to content

Commit 8358183

Browse files
committed
feat: Add kaitai file for an RxTag record
1 parent b10b45b commit 8358183

File tree

4 files changed

+154
-18
lines changed

4 files changed

+154
-18
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ build
99
.idea
1010
dist
1111
/test/dump/
12+
/.mypy_cache/
13+
/acd_tools.egg-info/

acd/l5x/rx_tag.py

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
2+
3+
import kaitaistruct
4+
from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO
5+
6+
7+
if getattr(kaitaistruct, 'API_VERSION', (0, 9)) < (0, 9):
8+
raise Exception("Incompatible Kaitai Struct Python API: 0.9 or later is required, but you have %s" % (kaitaistruct.__version__))
9+
10+
class RxTag(KaitaiStruct):
11+
def __init__(self, _io, _parent=None, _root=None):
12+
self._io = _io
13+
self._parent = _parent
14+
self._root = _root if _root else self
15+
self._read()
16+
17+
def _read(self):
18+
self.header = RxTag.Header(self._io, self, self._root)
19+
self.parent_id = self._io.read_u4le()
20+
self.unique_tag_identifier = self._io.read_u4le()
21+
22+
class Header(KaitaiStruct):
23+
def __init__(self, _io, _parent=None, _root=None):
24+
self._io = _io
25+
self._parent = _parent
26+
self._root = _root if _root else self
27+
self._read()
28+
29+
def _read(self):
30+
self.length = self._io.read_u4le()
31+
self.blank_1 = self._io.read_u4le()
32+
self.seq_number = self._io.read_u2le()
33+
self.record_type = self._io.read_u2le()
34+
self.blank_2 = self._io.read_u4le()
35+
self.object_id = self._io.read_u4le()
36+
self.parent_id = self._io.read_u4le()
37+
self.name = (self._io.read_bytes(124)).decode(u"UTF-16")
38+
39+
40+
@property
41+
def tag_name_length(self):
42+
if hasattr(self, '_m_tag_name_length'):
43+
return self._m_tag_name_length
44+
45+
_pos = self._io.pos()
46+
self._io.seek(238)
47+
self._m_tag_name_length = self._io.read_u2le()
48+
self._io.seek(_pos)
49+
return getattr(self, '_m_tag_name_length', None)
50+
51+
@property
52+
def data_type_id(self):
53+
if hasattr(self, '_m_data_type_id'):
54+
return self._m_data_type_id
55+
56+
_pos = self._io.pos()
57+
self._io.seek(190)
58+
self._m_data_type_id = self._io.read_u4le()
59+
self._io.seek(_pos)
60+
return getattr(self, '_m_data_type_id', None)
61+
62+
@property
63+
def tag_name(self):
64+
if hasattr(self, '_m_tag_name'):
65+
return self._m_tag_name
66+
67+
_pos = self._io.pos()
68+
self._io.seek(240)
69+
self._m_tag_name = (self._io.read_bytes(self.tag_name_length)).decode(u"UTF-8")
70+
self._io.seek(_pos)
71+
return getattr(self, '_m_tag_name', None)
72+
73+
@property
74+
def second_array_dimension(self):
75+
if hasattr(self, '_m_second_array_dimension'):
76+
return self._m_second_array_dimension
77+
78+
_pos = self._io.pos()
79+
self._io.seek(178)
80+
self._m_second_array_dimension = self._io.read_u4le()
81+
self._io.seek(_pos)
82+
return getattr(self, '_m_second_array_dimension', None)
83+
84+
@property
85+
def first_array_dimension(self):
86+
if hasattr(self, '_m_first_array_dimension'):
87+
return self._m_first_array_dimension
88+
89+
_pos = self._io.pos()
90+
self._io.seek(174)
91+
self._m_first_array_dimension = self._io.read_u4le()
92+
self._io.seek(_pos)
93+
return getattr(self, '_m_first_array_dimension', None)
94+
95+
@property
96+
def third_array_dimension(self):
97+
if hasattr(self, '_m_third_array_dimension'):
98+
return self._m_third_array_dimension
99+
100+
_pos = self._io.pos()
101+
self._io.seek(182)
102+
self._m_third_array_dimension = self._io.read_u4le()
103+
self._io.seek(_pos)
104+
return getattr(self, '_m_third_array_dimension', None)
105+
106+

acd/templates/Comps/RxTag.ksy

Lines changed: 44 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,56 @@
11
meta:
2-
id: RxTag
2+
id: rx_tag
33
endian: le
44
tags:
55
- version: 60
6+
instances:
7+
first_array_dimension:
8+
pos: 0xAE
9+
type: u4
10+
second_array_dimension:
11+
pos: 0xB2
12+
type: u4
13+
third_array_dimension:
14+
pos: 0xB6
15+
type: u4
16+
data_type_id:
17+
pos: 0xBE
18+
type: u4
19+
tag_name_length:
20+
pos: 0xEE
21+
type: u2
22+
tag_name:
23+
pos: 0xF0
24+
type: str
25+
size: tag_name_length
26+
encoding: UTF-8
27+
628
seq:
729
- id: header
830
type: header
9-
- id: logical_screen
10-
type: logical_screen
31+
- id: parent_id
32+
type: u4
33+
- id: unique_tag_identifier
34+
type: u4
1135
types:
1236
header:
1337
seq:
14-
- id: magic
15-
contents: 'GIF'
16-
- id: version
17-
size: 3
18-
logical_screen:
19-
seq:
20-
- id: image_width
38+
- id: length
39+
type: u4
40+
- id: blank_1
41+
type: u4
42+
- id: seq_number
2143
type: u2
22-
- id: image_height
44+
- id: record_type
2345
type: u2
24-
- id: flags
25-
type: u1
26-
- id: bg_color_index
27-
type: u1
28-
- id: pixel_aspect_ratio
29-
type: u1
46+
- id: blank_2
47+
type: u4
48+
- id: object_id
49+
type: u4
50+
- id: parent_id
51+
type: u4
52+
- id: name
53+
type: str
54+
size: 124
55+
encoding: UTF-16
56+

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"wheel",
4646
],
4747
install_requires=[
48-
"loguru"
48+
"loguru",
49+
"kaitaistruct",
4950
],
5051
extras_require={
5152
"dev": [

0 commit comments

Comments
 (0)