From 31c2fd079fe54a56e1566e83bb760282358f87be Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Wed, 23 Jul 2025 21:06:11 -0700 Subject: [PATCH 01/15] Filtering for copyleft schemas --- compile_kaitai_parsers.py | 70 +- polyfile/kaitai/parsers/broadcom_trx.py | 290 ----- polyfile/kaitai/parsers/lvm2.py | 348 ------ polyfile/kaitai/parsers/manifest.json | 2 +- polyfile/kaitai/parsers/nt_mdt.py | 1311 ----------------------- polyfile/kaitai/parsers/pif.py | 233 ---- polyfile/kaitai/parsers/vdi.py | 463 -------- 7 files changed, 69 insertions(+), 2648 deletions(-) delete mode 100644 polyfile/kaitai/parsers/broadcom_trx.py delete mode 100644 polyfile/kaitai/parsers/lvm2.py delete mode 100644 polyfile/kaitai/parsers/nt_mdt.py delete mode 100644 polyfile/kaitai/parsers/pif.py delete mode 100644 polyfile/kaitai/parsers/vdi.py diff --git a/compile_kaitai_parsers.py b/compile_kaitai_parsers.py index 47a6b8e7..b3d9f329 100644 --- a/compile_kaitai_parsers.py +++ b/compile_kaitai_parsers.py @@ -6,6 +6,13 @@ import subprocess import sys from typing import Any, Dict, List, Optional, Tuple +import os +import glob +import yaml + +# Copyleft Licenses to exclude +EXCLUDE_LICENSES = ['AGPL', 'EUPL', 'GPL', 'LGPL', 'OSL', 'ODbL', 'Ms-RL', 'GFDL'] + POLYFILE_DIR: Path = Path(__file__).absolute().parent COMPILE_SCRIPT: Path = POLYFILE_DIR / "polyfile" / "kaitai" / "compiler.py" @@ -14,6 +21,46 @@ MANIFEST_PATH: Path = KAITAI_PARSERS_DIR / "manifest.json" +def find_files_with_excluded_licenses(directory, license_list) -> list[str]: + """ + Recursively scans a directory for files and identifies any that contain + a license from the excluded list. + + The check is performed as a substring match (e.g., 'GPL' in the list + will match a license named 'GPL-3.0-or-later'). + """ + # Create the recursive search pattern + search_path = os.path.join(directory, '**', f'*.ksy') + file_paths = glob.glob(search_path, recursive=True) + + if not file_paths: + return [] + + flagged_files = [] + + for file_path in file_paths: + try: + with open(file_path, 'r', encoding='utf-8') as f: + data = yaml.safe_load(f) + if data and isinstance(data, dict): + license_val = data.get('meta', {}).get('license') + if not license_val: + continue + + # Check if any part of the license name is in our exclude list + for excluded_license in license_list: + if excluded_license in license_val: + flagged_files.append(file_path) + break # Found a match, no need to check other excluded licenses for this file + + except yaml.YAMLError as e: + print(f"❌ Error parsing YAML in file '{file_path}': {e}") + except Exception as e: + print(f"❌ An unexpected error occurred with file '{file_path}': {e}") + + return flagged_files + + # Make sure the ktaitai_struct_formats submodlue is cloned: if not (KAITAI_FORMAT_LIBRARY / "README.md").exists(): subprocess.check_call(["git", "submodule", "init"], cwd=str(POLYFILE_DIR)) @@ -48,6 +95,14 @@ def mtime(path: Path) -> datetime: def rebuild(force: bool = False): + # Get the list of copyleft-licensed files to exclude + + excluded_files = find_files_with_excluded_licenses( + KAITAI_FORMAT_LIBRARY, + EXCLUDE_LICENSES + ) + excluded_paths = {Path(f).absolute() for f in excluded_files} + # Remove the manifest file to force a rebuild: if force or not MANIFEST_PATH.exists(): if MANIFEST_PATH.exists(): @@ -57,6 +112,9 @@ def rebuild(force: bool = False): # see if any of the files are out of date and need to be recompiled newest_definition: Optional[datetime] = None for definition in KAITAI_FORMAT_LIBRARY.glob("**/*.ksy"): + # Skip excluded files + if definition.absolute() in excluded_paths: + continue modtime = mtime(definition) if newest_definition is None or newest_definition < modtime: newest_definition = modtime @@ -71,7 +129,15 @@ def rebuild(force: bool = False): sys.stderr.write("Error: You must have kaitai-struct-compiler installed\nSee https://kaitai.io/#download\n") sys.exit(1) - num_files = sum(1 for _ in KAITAI_FORMAT_LIBRARY.glob("**/*.ksy")) + # Count non-excluded files + all_ksy_files = list(KAITAI_FORMAT_LIBRARY.glob("**/*.ksy")) + ksy_files_to_compile = [f for f in all_ksy_files if f.absolute() not in excluded_paths] + num_excluded = len(all_ksy_files) - len(ksy_files_to_compile) + + if num_excluded > 0: + print(f"Excluding {num_excluded} copyleft-licensed KSY files from compilation") + + num_files = len(ksy_files_to_compile) try: from tqdm import tqdm @@ -99,7 +165,7 @@ def update(self, n: int): with concurrent.futures.ThreadPoolExecutor(max_workers=cpu_count()) as executor: futures_to_path: Dict[concurrent.futures.Future, Path] = { executor.submit(compile_ksy, file): file - for file in KAITAI_FORMAT_LIBRARY.glob("**/*.ksy") + for file in ksy_files_to_compile } for future in concurrent.futures.as_completed(futures_to_path): t.update(1) diff --git a/polyfile/kaitai/parsers/broadcom_trx.py b/polyfile/kaitai/parsers/broadcom_trx.py deleted file mode 100644 index 69740fd8..00000000 --- a/polyfile/kaitai/parsers/broadcom_trx.py +++ /dev/null @@ -1,290 +0,0 @@ -# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild - -from pkg_resources import parse_version -import kaitaistruct -from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO -import collections - - -if parse_version(kaitaistruct.__version__) < parse_version('0.9'): - raise Exception("Incompatible Kaitai Struct Python API: 0.9 or later is required, but you have %s" % (kaitaistruct.__version__)) - -class BroadcomTrx(KaitaiStruct): - """.trx file format is widely used for distribution of firmware - updates for Broadcom devices. The most well-known are ASUS routers. - - Fundamentally, it includes a footer which acts as a safeguard - against installing a firmware package on a wrong hardware model or - version, and a header which list numerous partitions packaged inside - a single .trx file. - - trx files not necessarily contain all these headers. - - .. seealso:: - Source - https://github.com/openwrt/firmware-utils/blob/a2c80c5/src/trx.c - - - .. seealso:: - Source - https://web.archive.org/web/20190127154419/https://openwrt.org/docs/techref/header - - - .. seealso:: - Source - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt - """ - SEQ_FIELDS = [] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - pass - - class Revision(KaitaiStruct): - SEQ_FIELDS = ["major", "minor"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['major']['start'] = self._io.pos() - self.major = self._io.read_u1() - self._debug['major']['end'] = self._io.pos() - self._debug['minor']['start'] = self._io.pos() - self.minor = self._io.read_u1() - self._debug['minor']['end'] = self._io.pos() - - - class Version(KaitaiStruct): - SEQ_FIELDS = ["major", "minor", "patch", "tweak"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['major']['start'] = self._io.pos() - self.major = self._io.read_u1() - self._debug['major']['end'] = self._io.pos() - self._debug['minor']['start'] = self._io.pos() - self.minor = self._io.read_u1() - self._debug['minor']['end'] = self._io.pos() - self._debug['patch']['start'] = self._io.pos() - self.patch = self._io.read_u1() - self._debug['patch']['end'] = self._io.pos() - self._debug['tweak']['start'] = self._io.pos() - self.tweak = self._io.read_u1() - self._debug['tweak']['end'] = self._io.pos() - - - class Tail(KaitaiStruct): - """A safeguard against installation of firmware to an incompatible device.""" - SEQ_FIELDS = ["version", "product_id", "comp_hw", "reserved"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['version']['start'] = self._io.pos() - self.version = BroadcomTrx.Version(self._io, self, self._root) - self.version._read() - self._debug['version']['end'] = self._io.pos() - self._debug['product_id']['start'] = self._io.pos() - self.product_id = (KaitaiStream.bytes_terminate(self._io.read_bytes(12), 0, False)).decode(u"utf-8") - self._debug['product_id']['end'] = self._io.pos() - self._debug['comp_hw']['start'] = self._io.pos() - self.comp_hw = [None] * (4) - for i in range(4): - if not 'arr' in self._debug['comp_hw']: - self._debug['comp_hw']['arr'] = [] - self._debug['comp_hw']['arr'].append({'start': self._io.pos()}) - _t_comp_hw = BroadcomTrx.Tail.HwCompInfo(self._io, self, self._root) - _t_comp_hw._read() - self.comp_hw[i] = _t_comp_hw - self._debug['comp_hw']['arr'][i]['end'] = self._io.pos() - - self._debug['comp_hw']['end'] = self._io.pos() - self._debug['reserved']['start'] = self._io.pos() - self.reserved = self._io.read_bytes(32) - self._debug['reserved']['end'] = self._io.pos() - - class HwCompInfo(KaitaiStruct): - SEQ_FIELDS = ["min", "max"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['min']['start'] = self._io.pos() - self.min = BroadcomTrx.Revision(self._io, self, self._root) - self.min._read() - self._debug['min']['end'] = self._io.pos() - self._debug['max']['start'] = self._io.pos() - self.max = BroadcomTrx.Revision(self._io, self, self._root) - self.max._read() - self._debug['max']['end'] = self._io.pos() - - - - class Header(KaitaiStruct): - SEQ_FIELDS = ["magic", "len", "crc32", "version", "flags", "partitions"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['magic']['start'] = self._io.pos() - self.magic = self._io.read_bytes(4) - self._debug['magic']['end'] = self._io.pos() - if not self.magic == b"\x48\x44\x52\x30": - raise kaitaistruct.ValidationNotEqualError(b"\x48\x44\x52\x30", self.magic, self._io, u"/types/header/seq/0") - self._debug['len']['start'] = self._io.pos() - self.len = self._io.read_u4le() - self._debug['len']['end'] = self._io.pos() - self._debug['crc32']['start'] = self._io.pos() - self.crc32 = self._io.read_u4le() - self._debug['crc32']['end'] = self._io.pos() - self._debug['version']['start'] = self._io.pos() - self.version = self._io.read_u2le() - self._debug['version']['end'] = self._io.pos() - self._debug['flags']['start'] = self._io.pos() - self.flags = BroadcomTrx.Header.Flags(self._io, self, self._root) - self.flags._read() - self._debug['flags']['end'] = self._io.pos() - self._debug['partitions']['start'] = self._io.pos() - self.partitions = [] - i = 0 - while True: - if not 'arr' in self._debug['partitions']: - self._debug['partitions']['arr'] = [] - self._debug['partitions']['arr'].append({'start': self._io.pos()}) - _t_partitions = BroadcomTrx.Header.Partition(i, self._io, self, self._root) - _t_partitions._read() - _ = _t_partitions - self.partitions.append(_) - self._debug['partitions']['arr'][len(self.partitions) - 1]['end'] = self._io.pos() - if ((i >= 4) or (not (_.is_present))) : - break - i += 1 - self._debug['partitions']['end'] = self._io.pos() - - class Partition(KaitaiStruct): - SEQ_FIELDS = ["ofs_body"] - def __init__(self, idx, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self.idx = idx - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['ofs_body']['start'] = self._io.pos() - self.ofs_body = self._io.read_u4le() - self._debug['ofs_body']['end'] = self._io.pos() - - @property - def is_present(self): - if hasattr(self, '_m_is_present'): - return self._m_is_present if hasattr(self, '_m_is_present') else None - - self._m_is_present = self.ofs_body != 0 - return self._m_is_present if hasattr(self, '_m_is_present') else None - - @property - def is_last(self): - if hasattr(self, '_m_is_last'): - return self._m_is_last if hasattr(self, '_m_is_last') else None - - if self.is_present: - self._m_is_last = ((self.idx == (len(self._parent.partitions) - 1)) or (not (self._parent.partitions[(self.idx + 1)].is_present))) - - return self._m_is_last if hasattr(self, '_m_is_last') else None - - @property - def len_body(self): - if hasattr(self, '_m_len_body'): - return self._m_len_body if hasattr(self, '_m_len_body') else None - - if self.is_present: - self._m_len_body = ((self._root._io.size() - self.ofs_body) if self.is_last else self._parent.partitions[(self.idx + 1)].ofs_body) - - return self._m_len_body if hasattr(self, '_m_len_body') else None - - @property - def body(self): - if hasattr(self, '_m_body'): - return self._m_body if hasattr(self, '_m_body') else None - - if self.is_present: - io = self._root._io - _pos = io.pos() - io.seek(self.ofs_body) - self._debug['_m_body']['start'] = io.pos() - self._m_body = io.read_bytes(self.len_body) - self._debug['_m_body']['end'] = io.pos() - io.seek(_pos) - - return self._m_body if hasattr(self, '_m_body') else None - - - class Flags(KaitaiStruct): - SEQ_FIELDS = ["flags"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['flags']['start'] = self._io.pos() - self.flags = [None] * (16) - for i in range(16): - if not 'arr' in self._debug['flags']: - self._debug['flags']['arr'] = [] - self._debug['flags']['arr'].append({'start': self._io.pos()}) - self.flags[i] = self._io.read_bits_int_le(1) != 0 - self._debug['flags']['arr'][i]['end'] = self._io.pos() - - self._debug['flags']['end'] = self._io.pos() - - - - @property - def header(self): - if hasattr(self, '_m_header'): - return self._m_header if hasattr(self, '_m_header') else None - - _pos = self._io.pos() - self._io.seek(0) - self._debug['_m_header']['start'] = self._io.pos() - self._m_header = BroadcomTrx.Header(self._io, self, self._root) - self._m_header._read() - self._debug['_m_header']['end'] = self._io.pos() - self._io.seek(_pos) - return self._m_header if hasattr(self, '_m_header') else None - - @property - def tail(self): - if hasattr(self, '_m_tail'): - return self._m_tail if hasattr(self, '_m_tail') else None - - _pos = self._io.pos() - self._io.seek((self._io.size() - 64)) - self._debug['_m_tail']['start'] = self._io.pos() - self._m_tail = BroadcomTrx.Tail(self._io, self, self._root) - self._m_tail._read() - self._debug['_m_tail']['end'] = self._io.pos() - self._io.seek(_pos) - return self._m_tail if hasattr(self, '_m_tail') else None - - diff --git a/polyfile/kaitai/parsers/lvm2.py b/polyfile/kaitai/parsers/lvm2.py deleted file mode 100644 index 88739c22..00000000 --- a/polyfile/kaitai/parsers/lvm2.py +++ /dev/null @@ -1,348 +0,0 @@ -# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild - -from pkg_resources import parse_version -import kaitaistruct -from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO -import collections -from enum import Enum - - -if parse_version(kaitaistruct.__version__) < parse_version('0.9'): - raise Exception("Incompatible Kaitai Struct Python API: 0.9 or later is required, but you have %s" % (kaitaistruct.__version__)) - -class Lvm2(KaitaiStruct): - """### Building a test file - - ``` - dd if=/dev/zero of=image.img bs=512 count=$(( 4 * 1024 * 2 )) - sudo losetup /dev/loop1 image.img - sudo pvcreate /dev/loop1 - sudo vgcreate vg_test /dev/loop1 - sudo lvcreate --name lv_test1 vg_test - sudo losetup -d /dev/loop1 - ``` - - .. seealso:: - Source - https://github.com/libyal/libvslvm/blob/main/documentation/Logical%20Volume%20Manager%20(LVM)%20format.asciidoc - """ - SEQ_FIELDS = ["pv"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['pv']['start'] = self._io.pos() - self.pv = Lvm2.PhysicalVolume(self._io, self, self._root) - self.pv._read() - self._debug['pv']['end'] = self._io.pos() - - class PhysicalVolume(KaitaiStruct): - SEQ_FIELDS = ["empty_sector", "label"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['empty_sector']['start'] = self._io.pos() - self.empty_sector = self._io.read_bytes(self._root.sector_size) - self._debug['empty_sector']['end'] = self._io.pos() - self._debug['label']['start'] = self._io.pos() - self.label = Lvm2.PhysicalVolume.Label(self._io, self, self._root) - self.label._read() - self._debug['label']['end'] = self._io.pos() - - class Label(KaitaiStruct): - SEQ_FIELDS = ["label_header", "volume_header"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['label_header']['start'] = self._io.pos() - self.label_header = Lvm2.PhysicalVolume.Label.LabelHeader(self._io, self, self._root) - self.label_header._read() - self._debug['label_header']['end'] = self._io.pos() - self._debug['volume_header']['start'] = self._io.pos() - self.volume_header = Lvm2.PhysicalVolume.Label.VolumeHeader(self._io, self, self._root) - self.volume_header._read() - self._debug['volume_header']['end'] = self._io.pos() - - class LabelHeader(KaitaiStruct): - SEQ_FIELDS = ["signature", "sector_number", "checksum", "label_header_"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['signature']['start'] = self._io.pos() - self.signature = self._io.read_bytes(8) - self._debug['signature']['end'] = self._io.pos() - if not self.signature == b"\x4C\x41\x42\x45\x4C\x4F\x4E\x45": - raise kaitaistruct.ValidationNotEqualError(b"\x4C\x41\x42\x45\x4C\x4F\x4E\x45", self.signature, self._io, u"/types/physical_volume/types/label/types/label_header/seq/0") - self._debug['sector_number']['start'] = self._io.pos() - self.sector_number = self._io.read_u8le() - self._debug['sector_number']['end'] = self._io.pos() - self._debug['checksum']['start'] = self._io.pos() - self.checksum = self._io.read_u4le() - self._debug['checksum']['end'] = self._io.pos() - self._debug['label_header_']['start'] = self._io.pos() - self.label_header_ = Lvm2.PhysicalVolume.Label.LabelHeader.LabelHeader(self._io, self, self._root) - self.label_header_._read() - self._debug['label_header_']['end'] = self._io.pos() - - class LabelHeader(KaitaiStruct): - SEQ_FIELDS = ["data_offset", "type_indicator"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['data_offset']['start'] = self._io.pos() - self.data_offset = self._io.read_u4le() - self._debug['data_offset']['end'] = self._io.pos() - self._debug['type_indicator']['start'] = self._io.pos() - self.type_indicator = self._io.read_bytes(8) - self._debug['type_indicator']['end'] = self._io.pos() - if not self.type_indicator == b"\x4C\x56\x4D\x32\x20\x30\x30\x31": - raise kaitaistruct.ValidationNotEqualError(b"\x4C\x56\x4D\x32\x20\x30\x30\x31", self.type_indicator, self._io, u"/types/physical_volume/types/label/types/label_header/types/label_header_/seq/1") - - - - class VolumeHeader(KaitaiStruct): - SEQ_FIELDS = ["id", "size", "data_area_descriptors", "metadata_area_descriptors"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['id']['start'] = self._io.pos() - self.id = (self._io.read_bytes(32)).decode(u"ascii") - self._debug['id']['end'] = self._io.pos() - self._debug['size']['start'] = self._io.pos() - self.size = self._io.read_u8le() - self._debug['size']['end'] = self._io.pos() - self._debug['data_area_descriptors']['start'] = self._io.pos() - self.data_area_descriptors = [] - i = 0 - while True: - if not 'arr' in self._debug['data_area_descriptors']: - self._debug['data_area_descriptors']['arr'] = [] - self._debug['data_area_descriptors']['arr'].append({'start': self._io.pos()}) - _t_data_area_descriptors = Lvm2.PhysicalVolume.Label.VolumeHeader.DataAreaDescriptor(self._io, self, self._root) - _t_data_area_descriptors._read() - _ = _t_data_area_descriptors - self.data_area_descriptors.append(_) - self._debug['data_area_descriptors']['arr'][len(self.data_area_descriptors) - 1]['end'] = self._io.pos() - if ((_.size != 0) and (_.offset != 0)) : - break - i += 1 - self._debug['data_area_descriptors']['end'] = self._io.pos() - self._debug['metadata_area_descriptors']['start'] = self._io.pos() - self.metadata_area_descriptors = [] - i = 0 - while True: - if not 'arr' in self._debug['metadata_area_descriptors']: - self._debug['metadata_area_descriptors']['arr'] = [] - self._debug['metadata_area_descriptors']['arr'].append({'start': self._io.pos()}) - _t_metadata_area_descriptors = Lvm2.PhysicalVolume.Label.VolumeHeader.MetadataAreaDescriptor(self._io, self, self._root) - _t_metadata_area_descriptors._read() - _ = _t_metadata_area_descriptors - self.metadata_area_descriptors.append(_) - self._debug['metadata_area_descriptors']['arr'][len(self.metadata_area_descriptors) - 1]['end'] = self._io.pos() - if ((_.size != 0) and (_.offset != 0)) : - break - i += 1 - self._debug['metadata_area_descriptors']['end'] = self._io.pos() - - class DataAreaDescriptor(KaitaiStruct): - SEQ_FIELDS = ["offset", "size"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['offset']['start'] = self._io.pos() - self.offset = self._io.read_u8le() - self._debug['offset']['end'] = self._io.pos() - self._debug['size']['start'] = self._io.pos() - self.size = self._io.read_u8le() - self._debug['size']['end'] = self._io.pos() - - @property - def data(self): - if hasattr(self, '_m_data'): - return self._m_data if hasattr(self, '_m_data') else None - - if self.size != 0: - _pos = self._io.pos() - self._io.seek(self.offset) - self._debug['_m_data']['start'] = self._io.pos() - self._m_data = (self._io.read_bytes(self.size)).decode(u"ascii") - self._debug['_m_data']['end'] = self._io.pos() - self._io.seek(_pos) - - return self._m_data if hasattr(self, '_m_data') else None - - - class MetadataAreaDescriptor(KaitaiStruct): - SEQ_FIELDS = ["offset", "size"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['offset']['start'] = self._io.pos() - self.offset = self._io.read_u8le() - self._debug['offset']['end'] = self._io.pos() - self._debug['size']['start'] = self._io.pos() - self.size = self._io.read_u8le() - self._debug['size']['end'] = self._io.pos() - - @property - def data(self): - if hasattr(self, '_m_data'): - return self._m_data if hasattr(self, '_m_data') else None - - if self.size != 0: - _pos = self._io.pos() - self._io.seek(self.offset) - self._debug['_m_data']['start'] = self._io.pos() - self._raw__m_data = self._io.read_bytes(self.size) - _io__raw__m_data = KaitaiStream(BytesIO(self._raw__m_data)) - self._m_data = Lvm2.PhysicalVolume.Label.VolumeHeader.MetadataArea(_io__raw__m_data, self, self._root) - self._m_data._read() - self._debug['_m_data']['end'] = self._io.pos() - self._io.seek(_pos) - - return self._m_data if hasattr(self, '_m_data') else None - - - class MetadataArea(KaitaiStruct): - """According to `[REDHAT]` the metadata area is a circular buffer. New metadata is appended to the old metadata and then the pointer to the start of it is updated. The metadata area, therefore, can contain copies of older versions of the metadata.""" - SEQ_FIELDS = ["header"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['header']['start'] = self._io.pos() - self.header = Lvm2.PhysicalVolume.Label.VolumeHeader.MetadataArea.MetadataAreaHeader(self._io, self, self._root) - self.header._read() - self._debug['header']['end'] = self._io.pos() - - class MetadataAreaHeader(KaitaiStruct): - SEQ_FIELDS = ["checksum", "signature", "version", "metadata_area_offset", "metadata_area_size", "raw_location_descriptors"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['checksum']['start'] = self._io.pos() - self.checksum = Lvm2.PhysicalVolume.Label.VolumeHeader.MetadataArea.MetadataAreaHeader(self._io, self, self._root) - self.checksum._read() - self._debug['checksum']['end'] = self._io.pos() - self._debug['signature']['start'] = self._io.pos() - self.signature = self._io.read_bytes(16) - self._debug['signature']['end'] = self._io.pos() - if not self.signature == b"\x20\x4C\x56\x4D\x32\x20\x78\x5B\x35\x41\x25\x72\x30\x4E\x2A\x3E": - raise kaitaistruct.ValidationNotEqualError(b"\x20\x4C\x56\x4D\x32\x20\x78\x5B\x35\x41\x25\x72\x30\x4E\x2A\x3E", self.signature, self._io, u"/types/physical_volume/types/label/types/volume_header/types/metadata_area/types/metadata_area_header/seq/1") - self._debug['version']['start'] = self._io.pos() - self.version = self._io.read_u4le() - self._debug['version']['end'] = self._io.pos() - self._debug['metadata_area_offset']['start'] = self._io.pos() - self.metadata_area_offset = self._io.read_u8le() - self._debug['metadata_area_offset']['end'] = self._io.pos() - self._debug['metadata_area_size']['start'] = self._io.pos() - self.metadata_area_size = self._io.read_u8le() - self._debug['metadata_area_size']['end'] = self._io.pos() - self._debug['raw_location_descriptors']['start'] = self._io.pos() - self.raw_location_descriptors = [] - i = 0 - while True: - if not 'arr' in self._debug['raw_location_descriptors']: - self._debug['raw_location_descriptors']['arr'] = [] - self._debug['raw_location_descriptors']['arr'].append({'start': self._io.pos()}) - _t_raw_location_descriptors = Lvm2.PhysicalVolume.Label.VolumeHeader.MetadataArea.MetadataAreaHeader.RawLocationDescriptor(self._io, self, self._root) - _t_raw_location_descriptors._read() - _ = _t_raw_location_descriptors - self.raw_location_descriptors.append(_) - self._debug['raw_location_descriptors']['arr'][len(self.raw_location_descriptors) - 1]['end'] = self._io.pos() - if ((_.offset != 0) and (_.size != 0) and (_.checksum != 0)) : - break - i += 1 - self._debug['raw_location_descriptors']['end'] = self._io.pos() - - class RawLocationDescriptor(KaitaiStruct): - """The data area size can be 0. It is assumed it represents the remaining available data.""" - - class RawLocationDescriptorFlags(Enum): - raw_location_ignored = 1 - SEQ_FIELDS = ["offset", "size", "checksum", "flags"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['offset']['start'] = self._io.pos() - self.offset = self._io.read_u8le() - self._debug['offset']['end'] = self._io.pos() - self._debug['size']['start'] = self._io.pos() - self.size = self._io.read_u8le() - self._debug['size']['end'] = self._io.pos() - self._debug['checksum']['start'] = self._io.pos() - self.checksum = self._io.read_u4le() - self._debug['checksum']['end'] = self._io.pos() - self._debug['flags']['start'] = self._io.pos() - self.flags = KaitaiStream.resolve_enum(Lvm2.PhysicalVolume.Label.VolumeHeader.MetadataArea.MetadataAreaHeader.RawLocationDescriptor.RawLocationDescriptorFlags, self._io.read_u4le()) - self._debug['flags']['end'] = self._io.pos() - - - @property - def metadata(self): - if hasattr(self, '_m_metadata'): - return self._m_metadata if hasattr(self, '_m_metadata') else None - - _pos = self._io.pos() - self._io.seek(self.metadata_area_offset) - self._debug['_m_metadata']['start'] = self._io.pos() - self._m_metadata = self._io.read_bytes(self.metadata_area_size) - self._debug['_m_metadata']['end'] = self._io.pos() - self._io.seek(_pos) - return self._m_metadata if hasattr(self, '_m_metadata') else None - - - - - - - @property - def sector_size(self): - if hasattr(self, '_m_sector_size'): - return self._m_sector_size if hasattr(self, '_m_sector_size') else None - - self._m_sector_size = 512 - return self._m_sector_size if hasattr(self, '_m_sector_size') else None - - diff --git a/polyfile/kaitai/parsers/manifest.json b/polyfile/kaitai/parsers/manifest.json index bfb504ef..3f001b85 100644 --- a/polyfile/kaitai/parsers/manifest.json +++ b/polyfile/kaitai/parsers/manifest.json @@ -1 +1 @@ -{"3d/gltf_binary.ksy": {"class_name": "GltfBinary", "python_path": "gltf_binary.py", "dependencies": []}, "executable/android_nanoapp_header.ksy": {"class_name": "AndroidNanoappHeader", "python_path": "android_nanoapp_header.py", "dependencies": []}, "executable/uefi_te.ksy": {"class_name": "UefiTe", "python_path": "uefi_te.py", "dependencies": []}, "database/tsm.ksy": {"class_name": "Tsm", "python_path": "tsm.py", "dependencies": []}, "database/dbf.ksy": {"class_name": "Dbf", "python_path": "dbf.py", "dependencies": []}, "database/gettext_mo.ksy": {"class_name": "GettextMo", "python_path": "gettext_mo.py", "dependencies": []}, "executable/python_pyc_27.ksy": {"class_name": "PythonPyc27", "python_path": "python_pyc_27.py", "dependencies": []}, "executable/dos_mz.ksy": {"class_name": "DosMz", "python_path": "dos_mz.py", "dependencies": []}, "executable/swf.ksy": {"class_name": "Swf", "python_path": "swf.py", "dependencies": []}, "executable/microsoft_pe.ksy": {"class_name": "MicrosoftPe", "python_path": "microsoft_pe.py", "dependencies": []}, "database/sqlite3.ksy": {"class_name": "Sqlite3", "python_path": "sqlite3.py", "dependencies": [{"class_name": "VlqBase128Be", "python_path": "vlq_base128_be.py"}]}, "executable/dex.ksy": {"class_name": "Dex", "python_path": "dex.py", "dependencies": [{"class_name": "VlqBase128Le", "python_path": "vlq_base128_le.py"}]}, "executable/java_class.ksy": {"class_name": "JavaClass", "python_path": "java_class.py", "dependencies": []}, "executable/elf.ksy": {"class_name": "Elf", "python_path": "elf.py", "dependencies": []}, "executable/mach_o_fat.ksy": {"class_name": "MachOFat", "python_path": "mach_o_fat.py", "dependencies": [{"class_name": "MachO", "python_path": "mach_o.py"}, {"class_name": "Asn1Der", "python_path": "asn1_der.py"}]}, "executable/mach_o.ksy": {"class_name": "MachO", "python_path": "mach_o.py", "dependencies": [{"class_name": "Asn1Der", "python_path": "asn1_der.py"}]}, "firmware/andes_firmware.ksy": {"class_name": "AndesFirmware", "python_path": "andes_firmware.py", "dependencies": []}, "firmware/uimage.ksy": {"class_name": "Uimage", "python_path": "uimage.py", "dependencies": []}, "firmware/ines.ksy": {"class_name": "Ines", "python_path": "ines.py", "dependencies": []}, "firmware/broadcom_trx.ksy": {"class_name": "BroadcomTrx", "python_path": "broadcom_trx.py", "dependencies": []}, "hardware/dtb.ksy": {"class_name": "Dtb", "python_path": "dtb.py", "dependencies": []}, "hardware/mifare/mifare_classic.ksy": {"class_name": "MifareClassic", "python_path": "mifare_classic.py", "dependencies": []}, "macos/resource_fork.ksy": {"class_name": "ResourceFork", "python_path": "resource_fork.py", "dependencies": [{"class_name": "BytesWithIo", "python_path": "bytes_with_io.py"}]}, "macos/resource_compression/dcmp_variable_length_integer.ksy": {"class_name": "DcmpVariableLengthInteger", "python_path": "dcmp_variable_length_integer.py", "dependencies": []}, "macos/ds_store.ksy": {"class_name": "DsStore", "python_path": "ds_store.py", "dependencies": []}, "hardware/edid.ksy": {"class_name": "Edid", "python_path": "edid.py", "dependencies": []}, "macos/compressed_resource.ksy": {"class_name": "CompressedResource", "python_path": "compressed_resource.py", "dependencies": [{"class_name": "BytesWithIo", "python_path": "bytes_with_io.py"}]}, "macos/mac_os_resource_snd.ksy": {"class_name": "MacOsResourceSnd", "python_path": "mac_os_resource_snd.py", "dependencies": []}, "macos/resource_compression/dcmp_1.ksy": {"class_name": "Dcmp1", "python_path": "dcmp_1.py", "dependencies": [{"class_name": "DcmpVariableLengthInteger", "python_path": "dcmp_variable_length_integer.py"}]}, "macos/resource_compression/dcmp_0.ksy": {"class_name": "Dcmp0", "python_path": "dcmp_0.py", "dependencies": [{"class_name": "DcmpVariableLengthInteger", "python_path": "dcmp_variable_length_integer.py"}]}, "archive/respack.ksy": {"class_name": "Respack", "python_path": "respack.py", "dependencies": []}, "macos/resource_compression/dcmp_2.ksy": {"class_name": "Dcmp2", "python_path": "dcmp_2.py", "dependencies": [{"class_name": "BytesWithIo", "python_path": "bytes_with_io.py"}]}, "archive/zisofs.ksy": {"class_name": "Zisofs", "python_path": "zisofs.py", "dependencies": []}, "archive/mozilla_mar.ksy": {"class_name": "MozillaMar", "python_path": "mozilla_mar.py", "dependencies": []}, "archive/rar.ksy": {"class_name": "Rar", "python_path": "rar.py", "dependencies": [{"class_name": "DosDatetime", "python_path": "dos_datetime.py"}]}, "archive/lzh.ksy": {"class_name": "Lzh", "python_path": "lzh.py", "dependencies": [{"class_name": "DosDatetime", "python_path": "dos_datetime.py"}]}, "archive/cpio_old_le.ksy": {"class_name": "CpioOldLe", "python_path": "cpio_old_le.py", "dependencies": []}, "archive/android_bootldr_asus.ksy": {"class_name": "AndroidBootldrAsus", "python_path": "android_bootldr_asus.py", "dependencies": []}, "archive/android_dto.ksy": {"class_name": "AndroidDto", "python_path": "android_dto.py", "dependencies": []}, "archive/android_bootldr_qcom.ksy": {"class_name": "AndroidBootldrQcom", "python_path": "android_bootldr_qcom.py", "dependencies": []}, "archive/android_sparse.ksy": {"class_name": "AndroidSparse", "python_path": "android_sparse.py", "dependencies": []}, "archive/zip.ksy": {"class_name": "Zip", "python_path": "zip.py", "dependencies": [{"class_name": "DosDatetime", "python_path": "dos_datetime.py"}]}, "archive/rpm.ksy": {"class_name": "Rpm", "python_path": "rpm.py", "dependencies": []}, "archive/android_img.ksy": {"class_name": "AndroidImg", "python_path": "android_img.py", "dependencies": []}, "archive/phar_without_stub.ksy": {"class_name": "PharWithoutStub", "python_path": "phar_without_stub.py", "dependencies": [{"class_name": "PhpSerializedValue", "python_path": "php_serialized_value.py"}]}, "archive/gzip.ksy": {"class_name": "Gzip", "python_path": "gzip.py", "dependencies": []}, "archive/android_bootldr_huawei.ksy": {"class_name": "AndroidBootldrHuawei", "python_path": "android_bootldr_huawei.py", "dependencies": []}, "archive/xar.ksy": {"class_name": "Xar", "python_path": "xar.py", "dependencies": []}, "security/efivar_signature_list.ksy": {"class_name": "EfivarSignatureList", "python_path": "efivar_signature_list.py", "dependencies": []}, "security/ssh_public_key.ksy": {"class_name": "SshPublicKey", "python_path": "ssh_public_key.py", "dependencies": []}, "serialization/google_protobuf.ksy": {"class_name": "GoogleProtobuf", "python_path": "google_protobuf.py", "dependencies": [{"class_name": "VlqBase128Le", "python_path": "vlq_base128_le.py"}]}, "serialization/bson.ksy": {"class_name": "Bson", "python_path": "bson.py", "dependencies": []}, "security/openpgp_message.ksy": {"class_name": "OpenpgpMessage", "python_path": "openpgp_message.py", "dependencies": []}, "serialization/microsoft_cfb.ksy": {"class_name": "MicrosoftCfb", "python_path": "microsoft_cfb.py", "dependencies": []}, "serialization/python_pickle.ksy": {"class_name": "PythonPickle", "python_path": "python_pickle.py", "dependencies": []}, "serialization/php_serialized_value.ksy": {"class_name": "PhpSerializedValue", "python_path": "php_serialized_value.py", "dependencies": []}, "serialization/msgpack.ksy": {"class_name": "Msgpack", "python_path": "msgpack.py", "dependencies": []}, "serialization/ruby_marshal.ksy": {"class_name": "RubyMarshal", "python_path": "ruby_marshal.py", "dependencies": []}, "serialization/chrome_pak.ksy": {"class_name": "ChromePak", "python_path": "chrome_pak.py", "dependencies": []}, "serialization/asn1/asn1_der.ksy": {"class_name": "Asn1Der", "python_path": "asn1_der.py", "dependencies": []}, "machine_code/code_6502.ksy": {"class_name": "Code6502", "python_path": "code_6502.py", "dependencies": []}, "network/tls_client_hello.ksy": {"class_name": "TlsClientHello", "python_path": "tls_client_hello.py", "dependencies": []}, "network/dns_packet.ksy": {"class_name": "DnsPacket", "python_path": "dns_packet.py", "dependencies": []}, "network/ipv4_packet.ksy": {"class_name": "Ipv4Packet", "python_path": "ipv4_packet.py", "dependencies": [{"class_name": "TcpSegment", "python_path": "tcp_segment.py"}, {"class_name": "UdpDatagram", "python_path": "udp_datagram.py"}, {"class_name": "ProtocolBody", "python_path": "protocol_body.py"}, {"class_name": "IcmpPacket", "python_path": "icmp_packet.py"}, {"class_name": "Ipv6Packet", "python_path": "ipv6_packet.py"}]}, "network/rtpdump.ksy": {"class_name": "Rtpdump", "python_path": "rtpdump.py", "dependencies": [{"class_name": "RtpPacket", "python_path": "rtp_packet.py"}]}, "network/dime_message.ksy": {"class_name": "DimeMessage", "python_path": "dime_message.py", "dependencies": []}, "network/rtp_packet.ksy": {"class_name": "RtpPacket", "python_path": "rtp_packet.py", "dependencies": []}, "network/bitcoin_transaction.ksy": {"class_name": "BitcoinTransaction", "python_path": "bitcoin_transaction.py", "dependencies": []}, "network/websocket.ksy": {"class_name": "Websocket", "python_path": "websocket.py", "dependencies": []}, "network/tcp_segment.ksy": {"class_name": "TcpSegment", "python_path": "tcp_segment.py", "dependencies": []}, "network/udp_datagram.ksy": {"class_name": "UdpDatagram", "python_path": "udp_datagram.py", "dependencies": []}, "network/icmp_packet.ksy": {"class_name": "IcmpPacket", "python_path": "icmp_packet.py", "dependencies": []}, "network/ipv6_packet.ksy": {"class_name": "Ipv6Packet", "python_path": "ipv6_packet.py", "dependencies": [{"class_name": "TcpSegment", "python_path": "tcp_segment.py"}, {"class_name": "UdpDatagram", "python_path": "udp_datagram.py"}, {"class_name": "ProtocolBody", "python_path": "protocol_body.py"}, {"class_name": "Ipv4Packet", "python_path": "ipv4_packet.py"}, {"class_name": "IcmpPacket", "python_path": "icmp_packet.py"}]}, "network/ethernet_frame.ksy": {"class_name": "EthernetFrame", "python_path": "ethernet_frame.py", "dependencies": [{"class_name": "TcpSegment", "python_path": "tcp_segment.py"}, {"class_name": "UdpDatagram", "python_path": "udp_datagram.py"}, {"class_name": "ProtocolBody", "python_path": "protocol_body.py"}, {"class_name": "Ipv4Packet", "python_path": "ipv4_packet.py"}, {"class_name": "IcmpPacket", "python_path": "icmp_packet.py"}, {"class_name": "Ipv6Packet", "python_path": "ipv6_packet.py"}]}, "network/protocol_body.ksy": {"class_name": "ProtocolBody", "python_path": "protocol_body.py", "dependencies": [{"class_name": "TcpSegment", "python_path": "tcp_segment.py"}, {"class_name": "UdpDatagram", "python_path": "udp_datagram.py"}, {"class_name": "Ipv4Packet", "python_path": "ipv4_packet.py"}, {"class_name": "IcmpPacket", "python_path": "icmp_packet.py"}, {"class_name": "Ipv6Packet", "python_path": "ipv6_packet.py"}]}, "network/packet_ppi.ksy": {"class_name": "PacketPpi", "python_path": "packet_ppi.py", "dependencies": [{"class_name": "TcpSegment", "python_path": "tcp_segment.py"}, {"class_name": "UdpDatagram", "python_path": "udp_datagram.py"}, {"class_name": "ProtocolBody", "python_path": "protocol_body.py"}, {"class_name": "Ipv4Packet", "python_path": "ipv4_packet.py"}, {"class_name": "IcmpPacket", "python_path": "icmp_packet.py"}, {"class_name": "EthernetFrame", "python_path": "ethernet_frame.py"}, {"class_name": "Ipv6Packet", "python_path": "ipv6_packet.py"}]}, "network/hccap.ksy": {"class_name": "Hccap", "python_path": "hccap.py", "dependencies": []}, "network/rtcp_payload.ksy": {"class_name": "RtcpPayload", "python_path": "rtcp_payload.py", "dependencies": []}, "network/pcap.ksy": {"class_name": "Pcap", "python_path": "pcap.py", "dependencies": [{"class_name": "TcpSegment", "python_path": "tcp_segment.py"}, {"class_name": "PacketPpi", "python_path": "packet_ppi.py"}, {"class_name": "UdpDatagram", "python_path": "udp_datagram.py"}, {"class_name": "ProtocolBody", "python_path": "protocol_body.py"}, {"class_name": "Ipv4Packet", "python_path": "ipv4_packet.py"}, {"class_name": "IcmpPacket", "python_path": "icmp_packet.py"}, {"class_name": "EthernetFrame", "python_path": "ethernet_frame.py"}, {"class_name": "Ipv6Packet", "python_path": "ipv6_packet.py"}]}, "network/microsoft_network_monitor_v2.ksy": {"class_name": "MicrosoftNetworkMonitorV2", "python_path": "microsoft_network_monitor_v2.py", "dependencies": [{"class_name": "TcpSegment", "python_path": "tcp_segment.py"}, {"class_name": "UdpDatagram", "python_path": "udp_datagram.py"}, {"class_name": "ProtocolBody", "python_path": "protocol_body.py"}, {"class_name": "Ipv4Packet", "python_path": "ipv4_packet.py"}, {"class_name": "WindowsSystemtime", "python_path": "windows_systemtime.py"}, {"class_name": "IcmpPacket", "python_path": "icmp_packet.py"}, {"class_name": "EthernetFrame", "python_path": "ethernet_frame.py"}, {"class_name": "Ipv6Packet", "python_path": "ipv6_packet.py"}]}, "network/some_ip/some_ip_sd_entries.ksy": {"class_name": "SomeIpSdEntries", "python_path": "some_ip_sd_entries.py", "dependencies": []}, "network/hccapx.ksy": {"class_name": "Hccapx", "python_path": "hccapx.py", "dependencies": []}, "network/some_ip/some_ip_container.ksy": {"class_name": "SomeIpContainer", "python_path": "some_ip_container.py", "dependencies": [{"class_name": "SomeIp", "python_path": "some_ip.py"}, {"class_name": "SomeIpSdEntries", "python_path": "some_ip_sd_entries.py"}, {"class_name": "SomeIpSd", "python_path": "some_ip_sd.py"}, {"class_name": "SomeIpSdOptions", "python_path": "some_ip_sd_options.py"}]}, "filesystem/gpt_partition_table.ksy": {"class_name": "GptPartitionTable", "python_path": "gpt_partition_table.py", "dependencies": []}, "network/some_ip/some_ip_sd.ksy": {"class_name": "SomeIpSd", "python_path": "some_ip_sd.py", "dependencies": [{"class_name": "SomeIpSdOptions", "python_path": "some_ip_sd_options.py"}, {"class_name": "SomeIpSdEntries", "python_path": "some_ip_sd_entries.py"}]}, "network/some_ip/some_ip_sd_options.ksy": {"class_name": "SomeIpSdOptions", "python_path": "some_ip_sd_options.py", "dependencies": []}, "network/some_ip/some_ip.ksy": {"class_name": "SomeIp", "python_path": "some_ip.py", "dependencies": [{"class_name": "SomeIpSdOptions", "python_path": "some_ip_sd_options.py"}, {"class_name": "SomeIpSdEntries", "python_path": "some_ip_sd_entries.py"}, {"class_name": "SomeIpSd", "python_path": "some_ip_sd.py"}]}, "filesystem/iso9660.ksy": {"class_name": "Iso9660", "python_path": "iso9660.py", "dependencies": []}, "filesystem/apm_partition_table.ksy": {"class_name": "ApmPartitionTable", "python_path": "apm_partition_table.py", "dependencies": []}, "filesystem/vdi.ksy": {"class_name": "Vdi", "python_path": "vdi.py", "dependencies": []}, "filesystem/luks.ksy": {"class_name": "Luks", "python_path": "luks.py", "dependencies": []}, "filesystem/ext2.ksy": {"class_name": "Ext2", "python_path": "ext2.py", "dependencies": []}, "filesystem/tr_dos_image.ksy": {"class_name": "TrDosImage", "python_path": "tr_dos_image.py", "dependencies": []}, "filesystem/android_super.ksy": {"class_name": "AndroidSuper", "python_path": "android_super.py", "dependencies": []}, "filesystem/lvm2.ksy": {"class_name": "Lvm2", "python_path": "lvm2.py", "dependencies": []}, "filesystem/zx_spectrum_tap.ksy": {"class_name": "ZxSpectrumTap", "python_path": "zx_spectrum_tap.py", "dependencies": []}, "filesystem/apple_single_double.ksy": {"class_name": "AppleSingleDouble", "python_path": "apple_single_double.py", "dependencies": []}, "filesystem/btrfs_stream.ksy": {"class_name": "BtrfsStream", "python_path": "btrfs_stream.py", "dependencies": []}, "filesystem/mbr_partition_table.ksy": {"class_name": "MbrPartitionTable", "python_path": "mbr_partition_table.py", "dependencies": []}, "filesystem/cramfs.ksy": {"class_name": "Cramfs", "python_path": "cramfs.py", "dependencies": []}, "filesystem/vmware_vmdk.ksy": {"class_name": "VmwareVmdk", "python_path": "vmware_vmdk.py", "dependencies": []}, "game/fallout_dat.ksy": {"class_name": "FalloutDat", "python_path": "fallout_dat.py", "dependencies": []}, "game/saints_row_2_vpp_pc.ksy": {"class_name": "SaintsRow2VppPc", "python_path": "saints_row_2_vpp_pc.py", "dependencies": []}, "filesystem/vfat.ksy": {"class_name": "Vfat", "python_path": "vfat.py", "dependencies": [{"class_name": "DosDatetime", "python_path": "dos_datetime.py"}]}, "game/renderware_binary_stream.ksy": {"class_name": "RenderwareBinaryStream", "python_path": "renderware_binary_stream.py", "dependencies": []}, "game/fallout2_dat.ksy": {"class_name": "Fallout2Dat", "python_path": "fallout2_dat.py", "dependencies": []}, "game/gran_turismo_vol.ksy": {"class_name": "GranTurismoVol", "python_path": "gran_turismo_vol.py", "dependencies": []}, "game/ftl_dat.ksy": {"class_name": "FtlDat", "python_path": "ftl_dat.py", "dependencies": []}, "game/quake_pak.ksy": {"class_name": "QuakePak", "python_path": "quake_pak.py", "dependencies": []}, "game/heaps_pak.ksy": {"class_name": "HeapsPak", "python_path": "heaps_pak.py", "dependencies": []}, "game/minecraft_nbt.ksy": {"class_name": "MinecraftNbt", "python_path": "minecraft_nbt.py", "dependencies": []}, "game/dune_2_pak.ksy": {"class_name": "Dune2Pak", "python_path": "dune_2_pak.py", "dependencies": []}, "game/heroes_of_might_and_magic_bmp.ksy": {"class_name": "HeroesOfMightAndMagicBmp", "python_path": "heroes_of_might_and_magic_bmp.py", "dependencies": []}, "game/heroes_of_might_and_magic_agg.ksy": {"class_name": "HeroesOfMightAndMagicAgg", "python_path": "heroes_of_might_and_magic_agg.py", "dependencies": []}, "game/doom_wad.ksy": {"class_name": "DoomWad", "python_path": "doom_wad.py", "dependencies": []}, "game/warcraft_2_pud.ksy": {"class_name": "Warcraft2Pud", "python_path": "warcraft_2_pud.py", "dependencies": []}, "image/xwd.ksy": {"class_name": "Xwd", "python_path": "xwd.py", "dependencies": []}, "game/quake_mdl.ksy": {"class_name": "QuakeMdl", "python_path": "quake_mdl.py", "dependencies": []}, "image/pcx_dcx.ksy": {"class_name": "PcxDcx", "python_path": "pcx_dcx.py", "dependencies": [{"class_name": "Pcx", "python_path": "pcx.py"}]}, "game/allegro_dat.ksy": {"class_name": "AllegroDat", "python_path": "allegro_dat.py", "dependencies": []}, "image/psx_tim.ksy": {"class_name": "PsxTim", "python_path": "psx_tim.py", "dependencies": []}, "image/pcx.ksy": {"class_name": "Pcx", "python_path": "pcx.py", "dependencies": []}, "image/ico.ksy": {"class_name": "Ico", "python_path": "ico.py", "dependencies": []}, "image/gimp_brush.ksy": {"class_name": "GimpBrush", "python_path": "gimp_brush.py", "dependencies": []}, "image/wmf.ksy": {"class_name": "Wmf", "python_path": "wmf.py", "dependencies": []}, "image/gif.ksy": {"class_name": "Gif", "python_path": "gif.py", "dependencies": []}, "image/nitf.ksy": {"class_name": "Nitf", "python_path": "nitf.py", "dependencies": []}, "image/dicom.ksy": {"class_name": "Dicom", "python_path": "dicom.py", "dependencies": []}, "image/tga.ksy": {"class_name": "Tga", "python_path": "tga.py", "dependencies": []}, "image/bmp.ksy": {"class_name": "Bmp", "python_path": "bmp.py", "dependencies": []}, "image/pif.ksy": {"class_name": "Pif", "python_path": "pif.py", "dependencies": []}, "image/exif.ksy": {"class_name": "Exif", "python_path": "exif.py", "dependencies": []}, "common/vlq_base128_be.ksy": {"class_name": "VlqBase128Be", "python_path": "vlq_base128_be.py", "dependencies": []}, "common/utf8_string.ksy": {"class_name": "Utf8String", "python_path": "utf8_string.py", "dependencies": []}, "image/jpeg.ksy": {"class_name": "Jpeg", "python_path": "jpeg.py", "dependencies": [{"class_name": "Exif", "python_path": "exif.py"}]}, "image/png.ksy": {"class_name": "Png", "python_path": "png.py", "dependencies": []}, "common/riff.ksy": {"class_name": "Riff", "python_path": "riff.py", "dependencies": []}, "common/bcd.ksy": {"class_name": "Bcd", "python_path": "bcd.py", "dependencies": []}, "common/dos_datetime.ksy": {"class_name": "DosDatetime", "python_path": "dos_datetime.py", "dependencies": []}, "common/bytes_with_io.ksy": {"class_name": "BytesWithIo", "python_path": "bytes_with_io.py", "dependencies": []}, "common/vlq_base128_le.ksy": {"class_name": "VlqBase128Le", "python_path": "vlq_base128_le.py", "dependencies": []}, "cad/monomakh_sapr_chg.ksy": {"class_name": "MonomakhSaprChg", "python_path": "monomakh_sapr_chg.py", "dependencies": []}, "log/aix_utmp.ksy": {"class_name": "AixUtmp", "python_path": "aix_utmp.py", "dependencies": []}, "log/windows_evt_log.ksy": {"class_name": "WindowsEvtLog", "python_path": "windows_evt_log.py", "dependencies": []}, "log/sudoers_ts.ksy": {"class_name": "SudoersTs", "python_path": "sudoers_ts.py", "dependencies": []}, "log/hashcat_restore.ksy": {"class_name": "HashcatRestore", "python_path": "hashcat_restore.py", "dependencies": []}, "log/glibc_utmp.ksy": {"class_name": "GlibcUtmp", "python_path": "glibc_utmp.py", "dependencies": []}, "log/systemd_journal.ksy": {"class_name": "SystemdJournal", "python_path": "systemd_journal.py", "dependencies": []}, "font/pcf_font.ksy": {"class_name": "PcfFont", "python_path": "pcf_font.py", "dependencies": [{"class_name": "BytesWithIo", "python_path": "bytes_with_io.py"}]}, "windows/windows_shell_items.ksy": {"class_name": "WindowsShellItems", "python_path": "windows_shell_items.py", "dependencies": []}, "log/mcap.ksy": {"class_name": "Mcap", "python_path": "mcap.py", "dependencies": []}, "font/grub2_font.ksy": {"class_name": "Grub2Font", "python_path": "grub2_font.py", "dependencies": []}, "windows/windows_minidump.ksy": {"class_name": "WindowsMinidump", "python_path": "windows_minidump.py", "dependencies": []}, "font/ttf.ksy": {"class_name": "Ttf", "python_path": "ttf.py", "dependencies": []}, "windows/windows_resource_file.ksy": {"class_name": "WindowsResourceFile", "python_path": "windows_resource_file.py", "dependencies": []}, "windows/windows_systemtime.ksy": {"class_name": "WindowsSystemtime", "python_path": "windows_systemtime.py", "dependencies": []}, "windows/regf.ksy": {"class_name": "Regf", "python_path": "regf.py", "dependencies": []}, "geospatial/shapefile_index.ksy": {"class_name": "ShapefileIndex", "python_path": "shapefile_index.py", "dependencies": []}, "windows/windows_lnk_file.ksy": {"class_name": "WindowsLnkFile", "python_path": "windows_lnk_file.py", "dependencies": [{"class_name": "WindowsShellItems", "python_path": "windows_shell_items.py"}]}, "scientific/spectroscopy/avantes_roh60.ksy": {"class_name": "AvantesRoh60", "python_path": "avantes_roh60.py", "dependencies": []}, "geospatial/shapefile_main.ksy": {"class_name": "ShapefileMain", "python_path": "shapefile_main.py", "dependencies": []}, "scientific/nt_mdt/nt_mdt_pal.ksy": {"class_name": "NtMdtPal", "python_path": "nt_mdt_pal.py", "dependencies": []}, "scientific/spectroscopy/specpr.ksy": {"class_name": "Specpr", "python_path": "specpr.py", "dependencies": []}, "media/ogg.ksy": {"class_name": "Ogg", "python_path": "ogg.py", "dependencies": []}, "media/id3v2_4.ksy": {"class_name": "Id3v24", "python_path": "id3v2_4.py", "dependencies": []}, "media/id3v1_1.ksy": {"class_name": "Id3v11", "python_path": "id3v1_1.py", "dependencies": []}, "media/id3v2_3.ksy": {"class_name": "Id3v23", "python_path": "id3v2_3.py", "dependencies": []}, "scientific/nt_mdt/nt_mdt.ksy": {"class_name": "NtMdt", "python_path": "nt_mdt.py", "dependencies": []}, "media/au.ksy": {"class_name": "Au", "python_path": "au.py", "dependencies": []}, "media/magicavoxel_vox.ksy": {"class_name": "MagicavoxelVox", "python_path": "magicavoxel_vox.py", "dependencies": []}, "media/genmidi_op2.ksy": {"class_name": "GenmidiOp2", "python_path": "genmidi_op2.py", "dependencies": []}, "media/stl.ksy": {"class_name": "Stl", "python_path": "stl.py", "dependencies": []}, "media/wav.ksy": {"class_name": "Wav", "python_path": "wav.py", "dependencies": [{"class_name": "Riff", "python_path": "riff.py"}]}, "media/blender_blend.ksy": {"class_name": "BlenderBlend", "python_path": "blender_blend.py", "dependencies": []}, "media/avi.ksy": {"class_name": "Avi", "python_path": "avi.py", "dependencies": []}, "media/android_opengl_shaders_cache.ksy": {"class_name": "AndroidOpenglShadersCache", "python_path": "android_opengl_shaders_cache.py", "dependencies": []}, "media/vp8_ivf.ksy": {"class_name": "Vp8Ivf", "python_path": "vp8_ivf.py", "dependencies": []}, "media/creative_voice_file.ksy": {"class_name": "CreativeVoiceFile", "python_path": "creative_voice_file.py", "dependencies": []}, "media/standard_midi_file.ksy": {"class_name": "StandardMidiFile", "python_path": "standard_midi_file.py", "dependencies": [{"class_name": "VlqBase128Be", "python_path": "vlq_base128_be.py"}]}, "media/quicktime_mov.ksy": {"class_name": "QuicktimeMov", "python_path": "quicktime_mov.py", "dependencies": []}, "media/tracker_modules/s3m.ksy": {"class_name": "S3m", "python_path": "s3m.py", "dependencies": []}, "media/tracker_modules/fasttracker_xm_module.ksy": {"class_name": "FasttrackerXmModule", "python_path": "fasttracker_xm_module.py", "dependencies": []}} \ No newline at end of file +{"executable/android_nanoapp_header.ksy": {"class_name": "AndroidNanoappHeader", "python_path": "android_nanoapp_header.py", "dependencies": []}, "database/gettext_mo.ksy": {"class_name": "GettextMo", "python_path": "gettext_mo.py", "dependencies": []}, "executable/python_pyc_27.ksy": {"class_name": "PythonPyc27", "python_path": "python_pyc_27.py", "dependencies": []}, "executable/mach_o_fat.ksy": {"class_name": "MachOFat", "python_path": "mach_o_fat.py", "dependencies": [{"class_name": "MachO", "python_path": "mach_o.py"}, {"class_name": "Asn1Der", "python_path": "asn1_der.py"}]}, "database/dbf.ksy": {"class_name": "Dbf", "python_path": "dbf.py", "dependencies": []}, "executable/microsoft_pe.ksy": {"class_name": "MicrosoftPe", "python_path": "microsoft_pe.py", "dependencies": []}, "executable/uefi_te.ksy": {"class_name": "UefiTe", "python_path": "uefi_te.py", "dependencies": []}, "database/sqlite3.ksy": {"class_name": "Sqlite3", "python_path": "sqlite3.py", "dependencies": [{"class_name": "VlqBase128Be", "python_path": "vlq_base128_be.py"}]}, "database/tsm.ksy": {"class_name": "Tsm", "python_path": "tsm.py", "dependencies": []}, "executable/swf.ksy": {"class_name": "Swf", "python_path": "swf.py", "dependencies": []}, "3d/gltf_binary.ksy": {"class_name": "GltfBinary", "python_path": "gltf_binary.py", "dependencies": []}, "executable/java_class.ksy": {"class_name": "JavaClass", "python_path": "java_class.py", "dependencies": []}, "executable/dos_mz.ksy": {"class_name": "DosMz", "python_path": "dos_mz.py", "dependencies": []}, "executable/mach_o.ksy": {"class_name": "MachO", "python_path": "mach_o.py", "dependencies": [{"class_name": "Asn1Der", "python_path": "asn1_der.py"}]}, "executable/dex.ksy": {"class_name": "Dex", "python_path": "dex.py", "dependencies": [{"class_name": "VlqBase128Le", "python_path": "vlq_base128_le.py"}]}, "executable/elf.ksy": {"class_name": "Elf", "python_path": "elf.py", "dependencies": []}, "firmware/uimage.ksy": {"class_name": "Uimage", "python_path": "uimage.py", "dependencies": []}, "firmware/andes_firmware.ksy": {"class_name": "AndesFirmware", "python_path": "andes_firmware.py", "dependencies": []}, "hardware/dtb.ksy": {"class_name": "Dtb", "python_path": "dtb.py", "dependencies": []}, "macos/resource_fork.ksy": {"class_name": "ResourceFork", "python_path": "resource_fork.py", "dependencies": [{"class_name": "BytesWithIo", "python_path": "bytes_with_io.py"}]}, "macos/ds_store.ksy": {"class_name": "DsStore", "python_path": "ds_store.py", "dependencies": []}, "macos/mac_os_resource_snd.ksy": {"class_name": "MacOsResourceSnd", "python_path": "mac_os_resource_snd.py", "dependencies": []}, "hardware/edid.ksy": {"class_name": "Edid", "python_path": "edid.py", "dependencies": []}, "macos/compressed_resource.ksy": {"class_name": "CompressedResource", "python_path": "compressed_resource.py", "dependencies": [{"class_name": "BytesWithIo", "python_path": "bytes_with_io.py"}]}, "firmware/ines.ksy": {"class_name": "Ines", "python_path": "ines.py", "dependencies": []}, "archive/respack.ksy": {"class_name": "Respack", "python_path": "respack.py", "dependencies": []}, "archive/mozilla_mar.ksy": {"class_name": "MozillaMar", "python_path": "mozilla_mar.py", "dependencies": []}, "archive/lzh.ksy": {"class_name": "Lzh", "python_path": "lzh.py", "dependencies": [{"class_name": "DosDatetime", "python_path": "dos_datetime.py"}]}, "archive/rar.ksy": {"class_name": "Rar", "python_path": "rar.py", "dependencies": [{"class_name": "DosDatetime", "python_path": "dos_datetime.py"}]}, "archive/zisofs.ksy": {"class_name": "Zisofs", "python_path": "zisofs.py", "dependencies": []}, "archive/android_bootldr_asus.ksy": {"class_name": "AndroidBootldrAsus", "python_path": "android_bootldr_asus.py", "dependencies": []}, "archive/cpio_old_le.ksy": {"class_name": "CpioOldLe", "python_path": "cpio_old_le.py", "dependencies": []}, "archive/zip.ksy": {"class_name": "Zip", "python_path": "zip.py", "dependencies": [{"class_name": "DosDatetime", "python_path": "dos_datetime.py"}]}, "archive/android_dto.ksy": {"class_name": "AndroidDto", "python_path": "android_dto.py", "dependencies": []}, "archive/rpm.ksy": {"class_name": "Rpm", "python_path": "rpm.py", "dependencies": []}, "archive/android_sparse.ksy": {"class_name": "AndroidSparse", "python_path": "android_sparse.py", "dependencies": []}, "archive/android_bootldr_qcom.ksy": {"class_name": "AndroidBootldrQcom", "python_path": "android_bootldr_qcom.py", "dependencies": []}, "archive/gzip.ksy": {"class_name": "Gzip", "python_path": "gzip.py", "dependencies": []}, "archive/android_img.ksy": {"class_name": "AndroidImg", "python_path": "android_img.py", "dependencies": []}, "archive/android_bootldr_huawei.ksy": {"class_name": "AndroidBootldrHuawei", "python_path": "android_bootldr_huawei.py", "dependencies": []}, "archive/phar_without_stub.ksy": {"class_name": "PharWithoutStub", "python_path": "phar_without_stub.py", "dependencies": [{"class_name": "PhpSerializedValue", "python_path": "php_serialized_value.py"}]}, "security/efivar_signature_list.ksy": {"class_name": "EfivarSignatureList", "python_path": "efivar_signature_list.py", "dependencies": []}, "archive/xar.ksy": {"class_name": "Xar", "python_path": "xar.py", "dependencies": []}, "serialization/bson.ksy": {"class_name": "Bson", "python_path": "bson.py", "dependencies": []}, "security/ssh_public_key.ksy": {"class_name": "SshPublicKey", "python_path": "ssh_public_key.py", "dependencies": []}, "security/openpgp_message.ksy": {"class_name": "OpenpgpMessage", "python_path": "openpgp_message.py", "dependencies": []}, "serialization/google_protobuf.ksy": {"class_name": "GoogleProtobuf", "python_path": "google_protobuf.py", "dependencies": [{"class_name": "VlqBase128Le", "python_path": "vlq_base128_le.py"}]}, "serialization/php_serialized_value.ksy": {"class_name": "PhpSerializedValue", "python_path": "php_serialized_value.py", "dependencies": []}, "serialization/microsoft_cfb.ksy": {"class_name": "MicrosoftCfb", "python_path": "microsoft_cfb.py", "dependencies": []}, "serialization/python_pickle.ksy": {"class_name": "PythonPickle", "python_path": "python_pickle.py", "dependencies": []}, "serialization/msgpack.ksy": {"class_name": "Msgpack", "python_path": "msgpack.py", "dependencies": []}, "serialization/ruby_marshal.ksy": {"class_name": "RubyMarshal", "python_path": "ruby_marshal.py", "dependencies": []}, "serialization/chrome_pak.ksy": {"class_name": "ChromePak", "python_path": "chrome_pak.py", "dependencies": []}, "network/tls_client_hello.ksy": {"class_name": "TlsClientHello", "python_path": "tls_client_hello.py", "dependencies": []}, "machine_code/code_6502.ksy": {"class_name": "Code6502", "python_path": "code_6502.py", "dependencies": []}, "network/rtpdump.ksy": {"class_name": "Rtpdump", "python_path": "rtpdump.py", "dependencies": [{"class_name": "RtpPacket", "python_path": "rtp_packet.py"}]}, "network/ipv4_packet.ksy": {"class_name": "Ipv4Packet", "python_path": "ipv4_packet.py", "dependencies": [{"class_name": "TcpSegment", "python_path": "tcp_segment.py"}, {"class_name": "UdpDatagram", "python_path": "udp_datagram.py"}, {"class_name": "ProtocolBody", "python_path": "protocol_body.py"}, {"class_name": "IcmpPacket", "python_path": "icmp_packet.py"}, {"class_name": "Ipv6Packet", "python_path": "ipv6_packet.py"}]}, "network/dns_packet.ksy": {"class_name": "DnsPacket", "python_path": "dns_packet.py", "dependencies": []}, "network/dime_message.ksy": {"class_name": "DimeMessage", "python_path": "dime_message.py", "dependencies": []}, "network/rtp_packet.ksy": {"class_name": "RtpPacket", "python_path": "rtp_packet.py", "dependencies": []}, "network/websocket.ksy": {"class_name": "Websocket", "python_path": "websocket.py", "dependencies": []}, "network/ipv6_packet.ksy": {"class_name": "Ipv6Packet", "python_path": "ipv6_packet.py", "dependencies": [{"class_name": "TcpSegment", "python_path": "tcp_segment.py"}, {"class_name": "UdpDatagram", "python_path": "udp_datagram.py"}, {"class_name": "ProtocolBody", "python_path": "protocol_body.py"}, {"class_name": "Ipv4Packet", "python_path": "ipv4_packet.py"}, {"class_name": "IcmpPacket", "python_path": "icmp_packet.py"}]}, "network/bitcoin_transaction.ksy": {"class_name": "BitcoinTransaction", "python_path": "bitcoin_transaction.py", "dependencies": []}, "network/udp_datagram.ksy": {"class_name": "UdpDatagram", "python_path": "udp_datagram.py", "dependencies": []}, "network/icmp_packet.ksy": {"class_name": "IcmpPacket", "python_path": "icmp_packet.py", "dependencies": []}, "network/tcp_segment.ksy": {"class_name": "TcpSegment", "python_path": "tcp_segment.py", "dependencies": []}, "network/ethernet_frame.ksy": {"class_name": "EthernetFrame", "python_path": "ethernet_frame.py", "dependencies": [{"class_name": "TcpSegment", "python_path": "tcp_segment.py"}, {"class_name": "UdpDatagram", "python_path": "udp_datagram.py"}, {"class_name": "ProtocolBody", "python_path": "protocol_body.py"}, {"class_name": "Ipv4Packet", "python_path": "ipv4_packet.py"}, {"class_name": "IcmpPacket", "python_path": "icmp_packet.py"}, {"class_name": "Ipv6Packet", "python_path": "ipv6_packet.py"}]}, "network/packet_ppi.ksy": {"class_name": "PacketPpi", "python_path": "packet_ppi.py", "dependencies": [{"class_name": "TcpSegment", "python_path": "tcp_segment.py"}, {"class_name": "UdpDatagram", "python_path": "udp_datagram.py"}, {"class_name": "ProtocolBody", "python_path": "protocol_body.py"}, {"class_name": "Ipv4Packet", "python_path": "ipv4_packet.py"}, {"class_name": "IcmpPacket", "python_path": "icmp_packet.py"}, {"class_name": "EthernetFrame", "python_path": "ethernet_frame.py"}, {"class_name": "Ipv6Packet", "python_path": "ipv6_packet.py"}]}, "network/protocol_body.ksy": {"class_name": "ProtocolBody", "python_path": "protocol_body.py", "dependencies": [{"class_name": "TcpSegment", "python_path": "tcp_segment.py"}, {"class_name": "UdpDatagram", "python_path": "udp_datagram.py"}, {"class_name": "Ipv4Packet", "python_path": "ipv4_packet.py"}, {"class_name": "IcmpPacket", "python_path": "icmp_packet.py"}, {"class_name": "Ipv6Packet", "python_path": "ipv6_packet.py"}]}, "network/hccap.ksy": {"class_name": "Hccap", "python_path": "hccap.py", "dependencies": []}, "network/pcap.ksy": {"class_name": "Pcap", "python_path": "pcap.py", "dependencies": [{"class_name": "TcpSegment", "python_path": "tcp_segment.py"}, {"class_name": "PacketPpi", "python_path": "packet_ppi.py"}, {"class_name": "UdpDatagram", "python_path": "udp_datagram.py"}, {"class_name": "ProtocolBody", "python_path": "protocol_body.py"}, {"class_name": "Ipv4Packet", "python_path": "ipv4_packet.py"}, {"class_name": "IcmpPacket", "python_path": "icmp_packet.py"}, {"class_name": "EthernetFrame", "python_path": "ethernet_frame.py"}, {"class_name": "Ipv6Packet", "python_path": "ipv6_packet.py"}]}, "network/rtcp_payload.ksy": {"class_name": "RtcpPayload", "python_path": "rtcp_payload.py", "dependencies": []}, "network/hccapx.ksy": {"class_name": "Hccapx", "python_path": "hccapx.py", "dependencies": []}, "network/microsoft_network_monitor_v2.ksy": {"class_name": "MicrosoftNetworkMonitorV2", "python_path": "microsoft_network_monitor_v2.py", "dependencies": [{"class_name": "TcpSegment", "python_path": "tcp_segment.py"}, {"class_name": "UdpDatagram", "python_path": "udp_datagram.py"}, {"class_name": "ProtocolBody", "python_path": "protocol_body.py"}, {"class_name": "Ipv4Packet", "python_path": "ipv4_packet.py"}, {"class_name": "WindowsSystemtime", "python_path": "windows_systemtime.py"}, {"class_name": "IcmpPacket", "python_path": "icmp_packet.py"}, {"class_name": "EthernetFrame", "python_path": "ethernet_frame.py"}, {"class_name": "Ipv6Packet", "python_path": "ipv6_packet.py"}]}, "filesystem/iso9660.ksy": {"class_name": "Iso9660", "python_path": "iso9660.py", "dependencies": []}, "filesystem/apm_partition_table.ksy": {"class_name": "ApmPartitionTable", "python_path": "apm_partition_table.py", "dependencies": []}, "filesystem/ext2.ksy": {"class_name": "Ext2", "python_path": "ext2.py", "dependencies": []}, "filesystem/gpt_partition_table.ksy": {"class_name": "GptPartitionTable", "python_path": "gpt_partition_table.py", "dependencies": []}, "filesystem/luks.ksy": {"class_name": "Luks", "python_path": "luks.py", "dependencies": []}, "filesystem/tr_dos_image.ksy": {"class_name": "TrDosImage", "python_path": "tr_dos_image.py", "dependencies": []}, "filesystem/zx_spectrum_tap.ksy": {"class_name": "ZxSpectrumTap", "python_path": "zx_spectrum_tap.py", "dependencies": []}, "filesystem/android_super.ksy": {"class_name": "AndroidSuper", "python_path": "android_super.py", "dependencies": []}, "filesystem/apple_single_double.ksy": {"class_name": "AppleSingleDouble", "python_path": "apple_single_double.py", "dependencies": []}, "filesystem/btrfs_stream.ksy": {"class_name": "BtrfsStream", "python_path": "btrfs_stream.py", "dependencies": []}, "filesystem/mbr_partition_table.ksy": {"class_name": "MbrPartitionTable", "python_path": "mbr_partition_table.py", "dependencies": []}, "filesystem/vmware_vmdk.ksy": {"class_name": "VmwareVmdk", "python_path": "vmware_vmdk.py", "dependencies": []}, "filesystem/cramfs.ksy": {"class_name": "Cramfs", "python_path": "cramfs.py", "dependencies": []}, "filesystem/vfat.ksy": {"class_name": "Vfat", "python_path": "vfat.py", "dependencies": [{"class_name": "DosDatetime", "python_path": "dos_datetime.py"}]}, "game/renderware_binary_stream.ksy": {"class_name": "RenderwareBinaryStream", "python_path": "renderware_binary_stream.py", "dependencies": []}, "game/fallout_dat.ksy": {"class_name": "FalloutDat", "python_path": "fallout_dat.py", "dependencies": []}, "game/saints_row_2_vpp_pc.ksy": {"class_name": "SaintsRow2VppPc", "python_path": "saints_row_2_vpp_pc.py", "dependencies": []}, "game/ftl_dat.ksy": {"class_name": "FtlDat", "python_path": "ftl_dat.py", "dependencies": []}, "game/fallout2_dat.ksy": {"class_name": "Fallout2Dat", "python_path": "fallout2_dat.py", "dependencies": []}, "game/heaps_pak.ksy": {"class_name": "HeapsPak", "python_path": "heaps_pak.py", "dependencies": []}, "game/gran_turismo_vol.ksy": {"class_name": "GranTurismoVol", "python_path": "gran_turismo_vol.py", "dependencies": []}, "game/quake_pak.ksy": {"class_name": "QuakePak", "python_path": "quake_pak.py", "dependencies": []}, "game/minecraft_nbt.ksy": {"class_name": "MinecraftNbt", "python_path": "minecraft_nbt.py", "dependencies": []}, "game/dune_2_pak.ksy": {"class_name": "Dune2Pak", "python_path": "dune_2_pak.py", "dependencies": []}, "game/heroes_of_might_and_magic_bmp.ksy": {"class_name": "HeroesOfMightAndMagicBmp", "python_path": "heroes_of_might_and_magic_bmp.py", "dependencies": []}, "game/doom_wad.ksy": {"class_name": "DoomWad", "python_path": "doom_wad.py", "dependencies": []}, "game/warcraft_2_pud.ksy": {"class_name": "Warcraft2Pud", "python_path": "warcraft_2_pud.py", "dependencies": []}, "game/heroes_of_might_and_magic_agg.ksy": {"class_name": "HeroesOfMightAndMagicAgg", "python_path": "heroes_of_might_and_magic_agg.py", "dependencies": []}, "image/pcx.ksy": {"class_name": "Pcx", "python_path": "pcx.py", "dependencies": []}, "game/quake_mdl.ksy": {"class_name": "QuakeMdl", "python_path": "quake_mdl.py", "dependencies": []}, "game/allegro_dat.ksy": {"class_name": "AllegroDat", "python_path": "allegro_dat.py", "dependencies": []}, "image/pcx_dcx.ksy": {"class_name": "PcxDcx", "python_path": "pcx_dcx.py", "dependencies": [{"class_name": "Pcx", "python_path": "pcx.py"}]}, "image/xwd.ksy": {"class_name": "Xwd", "python_path": "xwd.py", "dependencies": []}, "image/psx_tim.ksy": {"class_name": "PsxTim", "python_path": "psx_tim.py", "dependencies": []}, "image/ico.ksy": {"class_name": "Ico", "python_path": "ico.py", "dependencies": []}, "image/wmf.ksy": {"class_name": "Wmf", "python_path": "wmf.py", "dependencies": []}, "image/gimp_brush.ksy": {"class_name": "GimpBrush", "python_path": "gimp_brush.py", "dependencies": []}, "image/gif.ksy": {"class_name": "Gif", "python_path": "gif.py", "dependencies": []}, "image/tga.ksy": {"class_name": "Tga", "python_path": "tga.py", "dependencies": []}, "image/nitf.ksy": {"class_name": "Nitf", "python_path": "nitf.py", "dependencies": []}, "image/dicom.ksy": {"class_name": "Dicom", "python_path": "dicom.py", "dependencies": []}, "image/bmp.ksy": {"class_name": "Bmp", "python_path": "bmp.py", "dependencies": []}, "image/exif.ksy": {"class_name": "Exif", "python_path": "exif.py", "dependencies": []}, "common/vlq_base128_be.ksy": {"class_name": "VlqBase128Be", "python_path": "vlq_base128_be.py", "dependencies": []}, "image/png.ksy": {"class_name": "Png", "python_path": "png.py", "dependencies": []}, "common/utf8_string.ksy": {"class_name": "Utf8String", "python_path": "utf8_string.py", "dependencies": []}, "image/jpeg.ksy": {"class_name": "Jpeg", "python_path": "jpeg.py", "dependencies": [{"class_name": "Exif", "python_path": "exif.py"}]}, "common/bytes_with_io.ksy": {"class_name": "BytesWithIo", "python_path": "bytes_with_io.py", "dependencies": []}, "common/riff.ksy": {"class_name": "Riff", "python_path": "riff.py", "dependencies": []}, "common/dos_datetime.ksy": {"class_name": "DosDatetime", "python_path": "dos_datetime.py", "dependencies": []}, "common/bcd.ksy": {"class_name": "Bcd", "python_path": "bcd.py", "dependencies": []}, "cad/monomakh_sapr_chg.ksy": {"class_name": "MonomakhSaprChg", "python_path": "monomakh_sapr_chg.py", "dependencies": []}, "common/vlq_base128_le.ksy": {"class_name": "VlqBase128Le", "python_path": "vlq_base128_le.py", "dependencies": []}, "log/windows_evt_log.ksy": {"class_name": "WindowsEvtLog", "python_path": "windows_evt_log.py", "dependencies": []}, "log/aix_utmp.ksy": {"class_name": "AixUtmp", "python_path": "aix_utmp.py", "dependencies": []}, "log/sudoers_ts.ksy": {"class_name": "SudoersTs", "python_path": "sudoers_ts.py", "dependencies": []}, "log/hashcat_restore.ksy": {"class_name": "HashcatRestore", "python_path": "hashcat_restore.py", "dependencies": []}, "log/mcap.ksy": {"class_name": "Mcap", "python_path": "mcap.py", "dependencies": []}, "log/glibc_utmp.ksy": {"class_name": "GlibcUtmp", "python_path": "glibc_utmp.py", "dependencies": []}, "log/systemd_journal.ksy": {"class_name": "SystemdJournal", "python_path": "systemd_journal.py", "dependencies": []}, "windows/windows_shell_items.ksy": {"class_name": "WindowsShellItems", "python_path": "windows_shell_items.py", "dependencies": []}, "windows/windows_systemtime.ksy": {"class_name": "WindowsSystemtime", "python_path": "windows_systemtime.py", "dependencies": []}, "font/grub2_font.ksy": {"class_name": "Grub2Font", "python_path": "grub2_font.py", "dependencies": []}, "font/pcf_font.ksy": {"class_name": "PcfFont", "python_path": "pcf_font.py", "dependencies": [{"class_name": "BytesWithIo", "python_path": "bytes_with_io.py"}]}, "windows/windows_resource_file.ksy": {"class_name": "WindowsResourceFile", "python_path": "windows_resource_file.py", "dependencies": []}, "windows/windows_minidump.ksy": {"class_name": "WindowsMinidump", "python_path": "windows_minidump.py", "dependencies": []}, "font/ttf.ksy": {"class_name": "Ttf", "python_path": "ttf.py", "dependencies": []}, "geospatial/shapefile_index.ksy": {"class_name": "ShapefileIndex", "python_path": "shapefile_index.py", "dependencies": []}, "windows/regf.ksy": {"class_name": "Regf", "python_path": "regf.py", "dependencies": []}, "windows/windows_lnk_file.ksy": {"class_name": "WindowsLnkFile", "python_path": "windows_lnk_file.py", "dependencies": [{"class_name": "WindowsShellItems", "python_path": "windows_shell_items.py"}]}, "geospatial/shapefile_main.ksy": {"class_name": "ShapefileMain", "python_path": "shapefile_main.py", "dependencies": []}, "media/id3v2_4.ksy": {"class_name": "Id3v24", "python_path": "id3v2_4.py", "dependencies": []}, "media/id3v1_1.ksy": {"class_name": "Id3v11", "python_path": "id3v1_1.py", "dependencies": []}, "media/ogg.ksy": {"class_name": "Ogg", "python_path": "ogg.py", "dependencies": []}, "media/id3v2_3.ksy": {"class_name": "Id3v23", "python_path": "id3v2_3.py", "dependencies": []}, "media/wav.ksy": {"class_name": "Wav", "python_path": "wav.py", "dependencies": [{"class_name": "Riff", "python_path": "riff.py"}]}, "media/stl.ksy": {"class_name": "Stl", "python_path": "stl.py", "dependencies": []}, "media/magicavoxel_vox.ksy": {"class_name": "MagicavoxelVox", "python_path": "magicavoxel_vox.py", "dependencies": []}, "media/au.ksy": {"class_name": "Au", "python_path": "au.py", "dependencies": []}, "media/genmidi_op2.ksy": {"class_name": "GenmidiOp2", "python_path": "genmidi_op2.py", "dependencies": []}, "media/android_opengl_shaders_cache.ksy": {"class_name": "AndroidOpenglShadersCache", "python_path": "android_opengl_shaders_cache.py", "dependencies": []}, "media/vp8_ivf.ksy": {"class_name": "Vp8Ivf", "python_path": "vp8_ivf.py", "dependencies": []}, "media/creative_voice_file.ksy": {"class_name": "CreativeVoiceFile", "python_path": "creative_voice_file.py", "dependencies": []}, "media/blender_blend.ksy": {"class_name": "BlenderBlend", "python_path": "blender_blend.py", "dependencies": []}, "media/avi.ksy": {"class_name": "Avi", "python_path": "avi.py", "dependencies": []}, "media/standard_midi_file.ksy": {"class_name": "StandardMidiFile", "python_path": "standard_midi_file.py", "dependencies": [{"class_name": "VlqBase128Be", "python_path": "vlq_base128_be.py"}]}, "media/tracker_modules/s3m.ksy": {"class_name": "S3m", "python_path": "s3m.py", "dependencies": []}, "media/quicktime_mov.ksy": {"class_name": "QuicktimeMov", "python_path": "quicktime_mov.py", "dependencies": []}, "scientific/spectroscopy/specpr.ksy": {"class_name": "Specpr", "python_path": "specpr.py", "dependencies": []}, "scientific/spectroscopy/avantes_roh60.ksy": {"class_name": "AvantesRoh60", "python_path": "avantes_roh60.py", "dependencies": []}, "media/tracker_modules/fasttracker_xm_module.ksy": {"class_name": "FasttrackerXmModule", "python_path": "fasttracker_xm_module.py", "dependencies": []}, "scientific/nt_mdt/nt_mdt_pal.ksy": {"class_name": "NtMdtPal", "python_path": "nt_mdt_pal.py", "dependencies": []}, "network/some_ip/some_ip_sd_entries.ksy": {"class_name": "SomeIpSdEntries", "python_path": "some_ip_sd_entries.py", "dependencies": []}, "network/some_ip/some_ip_container.ksy": {"class_name": "SomeIpContainer", "python_path": "some_ip_container.py", "dependencies": [{"class_name": "SomeIp", "python_path": "some_ip.py"}, {"class_name": "SomeIpSdEntries", "python_path": "some_ip_sd_entries.py"}, {"class_name": "SomeIpSd", "python_path": "some_ip_sd.py"}, {"class_name": "SomeIpSdOptions", "python_path": "some_ip_sd_options.py"}]}, "network/some_ip/some_ip_sd.ksy": {"class_name": "SomeIpSd", "python_path": "some_ip_sd.py", "dependencies": [{"class_name": "SomeIpSdOptions", "python_path": "some_ip_sd_options.py"}, {"class_name": "SomeIpSdEntries", "python_path": "some_ip_sd_entries.py"}]}, "network/some_ip/some_ip_sd_options.ksy": {"class_name": "SomeIpSdOptions", "python_path": "some_ip_sd_options.py", "dependencies": []}, "serialization/asn1/asn1_der.ksy": {"class_name": "Asn1Der", "python_path": "asn1_der.py", "dependencies": []}, "network/some_ip/some_ip.ksy": {"class_name": "SomeIp", "python_path": "some_ip.py", "dependencies": [{"class_name": "SomeIpSdOptions", "python_path": "some_ip_sd_options.py"}, {"class_name": "SomeIpSdEntries", "python_path": "some_ip_sd_entries.py"}, {"class_name": "SomeIpSd", "python_path": "some_ip_sd.py"}]}, "macos/resource_compression/dcmp_variable_length_integer.ksy": {"class_name": "DcmpVariableLengthInteger", "python_path": "dcmp_variable_length_integer.py", "dependencies": []}, "macos/resource_compression/dcmp_2.ksy": {"class_name": "Dcmp2", "python_path": "dcmp_2.py", "dependencies": [{"class_name": "BytesWithIo", "python_path": "bytes_with_io.py"}]}, "macos/resource_compression/dcmp_1.ksy": {"class_name": "Dcmp1", "python_path": "dcmp_1.py", "dependencies": [{"class_name": "DcmpVariableLengthInteger", "python_path": "dcmp_variable_length_integer.py"}]}, "macos/resource_compression/dcmp_0.ksy": {"class_name": "Dcmp0", "python_path": "dcmp_0.py", "dependencies": [{"class_name": "DcmpVariableLengthInteger", "python_path": "dcmp_variable_length_integer.py"}]}, "hardware/mifare/mifare_classic.ksy": {"class_name": "MifareClassic", "python_path": "mifare_classic.py", "dependencies": []}} \ No newline at end of file diff --git a/polyfile/kaitai/parsers/nt_mdt.py b/polyfile/kaitai/parsers/nt_mdt.py deleted file mode 100644 index 8696cd7c..00000000 --- a/polyfile/kaitai/parsers/nt_mdt.py +++ /dev/null @@ -1,1311 +0,0 @@ -# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild - -from pkg_resources import parse_version -import kaitaistruct -from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO -from enum import Enum -import collections - - -if parse_version(kaitaistruct.__version__) < parse_version('0.9'): - raise Exception("Incompatible Kaitai Struct Python API: 0.9 or later is required, but you have %s" % (kaitaistruct.__version__)) - -class NtMdt(KaitaiStruct): - """A native file format of NT-MDT scientific software. Usually contains - any of: - - * [Scanning probe](https://en.wikipedia.org/wiki/Scanning_probe_microscopy) microscopy scans and spectra - * [Raman spectra](https://en.wikipedia.org/wiki/Raman_spectroscopy) - * results of their analysis - - Some examples of mdt files can be downloaded at: - - * - * - - .. seealso:: - Source - https://svn.code.sf.net/p/gwyddion/code/trunk/gwyddion/modules/file/nt-mdt.c - """ - - class AdcMode(Enum): - height = 0 - dfl = 1 - lateral_f = 2 - bias_v = 3 - current = 4 - fb_out = 5 - mag = 6 - mag_sin = 7 - mag_cos = 8 - rms = 9 - calc_mag = 10 - phase1 = 11 - phase2 = 12 - calc_phase = 13 - ex1 = 14 - ex2 = 15 - hv_x = 16 - hv_y = 17 - snap_back = 18 - false = 255 - - class XmlScanLocation(Enum): - hlt = 0 - hlb = 1 - hrt = 2 - hrb = 3 - vlt = 4 - vlb = 5 - vrt = 6 - vrb = 7 - - class DataType(Enum): - floatfix = -65544 - float80 = -16138 - float64 = -13320 - float48 = -9990 - float32 = -5892 - int64 = -8 - int32 = -4 - int16 = -2 - int8 = -1 - unknown0 = 0 - uint8 = 1 - uint16 = 2 - uint32 = 4 - uint64 = 8 - - class XmlParamType(Enum): - none = 0 - laser_wavelength = 1 - units = 2 - data_array = 255 - - class SpmMode(Enum): - constant_force = 0 - contact_constant_height = 1 - contact_error = 2 - lateral_force = 3 - force_modulation = 4 - spreading_resistance_imaging = 5 - semicontact_topography = 6 - semicontact_error = 7 - phase_contrast = 8 - ac_magnetic_force = 9 - dc_magnetic_force = 10 - electrostatic_force = 11 - capacitance_contrast = 12 - kelvin_probe = 13 - constant_current = 14 - barrier_height = 15 - constant_height = 16 - afam = 17 - contact_efm = 18 - shear_force_topography = 19 - sfom = 20 - contact_capacitance = 21 - snom_transmission = 22 - snom_reflection = 23 - snom_all = 24 - snom = 25 - - class Unit(Enum): - raman_shift = -10 - reserved0 = -9 - reserved1 = -8 - reserved2 = -7 - reserved3 = -6 - meter = -5 - centi_meter = -4 - milli_meter = -3 - micro_meter = -2 - nano_meter = -1 - angstrom = 0 - nano_ampere = 1 - volt = 2 - none = 3 - kilo_hertz = 4 - degrees = 5 - percent = 6 - celsius_degree = 7 - volt_high = 8 - second = 9 - milli_second = 10 - micro_second = 11 - nano_second = 12 - counts = 13 - pixels = 14 - reserved_sfom0 = 15 - reserved_sfom1 = 16 - reserved_sfom2 = 17 - reserved_sfom3 = 18 - reserved_sfom4 = 19 - ampere2 = 20 - milli_ampere = 21 - micro_ampere = 22 - nano_ampere2 = 23 - pico_ampere = 24 - volt2 = 25 - milli_volt = 26 - micro_volt = 27 - nano_volt = 28 - pico_volt = 29 - newton = 30 - milli_newton = 31 - micro_newton = 32 - nano_newton = 33 - pico_newton = 34 - reserved_dos0 = 35 - reserved_dos1 = 36 - reserved_dos2 = 37 - reserved_dos3 = 38 - reserved_dos4 = 39 - - class SpmTechnique(Enum): - contact_mode = 0 - semicontact_mode = 1 - tunnel_current = 2 - snom = 3 - - class Consts(Enum): - frame_mode_size = 8 - frame_header_size = 22 - axis_scales_size = 30 - file_header_size = 32 - spectro_vars_min_size = 38 - scan_vars_min_size = 77 - SEQ_FIELDS = ["signature", "size", "reserved0", "last_frame", "reserved1", "wrond_doc", "frames"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['signature']['start'] = self._io.pos() - self.signature = self._io.read_bytes(4) - self._debug['signature']['end'] = self._io.pos() - if not self.signature == b"\x01\xB0\x93\xFF": - raise kaitaistruct.ValidationNotEqualError(b"\x01\xB0\x93\xFF", self.signature, self._io, u"/seq/0") - self._debug['size']['start'] = self._io.pos() - self.size = self._io.read_u4le() - self._debug['size']['end'] = self._io.pos() - self._debug['reserved0']['start'] = self._io.pos() - self.reserved0 = self._io.read_bytes(4) - self._debug['reserved0']['end'] = self._io.pos() - self._debug['last_frame']['start'] = self._io.pos() - self.last_frame = self._io.read_u2le() - self._debug['last_frame']['end'] = self._io.pos() - self._debug['reserved1']['start'] = self._io.pos() - self.reserved1 = self._io.read_bytes(18) - self._debug['reserved1']['end'] = self._io.pos() - self._debug['wrond_doc']['start'] = self._io.pos() - self.wrond_doc = self._io.read_bytes(1) - self._debug['wrond_doc']['end'] = self._io.pos() - self._debug['frames']['start'] = self._io.pos() - self._raw_frames = self._io.read_bytes(self.size) - _io__raw_frames = KaitaiStream(BytesIO(self._raw_frames)) - self.frames = NtMdt.Framez(_io__raw_frames, self, self._root) - self.frames._read() - self._debug['frames']['end'] = self._io.pos() - - class Uuid(KaitaiStruct): - SEQ_FIELDS = ["data"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['data']['start'] = self._io.pos() - self.data = [None] * (16) - for i in range(16): - if not 'arr' in self._debug['data']: - self._debug['data']['arr'] = [] - self._debug['data']['arr'].append({'start': self._io.pos()}) - self.data[i] = self._io.read_u1() - self._debug['data']['arr'][i]['end'] = self._io.pos() - - self._debug['data']['end'] = self._io.pos() - - - class Framez(KaitaiStruct): - SEQ_FIELDS = ["frames"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['frames']['start'] = self._io.pos() - self.frames = [None] * ((self._root.last_frame + 1)) - for i in range((self._root.last_frame + 1)): - if not 'arr' in self._debug['frames']: - self._debug['frames']['arr'] = [] - self._debug['frames']['arr'].append({'start': self._io.pos()}) - _t_frames = NtMdt.Frame(self._io, self, self._root) - _t_frames._read() - self.frames[i] = _t_frames - self._debug['frames']['arr'][i]['end'] = self._io.pos() - - self._debug['frames']['end'] = self._io.pos() - - - class Frame(KaitaiStruct): - - class FrameType(Enum): - scanned = 0 - spectroscopy = 1 - text = 3 - old_mda = 105 - mda = 106 - palette = 107 - curves_new = 190 - curves = 201 - SEQ_FIELDS = ["size", "main"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['size']['start'] = self._io.pos() - self.size = self._io.read_u4le() - self._debug['size']['end'] = self._io.pos() - self._debug['main']['start'] = self._io.pos() - self._raw_main = self._io.read_bytes((self.size - 4)) - _io__raw_main = KaitaiStream(BytesIO(self._raw_main)) - self.main = NtMdt.Frame.FrameMain(_io__raw_main, self, self._root) - self.main._read() - self._debug['main']['end'] = self._io.pos() - - class Dots(KaitaiStruct): - SEQ_FIELDS = ["fm_ndots", "coord_header", "coordinates", "data"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['fm_ndots']['start'] = self._io.pos() - self.fm_ndots = self._io.read_u2le() - self._debug['fm_ndots']['end'] = self._io.pos() - if self.fm_ndots > 0: - self._debug['coord_header']['start'] = self._io.pos() - self.coord_header = NtMdt.Frame.Dots.DotsHeader(self._io, self, self._root) - self.coord_header._read() - self._debug['coord_header']['end'] = self._io.pos() - - self._debug['coordinates']['start'] = self._io.pos() - self.coordinates = [None] * (self.fm_ndots) - for i in range(self.fm_ndots): - if not 'arr' in self._debug['coordinates']: - self._debug['coordinates']['arr'] = [] - self._debug['coordinates']['arr'].append({'start': self._io.pos()}) - _t_coordinates = NtMdt.Frame.Dots.DotsData(self._io, self, self._root) - _t_coordinates._read() - self.coordinates[i] = _t_coordinates - self._debug['coordinates']['arr'][i]['end'] = self._io.pos() - - self._debug['coordinates']['end'] = self._io.pos() - self._debug['data']['start'] = self._io.pos() - self.data = [None] * (self.fm_ndots) - for i in range(self.fm_ndots): - if not 'arr' in self._debug['data']: - self._debug['data']['arr'] = [] - self._debug['data']['arr'].append({'start': self._io.pos()}) - _t_data = NtMdt.Frame.Dots.DataLinez(i, self._io, self, self._root) - _t_data._read() - self.data[i] = _t_data - self._debug['data']['arr'][i]['end'] = self._io.pos() - - self._debug['data']['end'] = self._io.pos() - - class DotsHeader(KaitaiStruct): - SEQ_FIELDS = ["header_size", "header"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['header_size']['start'] = self._io.pos() - self.header_size = self._io.read_s4le() - self._debug['header_size']['end'] = self._io.pos() - self._debug['header']['start'] = self._io.pos() - self._raw_header = self._io.read_bytes(self.header_size) - _io__raw_header = KaitaiStream(BytesIO(self._raw_header)) - self.header = NtMdt.Frame.Dots.DotsHeader.Header(_io__raw_header, self, self._root) - self.header._read() - self._debug['header']['end'] = self._io.pos() - - class Header(KaitaiStruct): - SEQ_FIELDS = ["coord_size", "version", "xyunits"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['coord_size']['start'] = self._io.pos() - self.coord_size = self._io.read_s4le() - self._debug['coord_size']['end'] = self._io.pos() - self._debug['version']['start'] = self._io.pos() - self.version = self._io.read_s4le() - self._debug['version']['end'] = self._io.pos() - self._debug['xyunits']['start'] = self._io.pos() - self.xyunits = KaitaiStream.resolve_enum(NtMdt.Unit, self._io.read_s2le()) - self._debug['xyunits']['end'] = self._io.pos() - - - - class DotsData(KaitaiStruct): - SEQ_FIELDS = ["coord_x", "coord_y", "forward_size", "backward_size"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['coord_x']['start'] = self._io.pos() - self.coord_x = self._io.read_f4le() - self._debug['coord_x']['end'] = self._io.pos() - self._debug['coord_y']['start'] = self._io.pos() - self.coord_y = self._io.read_f4le() - self._debug['coord_y']['end'] = self._io.pos() - self._debug['forward_size']['start'] = self._io.pos() - self.forward_size = self._io.read_s4le() - self._debug['forward_size']['end'] = self._io.pos() - self._debug['backward_size']['start'] = self._io.pos() - self.backward_size = self._io.read_s4le() - self._debug['backward_size']['end'] = self._io.pos() - - - class DataLinez(KaitaiStruct): - SEQ_FIELDS = ["forward", "backward"] - def __init__(self, index, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self.index = index - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['forward']['start'] = self._io.pos() - self.forward = [None] * (self._parent.coordinates[self.index].forward_size) - for i in range(self._parent.coordinates[self.index].forward_size): - if not 'arr' in self._debug['forward']: - self._debug['forward']['arr'] = [] - self._debug['forward']['arr'].append({'start': self._io.pos()}) - self.forward[i] = self._io.read_s2le() - self._debug['forward']['arr'][i]['end'] = self._io.pos() - - self._debug['forward']['end'] = self._io.pos() - self._debug['backward']['start'] = self._io.pos() - self.backward = [None] * (self._parent.coordinates[self.index].backward_size) - for i in range(self._parent.coordinates[self.index].backward_size): - if not 'arr' in self._debug['backward']: - self._debug['backward']['arr'] = [] - self._debug['backward']['arr'].append({'start': self._io.pos()}) - self.backward[i] = self._io.read_s2le() - self._debug['backward']['arr'][i]['end'] = self._io.pos() - - self._debug['backward']['end'] = self._io.pos() - - - - class FrameMain(KaitaiStruct): - SEQ_FIELDS = ["type", "version", "date_time", "var_size", "frame_data"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['type']['start'] = self._io.pos() - self.type = KaitaiStream.resolve_enum(NtMdt.Frame.FrameType, self._io.read_u2le()) - self._debug['type']['end'] = self._io.pos() - self._debug['version']['start'] = self._io.pos() - self.version = NtMdt.Version(self._io, self, self._root) - self.version._read() - self._debug['version']['end'] = self._io.pos() - self._debug['date_time']['start'] = self._io.pos() - self.date_time = NtMdt.Frame.DateTime(self._io, self, self._root) - self.date_time._read() - self._debug['date_time']['end'] = self._io.pos() - self._debug['var_size']['start'] = self._io.pos() - self.var_size = self._io.read_u2le() - self._debug['var_size']['end'] = self._io.pos() - self._debug['frame_data']['start'] = self._io.pos() - _on = self.type - if _on == NtMdt.Frame.FrameType.mda: - self._raw_frame_data = self._io.read_bytes_full() - _io__raw_frame_data = KaitaiStream(BytesIO(self._raw_frame_data)) - self.frame_data = NtMdt.Frame.FdMetaData(_io__raw_frame_data, self, self._root) - self.frame_data._read() - elif _on == NtMdt.Frame.FrameType.curves_new: - self._raw_frame_data = self._io.read_bytes_full() - _io__raw_frame_data = KaitaiStream(BytesIO(self._raw_frame_data)) - self.frame_data = NtMdt.Frame.FdCurvesNew(_io__raw_frame_data, self, self._root) - self.frame_data._read() - elif _on == NtMdt.Frame.FrameType.curves: - self._raw_frame_data = self._io.read_bytes_full() - _io__raw_frame_data = KaitaiStream(BytesIO(self._raw_frame_data)) - self.frame_data = NtMdt.Frame.FdSpectroscopy(_io__raw_frame_data, self, self._root) - self.frame_data._read() - elif _on == NtMdt.Frame.FrameType.spectroscopy: - self._raw_frame_data = self._io.read_bytes_full() - _io__raw_frame_data = KaitaiStream(BytesIO(self._raw_frame_data)) - self.frame_data = NtMdt.Frame.FdSpectroscopy(_io__raw_frame_data, self, self._root) - self.frame_data._read() - elif _on == NtMdt.Frame.FrameType.scanned: - self._raw_frame_data = self._io.read_bytes_full() - _io__raw_frame_data = KaitaiStream(BytesIO(self._raw_frame_data)) - self.frame_data = NtMdt.Frame.FdScanned(_io__raw_frame_data, self, self._root) - self.frame_data._read() - else: - self.frame_data = self._io.read_bytes_full() - self._debug['frame_data']['end'] = self._io.pos() - - - class FdCurvesNew(KaitaiStruct): - SEQ_FIELDS = ["block_count", "blocks_headers", "blocks_names", "blocks_data"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['block_count']['start'] = self._io.pos() - self.block_count = self._io.read_u4le() - self._debug['block_count']['end'] = self._io.pos() - self._debug['blocks_headers']['start'] = self._io.pos() - self.blocks_headers = [None] * (self.block_count) - for i in range(self.block_count): - if not 'arr' in self._debug['blocks_headers']: - self._debug['blocks_headers']['arr'] = [] - self._debug['blocks_headers']['arr'].append({'start': self._io.pos()}) - _t_blocks_headers = NtMdt.Frame.FdCurvesNew.BlockDescr(self._io, self, self._root) - _t_blocks_headers._read() - self.blocks_headers[i] = _t_blocks_headers - self._debug['blocks_headers']['arr'][i]['end'] = self._io.pos() - - self._debug['blocks_headers']['end'] = self._io.pos() - self._debug['blocks_names']['start'] = self._io.pos() - self.blocks_names = [None] * (self.block_count) - for i in range(self.block_count): - if not 'arr' in self._debug['blocks_names']: - self._debug['blocks_names']['arr'] = [] - self._debug['blocks_names']['arr'].append({'start': self._io.pos()}) - self.blocks_names[i] = (self._io.read_bytes(self.blocks_headers[i].name_len)).decode(u"UTF-8") - self._debug['blocks_names']['arr'][i]['end'] = self._io.pos() - - self._debug['blocks_names']['end'] = self._io.pos() - self._debug['blocks_data']['start'] = self._io.pos() - self.blocks_data = [None] * (self.block_count) - for i in range(self.block_count): - if not 'arr' in self._debug['blocks_data']: - self._debug['blocks_data']['arr'] = [] - self._debug['blocks_data']['arr'].append({'start': self._io.pos()}) - self.blocks_data[i] = self._io.read_bytes(self.blocks_headers[i].len) - self._debug['blocks_data']['arr'][i]['end'] = self._io.pos() - - self._debug['blocks_data']['end'] = self._io.pos() - - class BlockDescr(KaitaiStruct): - SEQ_FIELDS = ["name_len", "len"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['name_len']['start'] = self._io.pos() - self.name_len = self._io.read_u4le() - self._debug['name_len']['end'] = self._io.pos() - self._debug['len']['start'] = self._io.pos() - self.len = self._io.read_u4le() - self._debug['len']['end'] = self._io.pos() - - - - class FdMetaData(KaitaiStruct): - SEQ_FIELDS = ["head_size", "tot_len", "guids", "frame_status", "name_size", "comm_size", "view_info_size", "spec_size", "source_info_size", "var_size", "data_offset", "data_size", "title", "xml", "struct_len", "array_size", "cell_size", "n_dimensions", "n_mesurands", "dimensions", "mesurands"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['head_size']['start'] = self._io.pos() - self.head_size = self._io.read_u4le() - self._debug['head_size']['end'] = self._io.pos() - self._debug['tot_len']['start'] = self._io.pos() - self.tot_len = self._io.read_u4le() - self._debug['tot_len']['end'] = self._io.pos() - self._debug['guids']['start'] = self._io.pos() - self.guids = [None] * (2) - for i in range(2): - if not 'arr' in self._debug['guids']: - self._debug['guids']['arr'] = [] - self._debug['guids']['arr'].append({'start': self._io.pos()}) - _t_guids = NtMdt.Uuid(self._io, self, self._root) - _t_guids._read() - self.guids[i] = _t_guids - self._debug['guids']['arr'][i]['end'] = self._io.pos() - - self._debug['guids']['end'] = self._io.pos() - self._debug['frame_status']['start'] = self._io.pos() - self.frame_status = self._io.read_bytes(4) - self._debug['frame_status']['end'] = self._io.pos() - self._debug['name_size']['start'] = self._io.pos() - self.name_size = self._io.read_u4le() - self._debug['name_size']['end'] = self._io.pos() - self._debug['comm_size']['start'] = self._io.pos() - self.comm_size = self._io.read_u4le() - self._debug['comm_size']['end'] = self._io.pos() - self._debug['view_info_size']['start'] = self._io.pos() - self.view_info_size = self._io.read_u4le() - self._debug['view_info_size']['end'] = self._io.pos() - self._debug['spec_size']['start'] = self._io.pos() - self.spec_size = self._io.read_u4le() - self._debug['spec_size']['end'] = self._io.pos() - self._debug['source_info_size']['start'] = self._io.pos() - self.source_info_size = self._io.read_u4le() - self._debug['source_info_size']['end'] = self._io.pos() - self._debug['var_size']['start'] = self._io.pos() - self.var_size = self._io.read_u4le() - self._debug['var_size']['end'] = self._io.pos() - self._debug['data_offset']['start'] = self._io.pos() - self.data_offset = self._io.read_u4le() - self._debug['data_offset']['end'] = self._io.pos() - self._debug['data_size']['start'] = self._io.pos() - self.data_size = self._io.read_u4le() - self._debug['data_size']['end'] = self._io.pos() - self._debug['title']['start'] = self._io.pos() - self.title = (self._io.read_bytes(self.name_size)).decode(u"UTF-8") - self._debug['title']['end'] = self._io.pos() - self._debug['xml']['start'] = self._io.pos() - self.xml = (self._io.read_bytes(self.comm_size)).decode(u"UTF-8") - self._debug['xml']['end'] = self._io.pos() - self._debug['struct_len']['start'] = self._io.pos() - self.struct_len = self._io.read_u4le() - self._debug['struct_len']['end'] = self._io.pos() - self._debug['array_size']['start'] = self._io.pos() - self.array_size = self._io.read_u8le() - self._debug['array_size']['end'] = self._io.pos() - self._debug['cell_size']['start'] = self._io.pos() - self.cell_size = self._io.read_u4le() - self._debug['cell_size']['end'] = self._io.pos() - self._debug['n_dimensions']['start'] = self._io.pos() - self.n_dimensions = self._io.read_u4le() - self._debug['n_dimensions']['end'] = self._io.pos() - self._debug['n_mesurands']['start'] = self._io.pos() - self.n_mesurands = self._io.read_u4le() - self._debug['n_mesurands']['end'] = self._io.pos() - self._debug['dimensions']['start'] = self._io.pos() - self.dimensions = [None] * (self.n_dimensions) - for i in range(self.n_dimensions): - if not 'arr' in self._debug['dimensions']: - self._debug['dimensions']['arr'] = [] - self._debug['dimensions']['arr'].append({'start': self._io.pos()}) - _t_dimensions = NtMdt.Frame.FdMetaData.Calibration(self._io, self, self._root) - _t_dimensions._read() - self.dimensions[i] = _t_dimensions - self._debug['dimensions']['arr'][i]['end'] = self._io.pos() - - self._debug['dimensions']['end'] = self._io.pos() - self._debug['mesurands']['start'] = self._io.pos() - self.mesurands = [None] * (self.n_mesurands) - for i in range(self.n_mesurands): - if not 'arr' in self._debug['mesurands']: - self._debug['mesurands']['arr'] = [] - self._debug['mesurands']['arr'].append({'start': self._io.pos()}) - _t_mesurands = NtMdt.Frame.FdMetaData.Calibration(self._io, self, self._root) - _t_mesurands._read() - self.mesurands[i] = _t_mesurands - self._debug['mesurands']['arr'][i]['end'] = self._io.pos() - - self._debug['mesurands']['end'] = self._io.pos() - - class Image(KaitaiStruct): - SEQ_FIELDS = ["image"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['image']['start'] = self._io.pos() - self.image = [] - i = 0 - while not self._io.is_eof(): - if not 'arr' in self._debug['image']: - self._debug['image']['arr'] = [] - self._debug['image']['arr'].append({'start': self._io.pos()}) - _t_image = NtMdt.Frame.FdMetaData.Image.Vec(self._io, self, self._root) - _t_image._read() - self.image.append(_t_image) - self._debug['image']['arr'][len(self.image) - 1]['end'] = self._io.pos() - i += 1 - - self._debug['image']['end'] = self._io.pos() - - class Vec(KaitaiStruct): - SEQ_FIELDS = ["items"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['items']['start'] = self._io.pos() - self.items = [None] * (self._parent._parent.n_mesurands) - for i in range(self._parent._parent.n_mesurands): - if not 'arr' in self._debug['items']: - self._debug['items']['arr'] = [] - self._debug['items']['arr'].append({'start': self._io.pos()}) - _on = self._parent._parent.mesurands[i].data_type - if _on == NtMdt.DataType.uint64: - if not 'arr' in self._debug['items']: - self._debug['items']['arr'] = [] - self._debug['items']['arr'].append({'start': self._io.pos()}) - self.items[i] = self._io.read_u8le() - self._debug['items']['arr'][i]['end'] = self._io.pos() - elif _on == NtMdt.DataType.uint8: - if not 'arr' in self._debug['items']: - self._debug['items']['arr'] = [] - self._debug['items']['arr'].append({'start': self._io.pos()}) - self.items[i] = self._io.read_u1() - self._debug['items']['arr'][i]['end'] = self._io.pos() - elif _on == NtMdt.DataType.float32: - if not 'arr' in self._debug['items']: - self._debug['items']['arr'] = [] - self._debug['items']['arr'].append({'start': self._io.pos()}) - self.items[i] = self._io.read_f4le() - self._debug['items']['arr'][i]['end'] = self._io.pos() - elif _on == NtMdt.DataType.int8: - if not 'arr' in self._debug['items']: - self._debug['items']['arr'] = [] - self._debug['items']['arr'].append({'start': self._io.pos()}) - self.items[i] = self._io.read_s1() - self._debug['items']['arr'][i]['end'] = self._io.pos() - elif _on == NtMdt.DataType.uint16: - if not 'arr' in self._debug['items']: - self._debug['items']['arr'] = [] - self._debug['items']['arr'].append({'start': self._io.pos()}) - self.items[i] = self._io.read_u2le() - self._debug['items']['arr'][i]['end'] = self._io.pos() - elif _on == NtMdt.DataType.int64: - if not 'arr' in self._debug['items']: - self._debug['items']['arr'] = [] - self._debug['items']['arr'].append({'start': self._io.pos()}) - self.items[i] = self._io.read_s8le() - self._debug['items']['arr'][i]['end'] = self._io.pos() - elif _on == NtMdt.DataType.uint32: - if not 'arr' in self._debug['items']: - self._debug['items']['arr'] = [] - self._debug['items']['arr'].append({'start': self._io.pos()}) - self.items[i] = self._io.read_u4le() - self._debug['items']['arr'][i]['end'] = self._io.pos() - elif _on == NtMdt.DataType.float64: - if not 'arr' in self._debug['items']: - self._debug['items']['arr'] = [] - self._debug['items']['arr'].append({'start': self._io.pos()}) - self.items[i] = self._io.read_f8le() - self._debug['items']['arr'][i]['end'] = self._io.pos() - elif _on == NtMdt.DataType.int16: - if not 'arr' in self._debug['items']: - self._debug['items']['arr'] = [] - self._debug['items']['arr'].append({'start': self._io.pos()}) - self.items[i] = self._io.read_s2le() - self._debug['items']['arr'][i]['end'] = self._io.pos() - elif _on == NtMdt.DataType.int32: - if not 'arr' in self._debug['items']: - self._debug['items']['arr'] = [] - self._debug['items']['arr'].append({'start': self._io.pos()}) - self.items[i] = self._io.read_s4le() - self._debug['items']['arr'][i]['end'] = self._io.pos() - self._debug['items']['arr'][i]['end'] = self._io.pos() - - self._debug['items']['end'] = self._io.pos() - - - - class Calibration(KaitaiStruct): - SEQ_FIELDS = ["len_tot", "len_struct", "len_name", "len_comment", "len_unit", "si_unit", "accuracy", "function_id_and_dimensions", "bias", "scale", "min_index", "max_index", "data_type", "len_author", "name", "comment", "unit", "author"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['len_tot']['start'] = self._io.pos() - self.len_tot = self._io.read_u4le() - self._debug['len_tot']['end'] = self._io.pos() - self._debug['len_struct']['start'] = self._io.pos() - self.len_struct = self._io.read_u4le() - self._debug['len_struct']['end'] = self._io.pos() - self._debug['len_name']['start'] = self._io.pos() - self.len_name = self._io.read_u4le() - self._debug['len_name']['end'] = self._io.pos() - self._debug['len_comment']['start'] = self._io.pos() - self.len_comment = self._io.read_u4le() - self._debug['len_comment']['end'] = self._io.pos() - self._debug['len_unit']['start'] = self._io.pos() - self.len_unit = self._io.read_u4le() - self._debug['len_unit']['end'] = self._io.pos() - self._debug['si_unit']['start'] = self._io.pos() - self.si_unit = self._io.read_u8le() - self._debug['si_unit']['end'] = self._io.pos() - self._debug['accuracy']['start'] = self._io.pos() - self.accuracy = self._io.read_f8le() - self._debug['accuracy']['end'] = self._io.pos() - self._debug['function_id_and_dimensions']['start'] = self._io.pos() - self.function_id_and_dimensions = self._io.read_u8le() - self._debug['function_id_and_dimensions']['end'] = self._io.pos() - self._debug['bias']['start'] = self._io.pos() - self.bias = self._io.read_f8le() - self._debug['bias']['end'] = self._io.pos() - self._debug['scale']['start'] = self._io.pos() - self.scale = self._io.read_f8le() - self._debug['scale']['end'] = self._io.pos() - self._debug['min_index']['start'] = self._io.pos() - self.min_index = self._io.read_u8le() - self._debug['min_index']['end'] = self._io.pos() - self._debug['max_index']['start'] = self._io.pos() - self.max_index = self._io.read_u8le() - self._debug['max_index']['end'] = self._io.pos() - self._debug['data_type']['start'] = self._io.pos() - self.data_type = KaitaiStream.resolve_enum(NtMdt.DataType, self._io.read_s4le()) - self._debug['data_type']['end'] = self._io.pos() - self._debug['len_author']['start'] = self._io.pos() - self.len_author = self._io.read_u4le() - self._debug['len_author']['end'] = self._io.pos() - self._debug['name']['start'] = self._io.pos() - self.name = (self._io.read_bytes(self.len_name)).decode(u"utf-8") - self._debug['name']['end'] = self._io.pos() - self._debug['comment']['start'] = self._io.pos() - self.comment = (self._io.read_bytes(self.len_comment)).decode(u"utf-8") - self._debug['comment']['end'] = self._io.pos() - self._debug['unit']['start'] = self._io.pos() - self.unit = (self._io.read_bytes(self.len_unit)).decode(u"utf-8") - self._debug['unit']['end'] = self._io.pos() - self._debug['author']['start'] = self._io.pos() - self.author = (self._io.read_bytes(self.len_author)).decode(u"utf-8") - self._debug['author']['end'] = self._io.pos() - - @property - def count(self): - if hasattr(self, '_m_count'): - return self._m_count if hasattr(self, '_m_count') else None - - self._m_count = ((self.max_index - self.min_index) + 1) - return self._m_count if hasattr(self, '_m_count') else None - - - @property - def image(self): - if hasattr(self, '_m_image'): - return self._m_image if hasattr(self, '_m_image') else None - - _pos = self._io.pos() - self._io.seek(self.data_offset) - self._debug['_m_image']['start'] = self._io.pos() - self._raw__m_image = self._io.read_bytes(self.data_size) - _io__raw__m_image = KaitaiStream(BytesIO(self._raw__m_image)) - self._m_image = NtMdt.Frame.FdMetaData.Image(_io__raw__m_image, self, self._root) - self._m_image._read() - self._debug['_m_image']['end'] = self._io.pos() - self._io.seek(_pos) - return self._m_image if hasattr(self, '_m_image') else None - - - class FdSpectroscopy(KaitaiStruct): - SEQ_FIELDS = ["vars", "fm_mode", "fm_xres", "fm_yres", "dots", "data", "title", "xml"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['vars']['start'] = self._io.pos() - self._raw_vars = self._io.read_bytes(self._parent.var_size) - _io__raw_vars = KaitaiStream(BytesIO(self._raw_vars)) - self.vars = NtMdt.Frame.FdSpectroscopy.Vars(_io__raw_vars, self, self._root) - self.vars._read() - self._debug['vars']['end'] = self._io.pos() - self._debug['fm_mode']['start'] = self._io.pos() - self.fm_mode = self._io.read_u2le() - self._debug['fm_mode']['end'] = self._io.pos() - self._debug['fm_xres']['start'] = self._io.pos() - self.fm_xres = self._io.read_u2le() - self._debug['fm_xres']['end'] = self._io.pos() - self._debug['fm_yres']['start'] = self._io.pos() - self.fm_yres = self._io.read_u2le() - self._debug['fm_yres']['end'] = self._io.pos() - self._debug['dots']['start'] = self._io.pos() - self.dots = NtMdt.Frame.Dots(self._io, self, self._root) - self.dots._read() - self._debug['dots']['end'] = self._io.pos() - self._debug['data']['start'] = self._io.pos() - self.data = [None] * ((self.fm_xres * self.fm_yres)) - for i in range((self.fm_xres * self.fm_yres)): - if not 'arr' in self._debug['data']: - self._debug['data']['arr'] = [] - self._debug['data']['arr'].append({'start': self._io.pos()}) - self.data[i] = self._io.read_s2le() - self._debug['data']['arr'][i]['end'] = self._io.pos() - - self._debug['data']['end'] = self._io.pos() - self._debug['title']['start'] = self._io.pos() - self.title = NtMdt.Title(self._io, self, self._root) - self.title._read() - self._debug['title']['end'] = self._io.pos() - self._debug['xml']['start'] = self._io.pos() - self.xml = NtMdt.Xml(self._io, self, self._root) - self.xml._read() - self._debug['xml']['end'] = self._io.pos() - - class Vars(KaitaiStruct): - SEQ_FIELDS = ["x_scale", "y_scale", "z_scale", "sp_mode", "sp_filter", "u_begin", "u_end", "z_up", "z_down", "sp_averaging", "sp_repeat", "sp_back", "sp_4nx", "sp_osc", "sp_n4", "sp_4x0", "sp_4xr", "sp_4u", "sp_4i", "sp_nx"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['x_scale']['start'] = self._io.pos() - self.x_scale = NtMdt.Frame.AxisScale(self._io, self, self._root) - self.x_scale._read() - self._debug['x_scale']['end'] = self._io.pos() - self._debug['y_scale']['start'] = self._io.pos() - self.y_scale = NtMdt.Frame.AxisScale(self._io, self, self._root) - self.y_scale._read() - self._debug['y_scale']['end'] = self._io.pos() - self._debug['z_scale']['start'] = self._io.pos() - self.z_scale = NtMdt.Frame.AxisScale(self._io, self, self._root) - self.z_scale._read() - self._debug['z_scale']['end'] = self._io.pos() - self._debug['sp_mode']['start'] = self._io.pos() - self.sp_mode = self._io.read_u2le() - self._debug['sp_mode']['end'] = self._io.pos() - self._debug['sp_filter']['start'] = self._io.pos() - self.sp_filter = self._io.read_u2le() - self._debug['sp_filter']['end'] = self._io.pos() - self._debug['u_begin']['start'] = self._io.pos() - self.u_begin = self._io.read_f4le() - self._debug['u_begin']['end'] = self._io.pos() - self._debug['u_end']['start'] = self._io.pos() - self.u_end = self._io.read_f4le() - self._debug['u_end']['end'] = self._io.pos() - self._debug['z_up']['start'] = self._io.pos() - self.z_up = self._io.read_s2le() - self._debug['z_up']['end'] = self._io.pos() - self._debug['z_down']['start'] = self._io.pos() - self.z_down = self._io.read_s2le() - self._debug['z_down']['end'] = self._io.pos() - self._debug['sp_averaging']['start'] = self._io.pos() - self.sp_averaging = self._io.read_u2le() - self._debug['sp_averaging']['end'] = self._io.pos() - self._debug['sp_repeat']['start'] = self._io.pos() - self.sp_repeat = self._io.read_u1() - self._debug['sp_repeat']['end'] = self._io.pos() - self._debug['sp_back']['start'] = self._io.pos() - self.sp_back = self._io.read_u1() - self._debug['sp_back']['end'] = self._io.pos() - self._debug['sp_4nx']['start'] = self._io.pos() - self.sp_4nx = self._io.read_s2le() - self._debug['sp_4nx']['end'] = self._io.pos() - self._debug['sp_osc']['start'] = self._io.pos() - self.sp_osc = self._io.read_u1() - self._debug['sp_osc']['end'] = self._io.pos() - self._debug['sp_n4']['start'] = self._io.pos() - self.sp_n4 = self._io.read_u1() - self._debug['sp_n4']['end'] = self._io.pos() - self._debug['sp_4x0']['start'] = self._io.pos() - self.sp_4x0 = self._io.read_f4le() - self._debug['sp_4x0']['end'] = self._io.pos() - self._debug['sp_4xr']['start'] = self._io.pos() - self.sp_4xr = self._io.read_f4le() - self._debug['sp_4xr']['end'] = self._io.pos() - self._debug['sp_4u']['start'] = self._io.pos() - self.sp_4u = self._io.read_s2le() - self._debug['sp_4u']['end'] = self._io.pos() - self._debug['sp_4i']['start'] = self._io.pos() - self.sp_4i = self._io.read_s2le() - self._debug['sp_4i']['end'] = self._io.pos() - self._debug['sp_nx']['start'] = self._io.pos() - self.sp_nx = self._io.read_s2le() - self._debug['sp_nx']['end'] = self._io.pos() - - - - class DateTime(KaitaiStruct): - SEQ_FIELDS = ["date", "time"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['date']['start'] = self._io.pos() - self.date = NtMdt.Frame.DateTime.Date(self._io, self, self._root) - self.date._read() - self._debug['date']['end'] = self._io.pos() - self._debug['time']['start'] = self._io.pos() - self.time = NtMdt.Frame.DateTime.Time(self._io, self, self._root) - self.time._read() - self._debug['time']['end'] = self._io.pos() - - class Date(KaitaiStruct): - SEQ_FIELDS = ["year", "month", "day"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['year']['start'] = self._io.pos() - self.year = self._io.read_u2le() - self._debug['year']['end'] = self._io.pos() - self._debug['month']['start'] = self._io.pos() - self.month = self._io.read_u2le() - self._debug['month']['end'] = self._io.pos() - self._debug['day']['start'] = self._io.pos() - self.day = self._io.read_u2le() - self._debug['day']['end'] = self._io.pos() - - - class Time(KaitaiStruct): - SEQ_FIELDS = ["hour", "min", "sec"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['hour']['start'] = self._io.pos() - self.hour = self._io.read_u2le() - self._debug['hour']['end'] = self._io.pos() - self._debug['min']['start'] = self._io.pos() - self.min = self._io.read_u2le() - self._debug['min']['end'] = self._io.pos() - self._debug['sec']['start'] = self._io.pos() - self.sec = self._io.read_u2le() - self._debug['sec']['end'] = self._io.pos() - - - - class AxisScale(KaitaiStruct): - SEQ_FIELDS = ["offset", "step", "unit"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['offset']['start'] = self._io.pos() - self.offset = self._io.read_f4le() - self._debug['offset']['end'] = self._io.pos() - self._debug['step']['start'] = self._io.pos() - self.step = self._io.read_f4le() - self._debug['step']['end'] = self._io.pos() - self._debug['unit']['start'] = self._io.pos() - self.unit = KaitaiStream.resolve_enum(NtMdt.Unit, self._io.read_s2le()) - self._debug['unit']['end'] = self._io.pos() - - - class FdScanned(KaitaiStruct): - - class Mode(Enum): - stm = 0 - afm = 1 - unknown2 = 2 - unknown3 = 3 - unknown4 = 4 - - class InputSignal(Enum): - extension_slot = 0 - bias_v = 1 - ground = 2 - - class LiftMode(Enum): - step = 0 - fine = 1 - slope = 2 - SEQ_FIELDS = ["vars", "orig_format", "tune", "feedback_gain", "dac_scale", "overscan", "fm_mode", "fm_xres", "fm_yres", "dots", "image", "title", "xml"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['vars']['start'] = self._io.pos() - self._raw_vars = self._io.read_bytes(self._parent.var_size) - _io__raw_vars = KaitaiStream(BytesIO(self._raw_vars)) - self.vars = NtMdt.Frame.FdScanned.Vars(_io__raw_vars, self, self._root) - self.vars._read() - self._debug['vars']['end'] = self._io.pos() - if False: - self._debug['orig_format']['start'] = self._io.pos() - self.orig_format = self._io.read_u4le() - self._debug['orig_format']['end'] = self._io.pos() - - if False: - self._debug['tune']['start'] = self._io.pos() - self.tune = KaitaiStream.resolve_enum(NtMdt.Frame.FdScanned.LiftMode, self._io.read_u4le()) - self._debug['tune']['end'] = self._io.pos() - - if False: - self._debug['feedback_gain']['start'] = self._io.pos() - self.feedback_gain = self._io.read_f8le() - self._debug['feedback_gain']['end'] = self._io.pos() - - if False: - self._debug['dac_scale']['start'] = self._io.pos() - self.dac_scale = self._io.read_s4le() - self._debug['dac_scale']['end'] = self._io.pos() - - if False: - self._debug['overscan']['start'] = self._io.pos() - self.overscan = self._io.read_s4le() - self._debug['overscan']['end'] = self._io.pos() - - self._debug['fm_mode']['start'] = self._io.pos() - self.fm_mode = self._io.read_u2le() - self._debug['fm_mode']['end'] = self._io.pos() - self._debug['fm_xres']['start'] = self._io.pos() - self.fm_xres = self._io.read_u2le() - self._debug['fm_xres']['end'] = self._io.pos() - self._debug['fm_yres']['start'] = self._io.pos() - self.fm_yres = self._io.read_u2le() - self._debug['fm_yres']['end'] = self._io.pos() - self._debug['dots']['start'] = self._io.pos() - self.dots = NtMdt.Frame.Dots(self._io, self, self._root) - self.dots._read() - self._debug['dots']['end'] = self._io.pos() - self._debug['image']['start'] = self._io.pos() - self.image = [None] * ((self.fm_xres * self.fm_yres)) - for i in range((self.fm_xres * self.fm_yres)): - if not 'arr' in self._debug['image']: - self._debug['image']['arr'] = [] - self._debug['image']['arr'].append({'start': self._io.pos()}) - self.image[i] = self._io.read_s2le() - self._debug['image']['arr'][i]['end'] = self._io.pos() - - self._debug['image']['end'] = self._io.pos() - self._debug['title']['start'] = self._io.pos() - self.title = NtMdt.Title(self._io, self, self._root) - self.title._read() - self._debug['title']['end'] = self._io.pos() - self._debug['xml']['start'] = self._io.pos() - self.xml = NtMdt.Xml(self._io, self, self._root) - self.xml._read() - self._debug['xml']['end'] = self._io.pos() - - class Vars(KaitaiStruct): - SEQ_FIELDS = ["x_scale", "y_scale", "z_scale", "channel_index", "mode", "xres", "yres", "ndacq", "step_length", "adt", "adc_gain_amp_log10", "adc_index", "input_signal_or_version", "substr_plane_order_or_pass_num", "scan_dir", "power_of_2", "velocity", "setpoint", "bias_voltage", "draw", "reserved", "xoff", "yoff", "nl_corr"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['x_scale']['start'] = self._io.pos() - self.x_scale = NtMdt.Frame.AxisScale(self._io, self, self._root) - self.x_scale._read() - self._debug['x_scale']['end'] = self._io.pos() - self._debug['y_scale']['start'] = self._io.pos() - self.y_scale = NtMdt.Frame.AxisScale(self._io, self, self._root) - self.y_scale._read() - self._debug['y_scale']['end'] = self._io.pos() - self._debug['z_scale']['start'] = self._io.pos() - self.z_scale = NtMdt.Frame.AxisScale(self._io, self, self._root) - self.z_scale._read() - self._debug['z_scale']['end'] = self._io.pos() - self._debug['channel_index']['start'] = self._io.pos() - self.channel_index = KaitaiStream.resolve_enum(NtMdt.AdcMode, self._io.read_u1()) - self._debug['channel_index']['end'] = self._io.pos() - self._debug['mode']['start'] = self._io.pos() - self.mode = KaitaiStream.resolve_enum(NtMdt.Frame.FdScanned.Mode, self._io.read_u1()) - self._debug['mode']['end'] = self._io.pos() - self._debug['xres']['start'] = self._io.pos() - self.xres = self._io.read_u2le() - self._debug['xres']['end'] = self._io.pos() - self._debug['yres']['start'] = self._io.pos() - self.yres = self._io.read_u2le() - self._debug['yres']['end'] = self._io.pos() - self._debug['ndacq']['start'] = self._io.pos() - self.ndacq = self._io.read_u2le() - self._debug['ndacq']['end'] = self._io.pos() - self._debug['step_length']['start'] = self._io.pos() - self.step_length = self._io.read_f4le() - self._debug['step_length']['end'] = self._io.pos() - self._debug['adt']['start'] = self._io.pos() - self.adt = self._io.read_u2le() - self._debug['adt']['end'] = self._io.pos() - self._debug['adc_gain_amp_log10']['start'] = self._io.pos() - self.adc_gain_amp_log10 = self._io.read_u1() - self._debug['adc_gain_amp_log10']['end'] = self._io.pos() - self._debug['adc_index']['start'] = self._io.pos() - self.adc_index = self._io.read_u1() - self._debug['adc_index']['end'] = self._io.pos() - self._debug['input_signal_or_version']['start'] = self._io.pos() - self.input_signal_or_version = self._io.read_u1() - self._debug['input_signal_or_version']['end'] = self._io.pos() - self._debug['substr_plane_order_or_pass_num']['start'] = self._io.pos() - self.substr_plane_order_or_pass_num = self._io.read_u1() - self._debug['substr_plane_order_or_pass_num']['end'] = self._io.pos() - self._debug['scan_dir']['start'] = self._io.pos() - self.scan_dir = NtMdt.Frame.FdScanned.ScanDir(self._io, self, self._root) - self.scan_dir._read() - self._debug['scan_dir']['end'] = self._io.pos() - self._debug['power_of_2']['start'] = self._io.pos() - self.power_of_2 = self._io.read_u1() - self._debug['power_of_2']['end'] = self._io.pos() - self._debug['velocity']['start'] = self._io.pos() - self.velocity = self._io.read_f4le() - self._debug['velocity']['end'] = self._io.pos() - self._debug['setpoint']['start'] = self._io.pos() - self.setpoint = self._io.read_f4le() - self._debug['setpoint']['end'] = self._io.pos() - self._debug['bias_voltage']['start'] = self._io.pos() - self.bias_voltage = self._io.read_f4le() - self._debug['bias_voltage']['end'] = self._io.pos() - self._debug['draw']['start'] = self._io.pos() - self.draw = self._io.read_u1() - self._debug['draw']['end'] = self._io.pos() - self._debug['reserved']['start'] = self._io.pos() - self.reserved = self._io.read_u1() - self._debug['reserved']['end'] = self._io.pos() - self._debug['xoff']['start'] = self._io.pos() - self.xoff = self._io.read_s4le() - self._debug['xoff']['end'] = self._io.pos() - self._debug['yoff']['start'] = self._io.pos() - self.yoff = self._io.read_s4le() - self._debug['yoff']['end'] = self._io.pos() - self._debug['nl_corr']['start'] = self._io.pos() - self.nl_corr = self._io.read_u1() - self._debug['nl_corr']['end'] = self._io.pos() - - - class Dot(KaitaiStruct): - SEQ_FIELDS = ["x", "y"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['x']['start'] = self._io.pos() - self.x = self._io.read_s2le() - self._debug['x']['end'] = self._io.pos() - self._debug['y']['start'] = self._io.pos() - self.y = self._io.read_s2le() - self._debug['y']['end'] = self._io.pos() - - - class ScanDir(KaitaiStruct): - SEQ_FIELDS = ["unkn", "double_pass", "bottom", "left", "horizontal"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['unkn']['start'] = self._io.pos() - self.unkn = self._io.read_bits_int_be(4) - self._debug['unkn']['end'] = self._io.pos() - self._debug['double_pass']['start'] = self._io.pos() - self.double_pass = self._io.read_bits_int_be(1) != 0 - self._debug['double_pass']['end'] = self._io.pos() - self._debug['bottom']['start'] = self._io.pos() - self.bottom = self._io.read_bits_int_be(1) != 0 - self._debug['bottom']['end'] = self._io.pos() - self._debug['left']['start'] = self._io.pos() - self.left = self._io.read_bits_int_be(1) != 0 - self._debug['left']['end'] = self._io.pos() - self._debug['horizontal']['start'] = self._io.pos() - self.horizontal = self._io.read_bits_int_be(1) != 0 - self._debug['horizontal']['end'] = self._io.pos() - - - - - class Version(KaitaiStruct): - SEQ_FIELDS = ["minor", "major"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['minor']['start'] = self._io.pos() - self.minor = self._io.read_u1() - self._debug['minor']['end'] = self._io.pos() - self._debug['major']['start'] = self._io.pos() - self.major = self._io.read_u1() - self._debug['major']['end'] = self._io.pos() - - - class Xml(KaitaiStruct): - SEQ_FIELDS = ["xml_len", "xml"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['xml_len']['start'] = self._io.pos() - self.xml_len = self._io.read_u4le() - self._debug['xml_len']['end'] = self._io.pos() - self._debug['xml']['start'] = self._io.pos() - self.xml = (self._io.read_bytes(self.xml_len)).decode(u"UTF-16LE") - self._debug['xml']['end'] = self._io.pos() - - - class Title(KaitaiStruct): - SEQ_FIELDS = ["title_len", "title"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['title_len']['start'] = self._io.pos() - self.title_len = self._io.read_u4le() - self._debug['title_len']['end'] = self._io.pos() - self._debug['title']['start'] = self._io.pos() - self.title = (self._io.read_bytes(self.title_len)).decode(u"cp1251") - self._debug['title']['end'] = self._io.pos() - - - diff --git a/polyfile/kaitai/parsers/pif.py b/polyfile/kaitai/parsers/pif.py deleted file mode 100644 index d5fb803f..00000000 --- a/polyfile/kaitai/parsers/pif.py +++ /dev/null @@ -1,233 +0,0 @@ -# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild - -from pkg_resources import parse_version -import kaitaistruct -from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO -from enum import Enum -import collections - - -if parse_version(kaitaistruct.__version__) < parse_version('0.9'): - raise Exception("Incompatible Kaitai Struct Python API: 0.9 or later is required, but you have %s" % (kaitaistruct.__version__)) - -class Pif(KaitaiStruct): - """The Portable Image Format (PIF) is a basic, bitmap-like image format with the - focus on ease of use (implementation) and small size for embedded - applications. - - See for more info. - - .. seealso:: - Source - https://github.com/gfcwfzkm/PIF-Image-Format/blob/4ec261b/Specification/PIF%20Format%20Specification.pdf - - - .. seealso:: - Source - https://github.com/gfcwfzkm/PIF-Image-Format/blob/4ec261b/C%20Library/pifdec.c#L300 - """ - - class ImageType(Enum): - rgb332 = 7763 - rgb888 = 17212 - indexed_rgb332 = 18754 - indexed_rgb565 = 18759 - indexed_rgb888 = 18770 - black_white = 32170 - rgb16c = 47253 - rgb565 = 58821 - - class CompressionType(Enum): - none = 0 - rle = 32222 - SEQ_FIELDS = ["file_header", "info_header", "color_table"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['file_header']['start'] = self._io.pos() - self.file_header = Pif.PifHeader(self._io, self, self._root) - self.file_header._read() - self._debug['file_header']['end'] = self._io.pos() - self._debug['info_header']['start'] = self._io.pos() - self.info_header = Pif.InformationHeader(self._io, self, self._root) - self.info_header._read() - self._debug['info_header']['end'] = self._io.pos() - if self.info_header.uses_indexed_mode: - self._debug['color_table']['start'] = self._io.pos() - self._raw_color_table = self._io.read_bytes(self.info_header.len_color_table) - _io__raw_color_table = KaitaiStream(BytesIO(self._raw_color_table)) - self.color_table = Pif.ColorTableData(_io__raw_color_table, self, self._root) - self.color_table._read() - self._debug['color_table']['end'] = self._io.pos() - - - class PifHeader(KaitaiStruct): - SEQ_FIELDS = ["magic", "len_file", "ofs_image_data"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['magic']['start'] = self._io.pos() - self.magic = self._io.read_bytes(4) - self._debug['magic']['end'] = self._io.pos() - if not self.magic == b"\x50\x49\x46\x00": - raise kaitaistruct.ValidationNotEqualError(b"\x50\x49\x46\x00", self.magic, self._io, u"/types/pif_header/seq/0") - self._debug['len_file']['start'] = self._io.pos() - self.len_file = self._io.read_u4le() - self._debug['len_file']['end'] = self._io.pos() - if not self.len_file >= self.ofs_image_data_min: - raise kaitaistruct.ValidationLessThanError(self.ofs_image_data_min, self.len_file, self._io, u"/types/pif_header/seq/1") - self._debug['ofs_image_data']['start'] = self._io.pos() - self.ofs_image_data = self._io.read_u4le() - self._debug['ofs_image_data']['end'] = self._io.pos() - if not self.ofs_image_data >= self.ofs_image_data_min: - raise kaitaistruct.ValidationLessThanError(self.ofs_image_data_min, self.ofs_image_data, self._io, u"/types/pif_header/seq/2") - if not self.ofs_image_data <= self.len_file: - raise kaitaistruct.ValidationGreaterThanError(self.len_file, self.ofs_image_data, self._io, u"/types/pif_header/seq/2") - - @property - def ofs_image_data_min(self): - if hasattr(self, '_m_ofs_image_data_min'): - return self._m_ofs_image_data_min if hasattr(self, '_m_ofs_image_data_min') else None - - self._m_ofs_image_data_min = (12 + 16) - return self._m_ofs_image_data_min if hasattr(self, '_m_ofs_image_data_min') else None - - - class InformationHeader(KaitaiStruct): - SEQ_FIELDS = ["image_type", "bits_per_pixel", "width", "height", "len_image_data", "len_color_table", "compression"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['image_type']['start'] = self._io.pos() - self.image_type = KaitaiStream.resolve_enum(Pif.ImageType, self._io.read_u2le()) - self._debug['image_type']['end'] = self._io.pos() - if not ((self.image_type == Pif.ImageType.rgb888) or (self.image_type == Pif.ImageType.rgb565) or (self.image_type == Pif.ImageType.rgb332) or (self.image_type == Pif.ImageType.rgb16c) or (self.image_type == Pif.ImageType.black_white) or (self.image_type == Pif.ImageType.indexed_rgb888) or (self.image_type == Pif.ImageType.indexed_rgb565) or (self.image_type == Pif.ImageType.indexed_rgb332)) : - raise kaitaistruct.ValidationNotAnyOfError(self.image_type, self._io, u"/types/information_header/seq/0") - self._debug['bits_per_pixel']['start'] = self._io.pos() - self.bits_per_pixel = self._io.read_u2le() - self._debug['bits_per_pixel']['end'] = self._io.pos() - _ = self.bits_per_pixel - if not (_ == 24 if self.image_type == Pif.ImageType.rgb888 else (_ == 16 if self.image_type == Pif.ImageType.rgb565 else (_ == 8 if self.image_type == Pif.ImageType.rgb332 else (_ == 4 if self.image_type == Pif.ImageType.rgb16c else (_ == 1 if self.image_type == Pif.ImageType.black_white else (_ <= 8 if self.uses_indexed_mode else True)))))): - raise kaitaistruct.ValidationExprError(self.bits_per_pixel, self._io, u"/types/information_header/seq/1") - self._debug['width']['start'] = self._io.pos() - self.width = self._io.read_u2le() - self._debug['width']['end'] = self._io.pos() - self._debug['height']['start'] = self._io.pos() - self.height = self._io.read_u2le() - self._debug['height']['end'] = self._io.pos() - self._debug['len_image_data']['start'] = self._io.pos() - self.len_image_data = self._io.read_u4le() - self._debug['len_image_data']['end'] = self._io.pos() - if not self.len_image_data <= (self._root.file_header.len_file - self._root.file_header.ofs_image_data): - raise kaitaistruct.ValidationGreaterThanError((self._root.file_header.len_file - self._root.file_header.ofs_image_data), self.len_image_data, self._io, u"/types/information_header/seq/4") - self._debug['len_color_table']['start'] = self._io.pos() - self.len_color_table = self._io.read_u2le() - self._debug['len_color_table']['end'] = self._io.pos() - if not self.len_color_table >= ((self.len_color_table_entry * 1) if self.uses_indexed_mode else 0): - raise kaitaistruct.ValidationLessThanError(((self.len_color_table_entry * 1) if self.uses_indexed_mode else 0), self.len_color_table, self._io, u"/types/information_header/seq/5") - if not self.len_color_table <= ((self.len_color_table_max if self.len_color_table_max < self.len_color_table_full else self.len_color_table_full) if self.uses_indexed_mode else 0): - raise kaitaistruct.ValidationGreaterThanError(((self.len_color_table_max if self.len_color_table_max < self.len_color_table_full else self.len_color_table_full) if self.uses_indexed_mode else 0), self.len_color_table, self._io, u"/types/information_header/seq/5") - self._debug['compression']['start'] = self._io.pos() - self.compression = KaitaiStream.resolve_enum(Pif.CompressionType, self._io.read_u2le()) - self._debug['compression']['end'] = self._io.pos() - if not ((self.compression == Pif.CompressionType.none) or (self.compression == Pif.CompressionType.rle)) : - raise kaitaistruct.ValidationNotAnyOfError(self.compression, self._io, u"/types/information_header/seq/6") - - @property - def len_color_table_entry(self): - if hasattr(self, '_m_len_color_table_entry'): - return self._m_len_color_table_entry if hasattr(self, '_m_len_color_table_entry') else None - - self._m_len_color_table_entry = (3 if self.image_type == Pif.ImageType.indexed_rgb888 else (2 if self.image_type == Pif.ImageType.indexed_rgb565 else (1 if self.image_type == Pif.ImageType.indexed_rgb332 else 0))) - return self._m_len_color_table_entry if hasattr(self, '_m_len_color_table_entry') else None - - @property - def len_color_table_full(self): - if hasattr(self, '_m_len_color_table_full'): - return self._m_len_color_table_full if hasattr(self, '_m_len_color_table_full') else None - - self._m_len_color_table_full = (self.len_color_table_entry * (1 << self.bits_per_pixel)) - return self._m_len_color_table_full if hasattr(self, '_m_len_color_table_full') else None - - @property - def len_color_table_max(self): - if hasattr(self, '_m_len_color_table_max'): - return self._m_len_color_table_max if hasattr(self, '_m_len_color_table_max') else None - - self._m_len_color_table_max = (self._root.file_header.ofs_image_data - self._root.file_header.ofs_image_data_min) - return self._m_len_color_table_max if hasattr(self, '_m_len_color_table_max') else None - - @property - def uses_indexed_mode(self): - if hasattr(self, '_m_uses_indexed_mode'): - return self._m_uses_indexed_mode if hasattr(self, '_m_uses_indexed_mode') else None - - self._m_uses_indexed_mode = self.len_color_table_entry != 0 - return self._m_uses_indexed_mode if hasattr(self, '_m_uses_indexed_mode') else None - - - class ColorTableData(KaitaiStruct): - SEQ_FIELDS = ["entries"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['entries']['start'] = self._io.pos() - self.entries = [] - i = 0 - while not self._io.is_eof(): - if not 'arr' in self._debug['entries']: - self._debug['entries']['arr'] = [] - self._debug['entries']['arr'].append({'start': self._io.pos()}) - _on = self._root.info_header.image_type - if _on == Pif.ImageType.indexed_rgb888: - if not 'arr' in self._debug['entries']: - self._debug['entries']['arr'] = [] - self._debug['entries']['arr'].append({'start': self._io.pos()}) - self.entries.append(self._io.read_bits_int_le(24)) - self._debug['entries']['arr'][len(self.entries) - 1]['end'] = self._io.pos() - elif _on == Pif.ImageType.indexed_rgb565: - if not 'arr' in self._debug['entries']: - self._debug['entries']['arr'] = [] - self._debug['entries']['arr'].append({'start': self._io.pos()}) - self.entries.append(self._io.read_bits_int_le(16)) - self._debug['entries']['arr'][len(self.entries) - 1]['end'] = self._io.pos() - elif _on == Pif.ImageType.indexed_rgb332: - if not 'arr' in self._debug['entries']: - self._debug['entries']['arr'] = [] - self._debug['entries']['arr'].append({'start': self._io.pos()}) - self.entries.append(self._io.read_bits_int_le(8)) - self._debug['entries']['arr'][len(self.entries) - 1]['end'] = self._io.pos() - self._debug['entries']['arr'][len(self.entries) - 1]['end'] = self._io.pos() - i += 1 - - self._debug['entries']['end'] = self._io.pos() - - - @property - def image_data(self): - if hasattr(self, '_m_image_data'): - return self._m_image_data if hasattr(self, '_m_image_data') else None - - _pos = self._io.pos() - self._io.seek(self.file_header.ofs_image_data) - self._debug['_m_image_data']['start'] = self._io.pos() - self._m_image_data = self._io.read_bytes(self.info_header.len_image_data) - self._debug['_m_image_data']['end'] = self._io.pos() - self._io.seek(_pos) - return self._m_image_data if hasattr(self, '_m_image_data') else None - - diff --git a/polyfile/kaitai/parsers/vdi.py b/polyfile/kaitai/parsers/vdi.py deleted file mode 100644 index 498d124b..00000000 --- a/polyfile/kaitai/parsers/vdi.py +++ /dev/null @@ -1,463 +0,0 @@ -# This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild - -from pkg_resources import parse_version -import kaitaistruct -from kaitaistruct import KaitaiStruct, KaitaiStream, BytesIO -from enum import Enum -import collections - - -if parse_version(kaitaistruct.__version__) < parse_version('0.9'): - raise Exception("Incompatible Kaitai Struct Python API: 0.9 or later is required, but you have %s" % (kaitaistruct.__version__)) - -class Vdi(KaitaiStruct): - """A native VirtualBox file format - - Images for testing can be downloaded from - - * - * - - or you can convert images of other formats. - - .. seealso:: - Source - https://github.com/qemu/qemu/blob/master/block/vdi.c - """ - - class ImageType(Enum): - dynamic = 1 - static = 2 - undo = 3 - diff = 4 - SEQ_FIELDS = ["header"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['header']['start'] = self._io.pos() - self.header = Vdi.Header(self._io, self, self._root) - self.header._read() - self._debug['header']['end'] = self._io.pos() - - class Header(KaitaiStruct): - SEQ_FIELDS = ["text", "signature", "version", "header_size_optional", "header_main"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['text']['start'] = self._io.pos() - self.text = (self._io.read_bytes(64)).decode(u"utf-8") - self._debug['text']['end'] = self._io.pos() - self._debug['signature']['start'] = self._io.pos() - self.signature = self._io.read_bytes(4) - self._debug['signature']['end'] = self._io.pos() - if not self.signature == b"\x7F\x10\xDA\xBE": - raise kaitaistruct.ValidationNotEqualError(b"\x7F\x10\xDA\xBE", self.signature, self._io, u"/types/header/seq/1") - self._debug['version']['start'] = self._io.pos() - self.version = Vdi.Header.Version(self._io, self, self._root) - self.version._read() - self._debug['version']['end'] = self._io.pos() - if self.subheader_size_is_dynamic: - self._debug['header_size_optional']['start'] = self._io.pos() - self.header_size_optional = self._io.read_u4le() - self._debug['header_size_optional']['end'] = self._io.pos() - - self._debug['header_main']['start'] = self._io.pos() - self._raw_header_main = self._io.read_bytes(self.header_size) - _io__raw_header_main = KaitaiStream(BytesIO(self._raw_header_main)) - self.header_main = Vdi.Header.HeaderMain(_io__raw_header_main, self, self._root) - self.header_main._read() - self._debug['header_main']['end'] = self._io.pos() - - class Uuid(KaitaiStruct): - SEQ_FIELDS = ["uuid"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['uuid']['start'] = self._io.pos() - self.uuid = self._io.read_bytes(16) - self._debug['uuid']['end'] = self._io.pos() - - - class Version(KaitaiStruct): - SEQ_FIELDS = ["major", "minor"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['major']['start'] = self._io.pos() - self.major = self._io.read_u2le() - self._debug['major']['end'] = self._io.pos() - self._debug['minor']['start'] = self._io.pos() - self.minor = self._io.read_u2le() - self._debug['minor']['end'] = self._io.pos() - - - class HeaderMain(KaitaiStruct): - SEQ_FIELDS = ["image_type", "image_flags", "description", "blocks_map_offset", "offset_data", "geometry", "reserved1", "disk_size", "block_data_size", "block_metadata_size", "blocks_in_image", "blocks_allocated", "uuid_image", "uuid_last_snap", "uuid_link", "uuid_parent", "lchc_geometry"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['image_type']['start'] = self._io.pos() - self.image_type = KaitaiStream.resolve_enum(Vdi.ImageType, self._io.read_u4le()) - self._debug['image_type']['end'] = self._io.pos() - self._debug['image_flags']['start'] = self._io.pos() - self.image_flags = Vdi.Header.HeaderMain.Flags(self._io, self, self._root) - self.image_flags._read() - self._debug['image_flags']['end'] = self._io.pos() - self._debug['description']['start'] = self._io.pos() - self.description = (self._io.read_bytes(256)).decode(u"utf-8") - self._debug['description']['end'] = self._io.pos() - if self._parent.version.major >= 1: - self._debug['blocks_map_offset']['start'] = self._io.pos() - self.blocks_map_offset = self._io.read_u4le() - self._debug['blocks_map_offset']['end'] = self._io.pos() - - if self._parent.version.major >= 1: - self._debug['offset_data']['start'] = self._io.pos() - self.offset_data = self._io.read_u4le() - self._debug['offset_data']['end'] = self._io.pos() - - self._debug['geometry']['start'] = self._io.pos() - self.geometry = Vdi.Header.HeaderMain.Geometry(self._io, self, self._root) - self.geometry._read() - self._debug['geometry']['end'] = self._io.pos() - if self._parent.version.major >= 1: - self._debug['reserved1']['start'] = self._io.pos() - self.reserved1 = self._io.read_u4le() - self._debug['reserved1']['end'] = self._io.pos() - - self._debug['disk_size']['start'] = self._io.pos() - self.disk_size = self._io.read_u8le() - self._debug['disk_size']['end'] = self._io.pos() - self._debug['block_data_size']['start'] = self._io.pos() - self.block_data_size = self._io.read_u4le() - self._debug['block_data_size']['end'] = self._io.pos() - if self._parent.version.major >= 1: - self._debug['block_metadata_size']['start'] = self._io.pos() - self.block_metadata_size = self._io.read_u4le() - self._debug['block_metadata_size']['end'] = self._io.pos() - - self._debug['blocks_in_image']['start'] = self._io.pos() - self.blocks_in_image = self._io.read_u4le() - self._debug['blocks_in_image']['end'] = self._io.pos() - self._debug['blocks_allocated']['start'] = self._io.pos() - self.blocks_allocated = self._io.read_u4le() - self._debug['blocks_allocated']['end'] = self._io.pos() - self._debug['uuid_image']['start'] = self._io.pos() - self.uuid_image = Vdi.Header.Uuid(self._io, self, self._root) - self.uuid_image._read() - self._debug['uuid_image']['end'] = self._io.pos() - self._debug['uuid_last_snap']['start'] = self._io.pos() - self.uuid_last_snap = Vdi.Header.Uuid(self._io, self, self._root) - self.uuid_last_snap._read() - self._debug['uuid_last_snap']['end'] = self._io.pos() - self._debug['uuid_link']['start'] = self._io.pos() - self.uuid_link = Vdi.Header.Uuid(self._io, self, self._root) - self.uuid_link._read() - self._debug['uuid_link']['end'] = self._io.pos() - if self._parent.version.major >= 1: - self._debug['uuid_parent']['start'] = self._io.pos() - self.uuid_parent = Vdi.Header.Uuid(self._io, self, self._root) - self.uuid_parent._read() - self._debug['uuid_parent']['end'] = self._io.pos() - - if ((self._parent.version.major >= 1) and ((self._io.pos() + 16) <= self._io.size())) : - self._debug['lchc_geometry']['start'] = self._io.pos() - self.lchc_geometry = Vdi.Header.HeaderMain.Geometry(self._io, self, self._root) - self.lchc_geometry._read() - self._debug['lchc_geometry']['end'] = self._io.pos() - - - class Geometry(KaitaiStruct): - SEQ_FIELDS = ["cylinders", "heads", "sectors", "sector_size"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['cylinders']['start'] = self._io.pos() - self.cylinders = self._io.read_u4le() - self._debug['cylinders']['end'] = self._io.pos() - self._debug['heads']['start'] = self._io.pos() - self.heads = self._io.read_u4le() - self._debug['heads']['end'] = self._io.pos() - self._debug['sectors']['start'] = self._io.pos() - self.sectors = self._io.read_u4le() - self._debug['sectors']['end'] = self._io.pos() - self._debug['sector_size']['start'] = self._io.pos() - self.sector_size = self._io.read_u4le() - self._debug['sector_size']['end'] = self._io.pos() - - - class Flags(KaitaiStruct): - SEQ_FIELDS = ["reserved0", "zero_expand", "reserved1", "diff", "fixed", "reserved2"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['reserved0']['start'] = self._io.pos() - self.reserved0 = self._io.read_bits_int_be(15) - self._debug['reserved0']['end'] = self._io.pos() - self._debug['zero_expand']['start'] = self._io.pos() - self.zero_expand = self._io.read_bits_int_be(1) != 0 - self._debug['zero_expand']['end'] = self._io.pos() - self._debug['reserved1']['start'] = self._io.pos() - self.reserved1 = self._io.read_bits_int_be(6) - self._debug['reserved1']['end'] = self._io.pos() - self._debug['diff']['start'] = self._io.pos() - self.diff = self._io.read_bits_int_be(1) != 0 - self._debug['diff']['end'] = self._io.pos() - self._debug['fixed']['start'] = self._io.pos() - self.fixed = self._io.read_bits_int_be(1) != 0 - self._debug['fixed']['end'] = self._io.pos() - self._debug['reserved2']['start'] = self._io.pos() - self.reserved2 = self._io.read_bits_int_be(8) - self._debug['reserved2']['end'] = self._io.pos() - - - - @property - def header_size(self): - if hasattr(self, '_m_header_size'): - return self._m_header_size if hasattr(self, '_m_header_size') else None - - self._m_header_size = (self.header_size_optional if self.subheader_size_is_dynamic else 336) - return self._m_header_size if hasattr(self, '_m_header_size') else None - - @property - def blocks_map_offset(self): - if hasattr(self, '_m_blocks_map_offset'): - return self._m_blocks_map_offset if hasattr(self, '_m_blocks_map_offset') else None - - self._m_blocks_map_offset = self.header_main.blocks_map_offset - return self._m_blocks_map_offset if hasattr(self, '_m_blocks_map_offset') else None - - @property - def subheader_size_is_dynamic(self): - if hasattr(self, '_m_subheader_size_is_dynamic'): - return self._m_subheader_size_is_dynamic if hasattr(self, '_m_subheader_size_is_dynamic') else None - - self._m_subheader_size_is_dynamic = self.version.major >= 1 - return self._m_subheader_size_is_dynamic if hasattr(self, '_m_subheader_size_is_dynamic') else None - - @property - def blocks_offset(self): - if hasattr(self, '_m_blocks_offset'): - return self._m_blocks_offset if hasattr(self, '_m_blocks_offset') else None - - self._m_blocks_offset = self.header_main.offset_data - return self._m_blocks_offset if hasattr(self, '_m_blocks_offset') else None - - @property - def block_size(self): - if hasattr(self, '_m_block_size'): - return self._m_block_size if hasattr(self, '_m_block_size') else None - - self._m_block_size = (self.header_main.block_metadata_size + self.header_main.block_data_size) - return self._m_block_size if hasattr(self, '_m_block_size') else None - - @property - def blocks_map_size(self): - if hasattr(self, '_m_blocks_map_size'): - return self._m_blocks_map_size if hasattr(self, '_m_blocks_map_size') else None - - self._m_blocks_map_size = ((((self.header_main.blocks_in_image * 4) + self.header_main.geometry.sector_size) - 1) // self.header_main.geometry.sector_size * self.header_main.geometry.sector_size) - return self._m_blocks_map_size if hasattr(self, '_m_blocks_map_size') else None - - - class BlocksMap(KaitaiStruct): - SEQ_FIELDS = ["index"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['index']['start'] = self._io.pos() - self.index = [None] * (self._root.header.header_main.blocks_in_image) - for i in range(self._root.header.header_main.blocks_in_image): - if not 'arr' in self._debug['index']: - self._debug['index']['arr'] = [] - self._debug['index']['arr'].append({'start': self._io.pos()}) - _t_index = Vdi.BlocksMap.BlockIndex(self._io, self, self._root) - _t_index._read() - self.index[i] = _t_index - self._debug['index']['arr'][i]['end'] = self._io.pos() - - self._debug['index']['end'] = self._io.pos() - - class BlockIndex(KaitaiStruct): - SEQ_FIELDS = ["index"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['index']['start'] = self._io.pos() - self.index = self._io.read_u4le() - self._debug['index']['end'] = self._io.pos() - - @property - def is_allocated(self): - if hasattr(self, '_m_is_allocated'): - return self._m_is_allocated if hasattr(self, '_m_is_allocated') else None - - self._m_is_allocated = self.index < self._root.block_discarded - return self._m_is_allocated if hasattr(self, '_m_is_allocated') else None - - @property - def block(self): - if hasattr(self, '_m_block'): - return self._m_block if hasattr(self, '_m_block') else None - - if self.is_allocated: - self._m_block = self._root.disk.blocks[self.index] - - return self._m_block if hasattr(self, '_m_block') else None - - - - class Disk(KaitaiStruct): - SEQ_FIELDS = ["blocks"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['blocks']['start'] = self._io.pos() - self.blocks = [None] * (self._root.header.header_main.blocks_in_image) - for i in range(self._root.header.header_main.blocks_in_image): - if not 'arr' in self._debug['blocks']: - self._debug['blocks']['arr'] = [] - self._debug['blocks']['arr'].append({'start': self._io.pos()}) - _t_blocks = Vdi.Disk.Block(self._io, self, self._root) - _t_blocks._read() - self.blocks[i] = _t_blocks - self._debug['blocks']['arr'][i]['end'] = self._io.pos() - - self._debug['blocks']['end'] = self._io.pos() - - class Block(KaitaiStruct): - SEQ_FIELDS = ["metadata", "data"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['metadata']['start'] = self._io.pos() - self.metadata = self._io.read_bytes(self._root.header.header_main.block_metadata_size) - self._debug['metadata']['end'] = self._io.pos() - self._debug['data']['start'] = self._io.pos() - self._raw_data = [] - self.data = [] - i = 0 - while not self._io.is_eof(): - if not 'arr' in self._debug['data']: - self._debug['data']['arr'] = [] - self._debug['data']['arr'].append({'start': self._io.pos()}) - self._raw_data.append(self._io.read_bytes(self._root.header.header_main.block_data_size)) - _io__raw_data = KaitaiStream(BytesIO(self._raw_data[-1])) - _t_data = Vdi.Disk.Block.Sector(_io__raw_data, self, self._root) - _t_data._read() - self.data.append(_t_data) - self._debug['data']['arr'][len(self.data) - 1]['end'] = self._io.pos() - i += 1 - - self._debug['data']['end'] = self._io.pos() - - class Sector(KaitaiStruct): - SEQ_FIELDS = ["data"] - def __init__(self, _io, _parent=None, _root=None): - self._io = _io - self._parent = _parent - self._root = _root if _root else self - self._debug = collections.defaultdict(dict) - - def _read(self): - self._debug['data']['start'] = self._io.pos() - self.data = self._io.read_bytes(self._root.header.header_main.geometry.sector_size) - self._debug['data']['end'] = self._io.pos() - - - - - @property - def block_discarded(self): - if hasattr(self, '_m_block_discarded'): - return self._m_block_discarded if hasattr(self, '_m_block_discarded') else None - - self._m_block_discarded = 4294967294 - return self._m_block_discarded if hasattr(self, '_m_block_discarded') else None - - @property - def block_unallocated(self): - if hasattr(self, '_m_block_unallocated'): - return self._m_block_unallocated if hasattr(self, '_m_block_unallocated') else None - - self._m_block_unallocated = 4294967295 - return self._m_block_unallocated if hasattr(self, '_m_block_unallocated') else None - - @property - def blocks_map(self): - """block_index = offset_in_virtual_disk / block_size actual_data_offset = blocks_map[block_index]*block_size+metadata_size+offset_in_block - The blocks_map will take up blocks_in_image_max * sizeof(uint32_t) bytes; since the blocks_map is read and written in a single operation, its size needs to be limited to INT_MAX; furthermore, when opening an image, the blocks_map size is rounded up to be aligned on BDRV_SECTOR_SIZE. Therefore this should satisfy the following: blocks_in_image_max * sizeof(uint32_t) + BDRV_SECTOR_SIZE == INT_MAX + 1 (INT_MAX + 1 is the first value not representable as an int) This guarantees that any value below or equal to the constant will, when multiplied by sizeof(uint32_t) and rounded up to a BDRV_SECTOR_SIZE boundary, still be below or equal to INT_MAX. - """ - if hasattr(self, '_m_blocks_map'): - return self._m_blocks_map if hasattr(self, '_m_blocks_map') else None - - _pos = self._io.pos() - self._io.seek(self.header.blocks_map_offset) - self._debug['_m_blocks_map']['start'] = self._io.pos() - self._raw__m_blocks_map = self._io.read_bytes(self.header.blocks_map_size) - _io__raw__m_blocks_map = KaitaiStream(BytesIO(self._raw__m_blocks_map)) - self._m_blocks_map = Vdi.BlocksMap(_io__raw__m_blocks_map, self, self._root) - self._m_blocks_map._read() - self._debug['_m_blocks_map']['end'] = self._io.pos() - self._io.seek(_pos) - return self._m_blocks_map if hasattr(self, '_m_blocks_map') else None - - @property - def disk(self): - if hasattr(self, '_m_disk'): - return self._m_disk if hasattr(self, '_m_disk') else None - - _pos = self._io.pos() - self._io.seek(self.header.blocks_offset) - self._debug['_m_disk']['start'] = self._io.pos() - self._m_disk = Vdi.Disk(self._io, self, self._root) - self._m_disk._read() - self._debug['_m_disk']['end'] = self._io.pos() - self._io.seek(_pos) - return self._m_disk if hasattr(self, '_m_disk') else None - - From 70018a70037166df3a8e11d22b63a24170155a4c Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Wed, 23 Jul 2025 22:09:03 -0700 Subject: [PATCH 02/15] move rebuild after deps --- setup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 84782789..401146a6 100644 --- a/setup.py +++ b/setup.py @@ -8,8 +8,6 @@ POLYFILE_DIR: Path = Path(__file__).absolute().parent README_PATH: Path = POLYFILE_DIR / "README.md" -compile_kaitai_parsers.rebuild() - with open(README_PATH, "r", encoding="utf8") as readme: README = readme.read() @@ -66,3 +64,6 @@ 'Topic :: Utilities' ] ) + +compile_kaitai_parsers.rebuild() + From 024f2fdbdccd954aaca56fad1865828d9f3db65f Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Wed, 23 Jul 2025 22:14:22 -0700 Subject: [PATCH 03/15] allow pyyaml to be installed before setuptools runs --- pyproject.toml | 3 +++ setup.py | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..e558a810 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools>=65.5.1", "pyyaml>=3.13"] +build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/setup.py b/setup.py index 401146a6..84782789 100644 --- a/setup.py +++ b/setup.py @@ -8,6 +8,8 @@ POLYFILE_DIR: Path = Path(__file__).absolute().parent README_PATH: Path = POLYFILE_DIR / "README.md" +compile_kaitai_parsers.rebuild() + with open(README_PATH, "r", encoding="utf8") as readme: README = readme.read() @@ -64,6 +66,3 @@ 'Topic :: Utilities' ] ) - -compile_kaitai_parsers.rebuild() - From 16b5d803e3a10a1c35fce4d4fdcfe253f26eb910 Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Wed, 23 Jul 2025 22:20:14 -0700 Subject: [PATCH 04/15] fix build --- setup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.py b/setup.py index 84782789..88c98b99 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,10 @@ import os +import sys from pathlib import Path from setuptools import setup, find_packages +# Add the current directory to the Python path so we can import compile_kaitai_parsers +sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) import compile_kaitai_parsers From af57a550457e971267feb01aed3e30b7d789936f Mon Sep 17 00:00:00 2001 From: Evan Sultanik Date: Fri, 25 Jul 2025 12:21:40 -0400 Subject: [PATCH 05/15] Update compile_kaitai_parsers.py --- compile_kaitai_parsers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compile_kaitai_parsers.py b/compile_kaitai_parsers.py index b3d9f329..6504b390 100644 --- a/compile_kaitai_parsers.py +++ b/compile_kaitai_parsers.py @@ -21,7 +21,7 @@ MANIFEST_PATH: Path = KAITAI_PARSERS_DIR / "manifest.json" -def find_files_with_excluded_licenses(directory, license_list) -> list[str]: +def find_files_with_excluded_licenses(directory, license_list) -> List[str]: """ Recursively scans a directory for files and identifies any that contain a license from the excluded list. From 481a965fe1fbb46f409971040546ce410bcace34 Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Fri, 25 Jul 2025 13:37:09 -0700 Subject: [PATCH 06/15] change name to publish --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 88c98b99..df809a76 100644 --- a/setup.py +++ b/setup.py @@ -17,11 +17,11 @@ README = readme.read() setup( - name='polyfile', + name='polyfile-weave', description='A utility to recursively map the structure of a file.', long_description=README, long_description_content_type="text/markdown", - url='https://github.com/trailofbits/polyfile', + url='https://github.com/zbirenbaum/polyfile-weave', author='Trail of Bits', version="0.5.5", packages=find_packages(exclude=("tests",)), From 9bbb050c491ac6b7e1719a2dede3d27750e3aa21 Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Fri, 25 Jul 2025 13:39:37 -0700 Subject: [PATCH 07/15] update pythonpublish --- .github/workflows/pythonpublish.yml | 49 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index 05bccb58..f6bee698 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -1,33 +1,30 @@ -# This workflows will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries - -name: Upload Python Package +name: Upload Python Package to PyPI when a Release is Created on: release: - types: [published] + types: [created] jobs: - deploy: - + pypi-publish: + name: Publish release to PyPI runs-on: ubuntu-latest - + environment: + name: pypi + url: https://pypi.org/p/polyfile-weave + permissions: + id-token: write steps: - - uses: actions/checkout@v4.2.2 - with: - submodules: recursive - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python setup.py sdist bdist_wheel - twine upload dist/* + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel + - name: Build package + run: | + python setup.py sdist bdist_wheel # Could also be python -m build + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 From 55e3b94a7068041ade69a299cbfd06b444ad7aee Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Fri, 25 Jul 2025 13:47:59 -0700 Subject: [PATCH 08/15] add pyyaml --- .github/workflows/pythonpublish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index f6bee698..842abbd3 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -22,7 +22,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel + pip install setuptools wheel pyyaml - name: Build package run: | python setup.py sdist bdist_wheel # Could also be python -m build From d549dba1b68fc8e8650ad084f4156bfa157e5643 Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Fri, 25 Jul 2025 13:50:36 -0700 Subject: [PATCH 09/15] revert package name change --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index df809a76..ba220803 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ README = readme.read() setup( - name='polyfile-weave', + name='polyfile', description='A utility to recursively map the structure of a file.', long_description=README, long_description_content_type="text/markdown", From 1e0b33b01a853dc6d3c068abb2e224b8d8c0c58e Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Fri, 25 Jul 2025 13:59:07 -0700 Subject: [PATCH 10/15] remove yaml dep --- .github/workflows/pythonpublish.yml | 4 +- compile_kaitai_parsers.py | 60 ++++------------------------- 2 files changed, 10 insertions(+), 54 deletions(-) diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index 842abbd3..90a4f2d8 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest environment: name: pypi - url: https://pypi.org/p/polyfile-weave + url: https://pypi.org/project/polyfile-weave permissions: id-token: write steps: @@ -22,7 +22,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel pyyaml + pip install setuptools wheel - name: Build package run: | python setup.py sdist bdist_wheel # Could also be python -m build diff --git a/compile_kaitai_parsers.py b/compile_kaitai_parsers.py index 6504b390..4f9eff1b 100644 --- a/compile_kaitai_parsers.py +++ b/compile_kaitai_parsers.py @@ -6,60 +6,21 @@ import subprocess import sys from typing import Any, Dict, List, Optional, Tuple -import os -import glob -import yaml - -# Copyleft Licenses to exclude -EXCLUDE_LICENSES = ['AGPL', 'EUPL', 'GPL', 'LGPL', 'OSL', 'ODbL', 'Ms-RL', 'GFDL'] - POLYFILE_DIR: Path = Path(__file__).absolute().parent COMPILE_SCRIPT: Path = POLYFILE_DIR / "polyfile" / "kaitai" / "compiler.py" KAITAI_FORMAT_LIBRARY: Path = POLYFILE_DIR / "kaitai_struct_formats" KAITAI_PARSERS_DIR: Path = POLYFILE_DIR / "polyfile" / "kaitai" / "parsers" MANIFEST_PATH: Path = KAITAI_PARSERS_DIR / "manifest.json" +EXCLUDE = [ + './kaitai_struct_formats/firmware/broadcom_trx.ksy', + './kaitai_struct_formats/filesystem/vdi.ksy', + './kaitai_struct_formats/filesystem/lvm2.ksy', + './kaitai_struct_formats/image/pif.ksy', + './kaitai_struct_formats/scientific/nt_mdt/nt_mdt.ksy' +] -def find_files_with_excluded_licenses(directory, license_list) -> List[str]: - """ - Recursively scans a directory for files and identifies any that contain - a license from the excluded list. - - The check is performed as a substring match (e.g., 'GPL' in the list - will match a license named 'GPL-3.0-or-later'). - """ - # Create the recursive search pattern - search_path = os.path.join(directory, '**', f'*.ksy') - file_paths = glob.glob(search_path, recursive=True) - - if not file_paths: - return [] - - flagged_files = [] - - for file_path in file_paths: - try: - with open(file_path, 'r', encoding='utf-8') as f: - data = yaml.safe_load(f) - if data and isinstance(data, dict): - license_val = data.get('meta', {}).get('license') - if not license_val: - continue - - # Check if any part of the license name is in our exclude list - for excluded_license in license_list: - if excluded_license in license_val: - flagged_files.append(file_path) - break # Found a match, no need to check other excluded licenses for this file - - except yaml.YAMLError as e: - print(f"❌ Error parsing YAML in file '{file_path}': {e}") - except Exception as e: - print(f"❌ An unexpected error occurred with file '{file_path}': {e}") - - return flagged_files - # Make sure the ktaitai_struct_formats submodlue is cloned: if not (KAITAI_FORMAT_LIBRARY / "README.md").exists(): @@ -96,12 +57,7 @@ def mtime(path: Path) -> datetime: def rebuild(force: bool = False): # Get the list of copyleft-licensed files to exclude - - excluded_files = find_files_with_excluded_licenses( - KAITAI_FORMAT_LIBRARY, - EXCLUDE_LICENSES - ) - excluded_paths = {Path(f).absolute() for f in excluded_files} + excluded_paths = {Path(f).absolute() for f in EXCLUDE} # Remove the manifest file to force a rebuild: if force or not MANIFEST_PATH.exists(): From 0ceec264d460023571cb73e3f9c81d04811bdfbb Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Fri, 25 Jul 2025 14:02:34 -0700 Subject: [PATCH 11/15] update setuptools version --- pyproject.toml | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e558a810..b533dfe0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["setuptools>=65.5.1", "pyyaml>=3.13"] -build-backend = "setuptools.build_meta" \ No newline at end of file +requires = ["setuptools>=70.0.0"] +build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index ba220803..d2014324 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ "Pillow>=5.0.0", "pyreadline3;platform_system=='Windows'", "pyyaml>=3.13", - "setuptools>=65.5.1" + "setuptools>=70.0.0" ], extras_require={ 'demangle': ['cxxfilt'], From 2e381d8360c99130eeb4fbdd6f8aeaef19d40426 Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Fri, 25 Jul 2025 14:06:12 -0700 Subject: [PATCH 12/15] update again --- pyproject.toml | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index b533dfe0..962f3110 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,3 @@ [build-system] -requires = ["setuptools>=70.0.0"] +requires = ["setuptools>=78.1.1"] build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py index d2014324..61f7217a 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ "Pillow>=5.0.0", "pyreadline3;platform_system=='Windows'", "pyyaml>=3.13", - "setuptools>=70.0.0" + "setuptools>=78.1.1" ], extras_require={ 'demangle': ['cxxfilt'], From d113558494a6d533bc52ddd9c24b3fbdd630a5cc Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Fri, 25 Jul 2025 14:08:15 -0700 Subject: [PATCH 13/15] remove 3.8 support --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index eafbf364..623bf78e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: os: [ubuntu-latest] # windows-latest, macos-latest, - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12"] runs-on: ${{ matrix.os }} From bce3d9f7ebbe7fabfb18b9e5360e75b015306a2a Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Fri, 25 Jul 2025 14:11:38 -0700 Subject: [PATCH 14/15] change pypi name --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 61f7217a..abefa93a 100644 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ README = readme.read() setup( - name='polyfile', + name='polyfile-weave', description='A utility to recursively map the structure of a file.', long_description=README, long_description_content_type="text/markdown", @@ -51,7 +51,7 @@ 'polyfile = polyfile.__main__:main' ] }, - package_data={"polyfile": [ + package_data={"polyfile-weave": [ os.path.join("templates", "*"), os.path.join("kaitai", "parsers", "*.py"), os.path.join("kaitai", "parsers", "manifest.json"), From 838036b5947427e079f7073d8c5dc7c426b325e0 Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Fri, 25 Jul 2025 14:16:30 -0700 Subject: [PATCH 15/15] rename --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index abefa93a..80c58c0b 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ "Pillow>=5.0.0", "pyreadline3;platform_system=='Windows'", "pyyaml>=3.13", - "setuptools>=78.1.1" + "setuptools>=80.9.0" ], extras_require={ 'demangle': ['cxxfilt'], @@ -51,7 +51,7 @@ 'polyfile = polyfile.__main__:main' ] }, - package_data={"polyfile-weave": [ + package_data={"polyfile": [ os.path.join("templates", "*"), os.path.join("kaitai", "parsers", "*.py"), os.path.join("kaitai", "parsers", "manifest.json"),