Module pychrysalide.plugins.kaitai.parsers
Class KaitaiAttribute
Class KaitaiEnum
Class KaitaiInstance
Class KaitaiMeta
Class KaitaiStruct
Class KaitaiType
Module pychrysalide.plugins.kaitai.parsers
Documentation
This module provides implementation for several Kaitai definitions parsers.
Classes
Class KaitaiAttribute
KaitaiAttribute is the class providing support for parsing binary contents using a special declarative language.
Instances can be created using the following constructor:
KaitaiAttribute(parent)
Where parent
is a YamlNode
instance pointing to Yaml data to load.
The class is the Python bindings for a C implementation of the Attribute structure described at https://doc.kaitai.io/ksy_diagram.html.
Hierarchy
builtins.object ╰── gi._gi.GObject ╰── pychrysalide.plugins.kaitai.KaitaiParser ╰── pychrysalide.plugins.kaitai.parsers.KaitaiAttribute
Known subclass: pychrysalide.plugins.kaitai.parsers.KaitaiInstance
Attributes
doc
Optional documentation for the attribute.
The returned value is a string or None
.
handle_signed_integer
Sign of the carried integer value, if any: positive or negative?
This status is provided as a boolean value.
original_id
Optional alternative identifier for the attribute, as seen in the original specifications.
The returned value is a string or None
.
raw_id
Raw value used by Kaitai to identify one attribute among others.
The returned indentifier is a string value.
Class KaitaiEnum
The KaitaiEnum class maps integer constants to symbolic names using Kaitai definitions.
Instances can be created using the following constructor:
KaitaiEnum(parent)
Where parent
is a YamlNode
instance pointing to Yaml data to load.
The class is the Python bindings for a C implementation of the EnumSpec structure described at https://doc.kaitai.io/ksy_diagram.html.
Hierarchy
builtins.object ╰── gi._gi.GObject ╰── pychrysalide.plugins.kaitai.parsers.KaitaiEnum
Methods
find_documentation(self, value)
Provide the optional documentation linked to a constant value within the current enumeration.
The value
is a simple integer.
The result is a string or None
if no documentation is registered for the provided value.
find_label(self, value, prefix=False)
Provide the label linked to a constant value within the current enumeration.
The value
is a simple integer, and prefix
is a boolean indicating if the result has to integrate the enumeration name as a prefix.
The result is a string or None
in case of resolution failure.
find_value(self, label)
Translate a given enumeration label into its relative value.
The label
argument is expected to be a string.
The result is an integer or None
in case of resolution failure.
Attributes
name
Name of the enumeration group, as a string value.
Class KaitaiInstance
KaitaiInstance is the class providing support for Kaitai computed values.
Instances can be created using the following constructor:
KaitaiInstance(parent)
Where parent
is a YamlNode
instance pointing to Yaml data to load.
The class is the Python bindings for a C implementation of the Instance structure described at https://doc.kaitai.io/ksy_diagram.html.
Hierarchy
builtins.object ╰── gi._gi.GObject ╰── pychrysalide.plugins.kaitai.KaitaiParser ╰── pychrysalide.plugins.kaitai.parsers.KaitaiAttribute ╰── pychrysalide.plugins.kaitai.parsers.KaitaiInstance
Attributes
name
Name used by Kaitai to identify the instance among others.
The returned indentifier is a string value.
Class KaitaiMeta
The KaitaiMeta class stores general information about a Kaitai definition, such as required imports or the default endianness for reading values.
Instances can be created using the following constructor:
KaitaiMeta(parent)
Where parent
is a YamlNode
instance pointing to Yaml data to load.
The class is the Python bindings for a C implementation of the MetaSpec structure described at https://doc.kaitai.io/ksy_diagram.html.
Hierarchy
builtins.object ╰── gi._gi.GObject ╰── pychrysalide.plugins.kaitai.parsers.KaitaiMeta
Attributes
endian
Default endianness for the Kaitai definition, as a SourceEndian
value.
id
Identifier for the Kaitai definition, as a string value or None
if any.
title
Humain description for the Kaitai definition, as a string value or None
if any.
Class KaitaiStruct
KaitaiStruct is the class providing support for parsing binary contents using a special declarative language.
Instances can be created using one of the following constructors:
KaitaiStruct(text=str)
KaitaiStruct(filename=str)
Where text
is a string containg a markup content to parse; the filename
argument is an alternative string for a path pointing to the same kind of content. This path can be a real filename or a resource URI.
It is the Python bindings for a C implementation of the specifications described at http://kaitai.io/.
Hierarchy
builtins.object ╰── gi._gi.GObject ╰── pychrysalide.plugins.kaitai.KaitaiParser ╰── pychrysalide.plugins.kaitai.parsers.KaitaiStruct
Known subclass: pychrysalide.plugins.kaitai.parsers.KaitaiType
Methods
parse(self, content)
Parse a binary content with the loaded specifications.
The content has to be a BinContent
instance.
The result is None
if the parsing failed, or a MatchRecord
object for each attribute met.
Attributes
meta
Global description provided for the Kaitai definition, as a KaitaiMeta
instance.
Class KaitaiType
The KaitaiType class provides support for user-defined type used in Kaitai definitions.
Instances can be created using the following constructor:
KaitaiType(parent)
Where parent
is a YamlNode
instance pointing to Yaml data to load.
The class is the Python bindings for a C implementation of the TypesSpec structure described at https://doc.kaitai.io/ksy_diagram.html.
Hierarchy
builtins.object ╰── gi._gi.GObject ╰── pychrysalide.plugins.kaitai.KaitaiParser ╰── pychrysalide.plugins.kaitai.parsers.KaitaiStruct ╰── pychrysalide.plugins.kaitai.parsers.KaitaiType
Attributes
name
Name of the user-defined type, provided as a unique string value.