data_bytes

Module with helper class for data bytes.

class DataBytes(data_bytes: bytes)

Bases: object

Data bytes class. It allows to get bytes in different formats.

m_data_bytes: bytes
Length() → int

Get length in bytes.

Returns:

Length in bytes

Return type:

int

Size() → int

Get length in bytes (same of Length()).

Returns:

Length in bytes

Return type:

int

ToBytes() → bytes

Get data bytes.

Returns:

Data bytes

Return type:

bytes

ToHex() → str

Get data bytes in hex format.

Returns:

Data bytes in hex format

Return type:

str

ToInt(endianness: typing_extensions.Literal[little, big] = 'big') → int

Get data bytes as an integer.

Parameters:

endianness ("big" or "little", optional) – Endianness (default: big)

Returns:

Data bytes as an integer

Return type:

int

__len__() → int

Get length in bytes.

Returns:

Length in bytes

Return type:

int

__bytes__() → bytes

Get data bytes.

Returns:

Data bytes

Return type:

bytes

__int__() → int

Get data bytes as integer.

Returns:

Data bytes as integer

Return type:

bytes

__repr__() → str

Get data bytes representation.

Returns:

Data bytes representation

Return type:

str

__getitem__(idx: int) → int

Get the element with the specified index.

Parameters:

idx (int) – Index

Returns:

Element

Return type:

int

Raises:

IndexError – If the index is not valid

__iter__() → Iterator[int]

Get the iterator to the current element.

Returns:

Iterator to the current element

Return type:

Iterator object

__eq__(other: object) → bool

Equality operator.

Parameters:

other (bytes, str, int or DataBytes object) – Other object to compare

Returns:

True if equal false otherwise

Return type:

bool

Raises:

TypeError – If the other object is not of the correct type