-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmemorywriter_sectoraddress.py
30 lines (21 loc) · 1.01 KB
/
memorywriter_sectoraddress.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
# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
import kaitaistruct
from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO
if getattr(kaitaistruct, 'API_VERSION', (0, 9)) < (0, 9):
raise Exception("Incompatible Kaitai Struct Python API: 0.9 or later is required, but you have %s" % (kaitaistruct.__version__))
class MemorywriterSectoraddress(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.track = self._io.read_u1()
self.sector = self._io.read_u1()
@property
def offset(self):
"""Offset in image corresponding to the sector address."""
if hasattr(self, '_m_offset'):
return self._m_offset
self._m_offset = (0 if self.sector == 0 else (256 * ((self.track * 16) + (self.sector - 1))))
return getattr(self, '_m_offset', None)