dtfabric package

Subpackages

Submodules

dtfabric.data_types module

Data type definitions.

class dtfabric.data_types.BooleanDefinition(name: str, aliases: Optional[List[str]] = None, description: Optional[str] = None, false_value: int = 0, urls: Optional[List[str]] = None)[source]

Bases: FixedSizeDataTypeDefinition

Boolean data type definition.

false_value

value of False, None represents any value except that defined by true_value.

Type

int

true_value

value of True, None represents any value except that defined by false_value.

Type

int

TYPE_INDICATOR: Optional[str] = 'boolean'
class dtfabric.data_types.CharacterDefinition(name: str, aliases: Optional[List[str]] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: FixedSizeDataTypeDefinition

Character data type definition.

TYPE_INDICATOR: Optional[str] = 'character'
class dtfabric.data_types.ConstantDefinition(name: str, aliases: Optional[List[str]] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: SemanticDataTypeDefinition

Constant data type definition.

value

constant value.

Type

int

TYPE_INDICATOR: Optional[str] = 'constant'
class dtfabric.data_types.DataTypeDefinition(name: str, aliases: Optional[List[str]] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: object

Data type definition interface.

aliases

aliases.

Type

list[str]

description

description.

Type

str

name

name.

Type

str

urls

URLs.

Type

list[str]

abstract GetByteSize() Optional[int][source]

Retrieves the byte size of the data type definition.

Returns

data type size in bytes or None if size cannot be determined.

Return type

int

IsComposite() bool[source]

Determines if the data type is composite.

A composite data type consists of other data types.

Returns

True if the data type is composite, False otherwise.

Return type

bool

TYPE_INDICATOR: Optional[str] = None
class dtfabric.data_types.DataTypeDefinitionWithMembers(name: str, aliases: Optional[List[str]] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: StorageDataTypeDefinition

Data type definition with members.

members

member data type definitions.

Type

list[DataTypeDefinition]

sections

member section definitions.

Type

list[MemberSectionDefinition]

AddMemberDefinition(member_definition: DataTypeDefinition) None[source]

Adds a member definition.

Parameters

member_definition (DataTypeDefinition) – member data type definition.

Raises

KeyError – if a member with the name already exists.

AddSectionDefinition(section_definition: MemberSectionDefinition) None[source]

Adds a section definition.

Parameters

section_definition (MemberSectionDefinition) – member section definition.

abstract GetByteSize() Optional[int][source]

Retrieves the byte size of the data type definition.

Returns

data type size in bytes or None if size cannot be determined.

Return type

int

GetMemberDefinitionByName(name: str) Union[int, DataTypeDefinition][source]

Retrieve a specific member definition.

Parameters

name (str) – name of the member definition.

Returns

member data type definition or None if not available.

Return type

DataTypeDefinition

property members: List[DataTypeDefinition]

member data type definitions.

Type

members (list[DataTypeDefinition])

class dtfabric.data_types.ElementSequenceDataTypeDefinition(name: str, data_type_definition: DataTypeDefinition, aliases: Optional[List[str]] = None, data_type: Optional[str] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: StorageDataTypeDefinition

Element sequence data type definition.

byte_order

byte-order the data type.

Type

str

elements_data_size

data size of the sequence elements.

Type

int

elements_data_size_expression

expression to determine the data size of the sequence elements.

Type

str

element_data_type

name of the sequence element data type.

Type

str

element_data_type_definition

sequence element data type definition.

Type

DataTypeDefinition

elements_terminator

element value that indicates the end-of-sequence.

Type

bytes|int

number_of_elements

number of sequence elements.

Type

int

number_of_elements_expression

expression to determine the number of sequence elements.

Type

str

GetByteSize() Optional[int][source]

Retrieves the byte size of the data type definition.

Returns

data type size in bytes or None if size cannot be determined.

Return type

int

class dtfabric.data_types.EnumerationDefinition(name: str, aliases: Optional[List[str]] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: SemanticDataTypeDefinition

Enumeration data type definition.

values

enumeration values.

Type

list[EnumerationValue]

values_per_alias

enumeration values per alias.

Type

dict[str, EnumerationValue]

values_per_name

enumeration values per name.

Type

dict[str, EnumerationValue]

values_per_number

enumeration values per number.

Type

dict[int, EnumerationValue]

AddValue(name: str, number: int, aliases: Optional[List[str]] = None, description: Optional[str] = None) None[source]

Adds an enumeration value.

Parameters
  • name (str) – name.

  • number (int) – number.

  • aliases (Optional[list[str]]) – aliases.

  • description (Optional[str]) – description.

Raises

KeyError – if the enumeration value already exists.

TYPE_INDICATOR: Optional[str] = 'enumeration'
class dtfabric.data_types.EnumerationValue(name: str, number: int, aliases: Optional[List[str]] = None, description: Optional[str] = None)[source]

Bases: object

Enumeration value.

aliases

aliases.

Type

list[str]

description

description.

Type

str

name

name.

Type

str

number

number.

Type

int

class dtfabric.data_types.FixedSizeDataTypeDefinition(name: str, aliases: Optional[List[str]] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: StorageDataTypeDefinition

Fixed-size data type definition.

size

size of the data type or SIZE_NATIVE.

Type

int|str

units

units of the size of the data type.

Type

str

GetByteSize() Optional[int][source]

Retrieves the byte size of the data type definition.

Returns

data type size in bytes or None if size cannot be determined.

Return type

int

aliases: List[str]
description: Union[str, None]
name: str
urls: Union[List[str], None]
class dtfabric.data_types.FloatingPointDefinition(name: str, aliases: Optional[List[str]] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: FixedSizeDataTypeDefinition

Floating point data type definition.

TYPE_INDICATOR: Optional[str] = 'floating-point'
class dtfabric.data_types.FormatDefinition(name: str, aliases: Optional[List[str]] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: LayoutDataTypeDefinition

Data format definition.

metadata

metadata.

Type

dict[str, object]

layout

layout element definitions.

Type

list[LayoutElementDefinition]

TYPE_INDICATOR: Optional[str] = 'format'
class dtfabric.data_types.IntegerDefinition(name: str, aliases: Optional[List[str]] = None, description: Optional[str] = None, maximum_value: Optional[int] = None, minimum_value: Optional[int] = None, urls: Optional[List[str]] = None)[source]

Bases: FixedSizeDataTypeDefinition

Integer data type definition.

format

format of the data type.

Type

str

maximum_value

maximum allowed value of the integer data type.

Type

int

minimum_value

minimum allowed value of the integer data type.

Type

int

TYPE_INDICATOR: Optional[str] = 'integer'
class dtfabric.data_types.LayoutDataTypeDefinition(name: str, aliases: Optional[List[str]] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: DataTypeDefinition

Layout data type definition interface.

GetByteSize() Optional[int][source]

Retrieves the byte size of the data type definition.

Returns

data type size in bytes or None if size cannot be determined.

Return type

int

class dtfabric.data_types.LayoutElementDefinition(data_type: str, offset: Optional[int] = None)[source]

Bases: object

Layout element definition.

data_type

name of the data type definition of the layout element.

Type

str

offset

offset of the layout element.

Type

int

class dtfabric.data_types.MemberDataTypeDefinition(name: str, data_type_definition: DataTypeDefinition, aliases: Optional[List[str]] = None, condition: Optional[str] = None, data_type: Optional[str] = None, description: Optional[str] = None, urls: Optional[List[str]] = None, values: Optional[List[Union[int, str]]] = None)[source]

Bases: StorageDataTypeDefinition

Member data type definition.

byte_order

byte-order the data type.

Type

str

condition

condition under which the data type applies.

Type

str

member_data_type

member data type.

Type

str

member_data_type_definition

member data type definition.

Type

DataTypeDefinition

values

supported values.

Type

list[int|str]

GetByteSize() Optional[int][source]

Retrieves the byte size of the data type definition.

Returns

data type size in bytes or None if size cannot be determined.

Return type

int

IsComposite() bool[source]

Determines if the data type is composite.

A composite data type consists of other data types.

Returns

True if the data type is composite, False otherwise.

Return type

bool

aliases: List[str]
description: Union[str, None]
name: str
urls: Union[List[str], None]
class dtfabric.data_types.MemberSectionDefinition(name: str)[source]

Bases: object

Member section definition.

name

name of the section.

Type

str

members

member data type definitions of the section.

Type

list[DataTypeDefinition]

class dtfabric.data_types.PaddingDefinition(name: str, aliases: Optional[List[str]] = None, alignment_size: Optional[int] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: StorageDataTypeDefinition

Padding data type definition.

alignment_size

alignment size.

Type

int

GetByteSize() Optional[int][source]

Retrieves the byte size of the data type definition.

Returns

data type size in bytes or None if size cannot be determined.

Return type

int

TYPE_INDICATOR: Optional[str] = 'padding'
class dtfabric.data_types.SemanticDataTypeDefinition(name: str, aliases: Optional[List[str]] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: DataTypeDefinition

Semantic data type definition interface.

GetByteSize() Optional[int][source]

Retrieves the byte size of the data type definition.

Returns

data type size in bytes or None if size cannot be determined.

Return type

int

aliases: List[str]
description: Union[str, None]
name: str
urls: Union[List[str], None]
class dtfabric.data_types.SequenceDefinition(name: str, data_type_definition: DataTypeDefinition, aliases: Optional[List[str]] = None, data_type: Optional[str] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: ElementSequenceDataTypeDefinition

Sequence data type definition.

TYPE_INDICATOR: Optional[str] = 'sequence'
class dtfabric.data_types.StorageDataTypeDefinition(name: str, aliases: Optional[List[str]] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: DataTypeDefinition

Storage data type definition interface.

byte_order

byte-order the data type.

Type

str

abstract GetByteSize() Optional[int][source]

Retrieves the byte size of the data type definition.

Returns

data type size in bytes or None if size cannot be determined.

Return type

int

aliases: List[str]
description: Union[str, None]
name: str
urls: Union[List[str], None]
class dtfabric.data_types.StreamDefinition(name: str, data_type_definition: DataTypeDefinition, aliases: Optional[List[str]] = None, data_type: Optional[str] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: ElementSequenceDataTypeDefinition

Stream data type definition.

TYPE_INDICATOR: Optional[str] = 'stream'
class dtfabric.data_types.StringDefinition(name: str, data_type_definition: DataTypeDefinition, aliases: Optional[List[str]] = None, data_type: Optional[str] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: ElementSequenceDataTypeDefinition

String data type definition.

encoding

string encoding.

Type

str

TYPE_INDICATOR: Optional[str] = 'string'
class dtfabric.data_types.StructureDefinition(name: str, aliases: Optional[List[str]] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: DataTypeDefinitionWithMembers

Structure data type definition.

GetByteSize() Optional[int][source]

Retrieves the byte size of the data type definition.

Returns

data type size in bytes or None if size cannot be determined.

Return type

int

TYPE_INDICATOR: Optional[str] = 'structure'
class dtfabric.data_types.StructureFamilyDefinition(name: str, base_definition: StructureDefinition, aliases: Optional[List[str]] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: LayoutDataTypeDefinition

Structure family definition.

base

base data type definition.

Type

DataTypeDefinition

members

member data type definitions.

Type

list[DataTypeDefinition]

AddMemberDefinition(member_definition: StructureDefinition) None[source]

Adds a member definition.

Parameters

member_definition (StructureDefinition) – member data type definition.

Raises

KeyError – if a member with the name already exists.

SetBaseDefinition(base_definition: StructureDefinition) None[source]

Sets a base definition.

Parameters

base_definition (StructureDefinition) – base data type definition.

TYPE_INDICATOR: Optional[str] = 'structure-family'
property members: List[DataTypeDefinition]

member data type definitions.

Type

members (list[DataTypeDefinition])

class dtfabric.data_types.StructureGroupDefinition(name: str, base_definition: StructureDefinition, identifier: str, aliases: Optional[List[str]] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: LayoutDataTypeDefinition

Structure group definition.

base

base data type definition.

Type

DataTypeDefinition

identifier

name of the base structure member to identify the group members.

Type

str

members

member data type definitions.

Type

list[DataTypeDefinition]

AddMemberDefinition(member_definition: StructureDefinition) None[source]

Adds a member definition.

Parameters

member_definition (StructureDefinition) – member data type definition.

Raises

KeyError – if a member with the name already exists.

TYPE_INDICATOR: Optional[str] = 'structure-group'
property members: List[DataTypeDefinition]

member data type definitions.

Type

members (list[DataTypeDefinition])

class dtfabric.data_types.UUIDDefinition(name: str, aliases: Optional[List[str]] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: FixedSizeDataTypeDefinition

UUID (or GUID) data type definition.

TYPE_INDICATOR: Optional[str] = 'uuid'
class dtfabric.data_types.UnionDefinition(name: str, aliases: Optional[List[str]] = None, description: Optional[str] = None, urls: Optional[List[str]] = None)[source]

Bases: DataTypeDefinitionWithMembers

Union data type definition.

GetByteSize() Optional[int][source]

Retrieves the byte size of the data type definition.

Returns

data type size in bytes or None if size cannot be determined.

Return type

int

TYPE_INDICATOR: Optional[str] = 'union'

dtfabric.decorators module

Function decorators.

dtfabric.decorators.deprecated(function)[source]

Decorator to mark functions or methods as deprecated.

dtfabric.definitions module

Definitions.

dtfabric.errors module

The error objects.

exception dtfabric.errors.ByteStreamTooSmallError[source]

Bases: Error

Error that is raised when the byte stream is too small.

exception dtfabric.errors.DefinitionReaderError(name: str, message: str)[source]

Bases: Error

Error that is raised by the definition reader.

name

name of the definition.

Type

str

message

error message.

Type

str

exception dtfabric.errors.Error[source]

Bases: Exception

The error interface.

exception dtfabric.errors.FoldingError[source]

Bases: Error

Error that is raised when the definition cannot be folded.

exception dtfabric.errors.FormatError[source]

Bases: Error

Error that is raised when the definition format is incorrect.

exception dtfabric.errors.MappingError[source]

Bases: Error

Error that is raised when the definition cannot be mapped.

dtfabric.reader module

The data type definition reader objects.

class dtfabric.reader.DataTypeDefinitionsFileReader[source]

Bases: DataTypeDefinitionsReader

Data type definitions file reader.

ReadFile(definitions_registry, path)[source]

Reads data type definitions from a file into the registry.

Parameters
abstract ReadFileObject(definitions_registry, file_object)[source]

Reads data type definitions from a file-like object into the registry.

Parameters
  • definitions_registry (DataTypeDefinitionsRegistry) – data type definitions registry.

  • file_object (file) – file-like object to read from.

class dtfabric.reader.DataTypeDefinitionsReader[source]

Bases: object

Data type definitions reader.

class dtfabric.reader.YAMLDataTypeDefinitionsFileReader[source]

Bases: DataTypeDefinitionsFileReader

YAML data type definitions file reader.

dict[str, object]

metadata.

ReadFileObject(definitions_registry, file_object)[source]

Reads data type definitions from a file-like object into the registry.

Parameters
  • definitions_registry (DataTypeDefinitionsRegistry) – data type definitions registry.

  • file_object (file) – file-like object to read from.

Raises
  • DefinitionReaderError – if the definitions values are missing or if the format is incorrect.

  • FormatError – if the definitions values are missing or if the format is incorrect.

dtfabric.registry module

The data type definitions registry.

class dtfabric.registry.DataTypeDefinitionsRegistry[source]

Bases: object

Data type definitions registry.

DeregisterDefinition(data_type_definition: data_types.DataTypeDefinition) None[source]

Deregisters a data type definition.

The data type definitions are identified based on their lower case name.

Parameters

data_type_definition (DataTypeDefinition) – data type definition.

Raises

KeyError – if a data type definition is not set for the corresponding name.

GetDefinitionByName(name: str) Union[data_types.DataTypeDefinition, None][source]

Retrieves a specific data type definition by name.

Parameters

name (str) – name of the data type definition.

Returns

data type definition or None if not available.

Return type

DataTypeDefinition

GetDefinitions() List[data_types.DataTypeDefinition][source]

Retrieves the data type definitions.

Returns

data type definitions.

Return type

list[DataTypeDefinition]

RegisterDefinition(data_type_definition: data_types.DataTypeDefinition) None[source]

Registers a data type definition.

The data type definitions are identified based on their lower case name.

Parameters

data_type_definition (DataTypeDefinition) – data type definitions.

Raises

KeyError – if data type definition is already set for the corresponding name.

Module contents

Data type fabric.