Skip to content

Standard Library

Namespace: exbip

Parsers

Reader #

Inherits from ReaderBase. Implements the standard library descriptors. A parser for deserializing bytes to Python objects. Designed for contiguous parsing.

Descriptor Method: deserialize

Operator Aliases:
check_stream_offset -> verify_stream_offset


NonContiguousReader #

Inherits from ReaderBase. Implements the standard library descriptors. A parser for deserializing bytes to Python objects. Designed for non-contiguous parsing.

Descriptor Method: deserialize

Operator Aliases:
check_stream_offset -> enforce_stream_offset


Validator #

Inherits from ValidatorBase. Implements the standard library descriptors. A parser to verify whether two bytestreams deserialize to identical Python objects, and if not, to raise an error that originates at the first pair of read calls that deserialize to different values. Designed for contiguous parsing.

Descriptor Method: deserialize

Operator Aliases:
check_stream_offset -> verify_stream_offset


Writer #

Inherits from WriterBase. Implements the standard library descriptors. A parser for serializing Python objects to bytes. Designed for contiguous parsing.

Descriptor Method: serialize

Operator Aliases:
check_stream_offset -> verify_stream_offset


Counter #

Inherits from CounterBase. Implements the standard library descriptors. A parser for counting how many bytes a stream pointer will advance for each operator call. Designed for contiguous parsing.

Descriptor Method: count

Operator Aliases:
check_stream_offset -> verify_stream_offset


OffsetCalculator #

Inherits from OffsetCalculatorBase. Implements the standard library descriptors. A parser for counting how many bytes a stream pointer will advance for each operator call, and using this to calculate the value of stream-offset variables within a structure.

Descriptor Method: calculate_offsets if it exists. Else, count

Operator Aliases:
check_stream_offset -> verify_stream_offset

Traits

ReadableTrait(Reader): #

A trait that adds deserialization methods to a structure.
Functions:
read(filepath, \*args, \*\*kwargs):
Passes filepath to the FileIO() method of Reader.
frombytes(byte_data, \*args, \*\*kwargs):
Passes byte_data to the BytestreamIO() method of Reader.

WriteableTrait(Writer): #

A trait that adds serialization methods to a structure.
Functions:
write(filepath, \*args, \*\*kwargs):
Passes filepath to the FileIO() method of Writer.
tobytes(\*args, \*\*kwargs):
Returns the bytes written to the stream initialized by the BytestreamIO() method of Writer.

ValidatableTrait(Validator): #

A trait that adds validation methods to a structure.
Functions:
validate_file_against_file(primary_filepath, reference_filepath, \*args, \*\*kwargs):
Validates the data in primary_filepath against the data in reference_filepath.
validate_file_against_bytes(primary_filepath, reference_bytes, \*args, \*\*kwargs):
Validates the data in primary_filepath against the bytes in reference_bytes.
validate_bytes_against_file(primary_bytes, reference_filepath, \*args, \*\*kwargs):
Validates the bytes in primary_bytes against the data in reference_filepath.
validate_bytes_against_bytes(primary_bytes, reference_bytes, \*args, \*\*kwargs):
Validates the bytes in primary_bytes against the bytes in reference_bytes.

OffsetsCalculableTrait(OffsetCalculator): #

A trait that adds offset calculation methods to a structure.
Functions:
calculate_offsets(obj, \*args, \*\*kwargs):
Calls OffsetCalculator.rw_obj(obj, \*args, \*\*kwargs) on an instance of OffsetCalculator. This is intended to be used to automatically calculate the values of file offsets.

Operations

Primitives

rw_int8(value): #

Operates on a signed 8-bit integer with context-sensitive endianness.
deserialize:
Returns a signed 8-bit integer unpacked from the stream.
serialize:
Packs value to 1 byte and writes it to the stream. Returns value.
count:
Increments the stream offset by 1. Returns value.
Variants:
rw_int8_le(value) Forced little-endian mode.
rw_int8_be(value) Forced big-endian mode.
rw_int8_e(value, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_int16(value): #

Operates on a signed 16-bit integer with context-sensitive endianness.
deserialize:
Returns a signed 16-bit integer unpacked from the stream.
serialize:
Packs value to 2 bytes and writes it to the stream. Returns value.
count:
Increments the stream offset by 2. Returns value.
Variants:
rw_int16_le(value) Forced little-endian mode.
rw_int16_be(value) Forced big-endian mode.
rw_int16_e(value, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_int32(value): #

Operates on a signed 32-bit integer with context-sensitive endianness.
deserialize:
Returns a signed 32-bit integer unpacked from the stream.
serialize:
Packs value to 4 bytes and writes it to the stream. Returns value.
count:
Increments the stream offset by 4. Returns value.
Variants:
rw_int32_le(value) Forced little-endian mode.
rw_int32_be(value) Forced big-endian mode.
rw_int32_e(value, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_int64(value): #

Operates on a signed 64-bit integer with context-sensitive endianness.
deserialize:
Returns a signed 64-bit integer unpacked from the stream.
serialize:
Packs value to 8 bytes and writes it to the stream. Returns value.
count:
Increments the stream offset by 8. Returns value.
Variants:
rw_int64_le(value) Forced little-endian mode.
rw_int64_be(value) Forced big-endian mode.
rw_int64_e(value, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_uint8(value): #

Operates on an unsigned 8-bit integer with context-sensitive endianness.
deserialize:
Returns an unsigned 8-bit integer unpacked from the stream.
serialize:
Packs value to 1 byte and writes it to the stream. Returns value.
count:
Increments the stream offset by 1. Returns value.
Variants:
rw_uint8_le(value) Forced little-endian mode.
rw_uint8_be(value) Forced big-endian mode.
rw_uint8_e(value, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_uint16(value): #

Operates on an unsigned 16-bit integer with context-sensitive endianness.
deserialize:
Returns an unsigned 16-bit integer unpacked from the stream.
serialize:
Packs value to 2 bytes and writes it to the stream. Returns value.
count:
Increments the stream offset by 2. Returns value.
Variants:
rw_uint16_le(value) Forced little-endian mode.
rw_uint16_be(value) Forced big-endian mode.
rw_uint16_e(value, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_uint32(value): #

Operates on an unsigned 32-bit integer with context-sensitive endianness.
deserialize:
Returns an unsigned 32-bit integer unpacked from the stream.
serialize:
Packs value to 4 bytes and writes it to the stream. Returns value.
count:
Increments the stream offset by 4. Returns value.
Variants:
rw_uint32_le(value) Forced little-endian mode.
rw_uint32_be(value) Forced big-endian mode.
rw_uint32_e(value, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_uint64(value): #

Operates on an unsigned 64-bit integer with context-sensitive endianness.
deserialize:
Returns an unsigned 64-bit integer unpacked from the stream.
serialize:
Packs value to 8 bytes and writes it to the stream. Returns value.
count:
Increments the stream offset by 8. Returns value.
Variants:
rw_uint64_le(value) Forced little-endian mode.
rw_uint64_be(value) Forced big-endian mode.
rw_uint64_e(value, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_float16(value): #

Operates on an IEEE 16-bit float with context-sensitive endianness.
deserialize:
Returns an IEEE 16-bit float unpacked from the stream.
serialize:
Packs value to 2 bytes and writes it to the stream. Returns value.
count:
Increments the stream offset by 2. Returns value.
Variants:
rw_float16_le(value) Forced little-endian mode.
rw_float16_be(value) Forced big-endian mode.
rw_float16_e(value, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_float32(value): #

Operates on an IEEE 32-bit float with context-sensitive endianness.
deserialize:
Returns an IEEE 32-bit float unpacked from the stream.
serialize:
Packs value to 4 bytes and writes it to the stream. Returns value.
count:
Increments the stream offset by 4. Returns value.
Variants:
rw_float32_le(value) Forced little-endian mode.
rw_float32_be(value) Forced big-endian mode.
rw_float32_e(value, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_float64(value): #

Operates on an IEEE 64-bit float with context-sensitive endianness.
deserialize:
Returns an IEEE 64-bit float unpacked from the stream.
serialize:
Packs value to 8 bytes and writes it to the stream. Returns value.
count:
Increments the stream offset by 8. Returns value.
Variants:
rw_float64_le(value) Forced little-endian mode.
rw_float64_be(value) Forced big-endian mode.
rw_float64_e(value, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

Primitive Arrays

rw_int8s(value, shape): #

Operates on an array of signed 8-bit integers with context-sensitive endianness.
deserialize:
Returns an array of signed 8-bit integers unpacked from the stream, row-major reshaped to the dimensions given by shape.
serialize:
Packs value in row-major order and writes it to the stream. Returns value.
count:
Increments the stream offset by the binary size of value. Returns value.
Variants:
rw_int8s_le(value, shape) Forced little-endian mode.
rw_int8s_be(value, shape) Forced big-endian mode.
rw_int8s_e(value, shape, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_int16s(value, shape): #

Operates on an array of signed 16-bit integers with context-sensitive endianness.
deserialize:
Returns an array of signed 16-bit integers unpacked from the stream, row-major reshaped to the dimensions given by shape.
serialize:
Packs value in row-major order and writes it to the stream. Returns value.
count:
Increments the stream offset by the binary size of value. Returns value.
Variants:
rw_int16s_le(value, shape) Forced little-endian mode.
rw_int16s_be(value, shape) Forced big-endian mode.
rw_int16s_e(value, shape, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_int32s(value, shape): #

Operates on an array of signed 32-bit integers with context-sensitive endianness.
deserialize:
Returns an array of signed 32-bit integers unpacked from the stream, row-major reshaped to the dimensions given by shape.
serialize:
Packs value in row-major order and writes it to the stream. Returns value.
count:
Increments the stream offset by the binary size of value. Returns value.
Variants:
rw_int32s_le(value, shape) Forced little-endian mode.
rw_int32s_be(value, shape) Forced big-endian mode.
rw_int32s_e(value, shape, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_int64s(value, shape): #

Operates on an array of signed 64-bit integers with context-sensitive endianness.
deserialize:
Returns an array of signed 64-bit integers unpacked from the stream, row-major reshaped to the dimensions given by shape.
serialize:
Packs value in row-major order and writes it to the stream. Returns value.
count:
Increments the stream offset by the binary size of value. Returns value.
Variants:
rw_int64s_le(value, shape) Forced little-endian mode.
rw_int64s_be(value, shape) Forced big-endian mode.
rw_int64s_e(value, shape, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_uint8s(value, shape): #

Operates on an array of unsigned 8-bit integers with context-sensitive endianness.
deserialize:
Returns an array of unsigned 8-bit integers unpacked from the stream, row-major reshaped to the dimensions given by shape.
serialize:
Packs value in row-major order and writes it to the stream. Returns value.
count:
Increments the stream offset by the binary size of value. Returns value.
Variants:
rw_uint8s_le(value, shape) Forced little-endian mode.
rw_uint8s_be(value, shape) Forced big-endian mode.
rw_uint8s_e(value, shape, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_uint16s(value, shape): #

Operates on an array of unsigned 16-bit integers with context-sensitive endianness.
deserialize:
Returns an array of unsigned 16-bit integers unpacked from the stream, row-major reshaped to the dimensions given by shape.
serialize:
Packs value in row-major order and writes it to the stream. Returns value.
count:
Increments the stream offset by the binary size of value. Returns value.
Variants:
rw_uint16s_le(value, shape) Forced little-endian mode.
rw_uint16s_be(value, shape) Forced big-endian mode.
rw_uint16s_e(value, shape, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_uint32s(value, shape): #

Operates on an array of unsigned 32-bit integers with context-sensitive endianness.
deserialize:
Returns an array of unsigned 32-bit integers unpacked from the stream, row-major reshaped to the dimensions given by shape.
serialize:
Packs value in row-major order and writes it to the stream. Returns value.
count:
Increments the stream offset by the binary size of value. Returns value.
Variants:
rw_uint32s_le(value, shape) Forced little-endian mode.
rw_uint32s_be(value, shape) Forced big-endian mode.
rw_uint32s_e(value, shape, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_uint64s(value, shape): #

Operates on an array of unsigned 64-bit integers with context-sensitive endianness.
deserialize:
Returns an array of unsigned 64-bit integers unpacked from the stream, row-major reshaped to the dimensions given by shape.
serialize:
Packs value in row-major order and writes it to the stream. Returns value.
count:
Increments the stream offset by the binary size of value. Returns value.
Variants:
rw_uint64s_le(value, shape) Forced little-endian mode.
rw_uint64s_be(value, shape) Forced big-endian mode.
rw_uint64s_e(value, shape, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_float16s(value, shape): #

Operates on an array of IEEE 16-bit floats with context-sensitive endianness.
deserialize:
Returns an array of IEEE 16-bit floats unpacked from the stream, row-major reshaped to the dimensions given by shape.
serialize:
Packs value in row-major order and writes it to the stream. Returns value.
count:
Increments the stream offset by the binary size of value. Returns value.
Variants:
rw_float16s_le(value, shape) Forced little-endian mode.
rw_float16s_be(value, shape) Forced big-endian mode.
rw_float16s_e(value, shape, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_float32s(value, shape): #

Operates on an array of IEEE 32-bit floats with context-sensitive endianness.
deserialize:
Returns an array of IEEE 32-bit floats unpacked from the stream, row-major reshaped to the dimensions given by shape.
serialize:
Packs value in row-major order and writes it to the stream. Returns value.
count:
Increments the stream offset by the binary size of value. Returns value.
Variants:
rw_float32s_le(value, shape) Forced little-endian mode.
rw_float32s_be(value, shape) Forced big-endian mode.
rw_float32s_e(value, shape, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

rw_float64s(value, shape): #

Operates on an array of IEEE 64-bit floats with context-sensitive endianness.
deserialize:
Returns an array of IEEE 64-bit floats unpacked from the stream, row-major reshaped to the dimensions given by shape.
serialize:
Packs value in row-major order and writes it to the stream. Returns value.
count:
Increments the stream offset by the binary size of value. Returns value.
Variants:
rw_float64s_le(value, shape) Forced little-endian mode.
rw_float64s_be(value, shape) Forced big-endian mode.
rw_float64s_e(value, shape, endianness) Runtime endianness. Pass '<' or '>' for little- or big-endianness respectively.

Strings

rw_bytestring(value, length): #

Operates on a fixed-size bytestring.
deserialize:
Reads length chars from the stream. Returns a bytes object.
serialize:
Writes value to the stream. Expects value to be a bytes-like object. Returns value.
count:
Increments the stream offset by the length of value. Expects value to be a bytes object. Returns value.

rw_bytestrings(value, lengths): #

Operates on a list of fixed-size bytestrings.
deserialize:
Reads length chars from the stream. Returns a List[bytes] object.
serialize:
Writes each element in value to the stream. Expects value to be an iterable of bytes-like objects. Returns value.
count:
Increments the stream offset by the sum of all lengths in value. Expects value to be an iterable of bytes-like objects. Returns value.

rw_cbytestring(value[, chunksize=0x40, terminator=b'\x00']): #

Operates on a terminated bytestring.
deserialize:
Reads chars from the stream in blocks of chunksize until the terminator pattern is identified in one of those blocks. Returns a bytes object without the terminator.
serialize:
Writes value to the stream, and then writes the terminator. Expects value to be a bytes-like object. Returns value.
count:
Increments the stream offset by the length of value plus the length of the terminator. Expects value to be an iterable of bytes-like objects. Returns value.

rw_cbytestrings(value, count[, chunksize=0x40, terminator=b'\x00']): #

Operates on a list of terminated bytestrings.
deserialize:
Reads chars from the stream in blocks of chunksize until the terminator pattern is identified in one of those blocks, count times. Returns a List[bytes] object.
serialize:
Writes each element (followed by the terminator) in value to the stream. Expects value to be an iterable of bytes-like objects. Returns value.
count:
Increments the stream offset by the sum of all lengths in value (plus the requisite terminator lengths). Expects value to be an iterable of bytes-like objects. Returns value.

Descriptors

rw_descriptor(descriptor, *args, **kwargs): #

Looks for and executes the descriptor method required by the parser.
deserialize:
Invokes the 'deserialize' method of the descriptor.
serialize:
Invokes the 'serialize' method of the descriptor.
count:
Invokes the 'count' method of the descriptor.

Objects

rw_obj(value, *args, **kwargs): #

Executes the exbip_rw function on value.
deserialize:
Calls exbip_rw on value.
serialize:
Calls exbip_rw on value.
count:
Calls exbip_rw on value.

rw_dynamic_obj(value, constructor, *args, **kwargs): #

Executes the exbip_rw function on value if not deserializing, otherwise constructs it first.
deserialize:
Calls constructor to build a new object, then calls exbip_rw on it.
serialize:
Calls exbip_rw on value.
count:
Calls exbip_rw on value.

rw_dynamic_objs(values, constructor, count, *args, **kwargs): #

Executes the exbip_rw function on value if not deserializing, otherwise constructs to object array first from a count.
deserialize:
Calls constructor to build a new object, then calls exbip_rw on it, count times.
serialize:
Calls exbip_rw on each element in values.
count:
Calls exbip_rw on each element in values.

rw_dynamic_objs_while(values, constructor, condition, *args, **kwargs): #

Executes the exbip_rw function on value if not deserializing, otherwise constructs to object array first from a boolean condition.
deserialize:
Calls constructor to build a new object, then calls exbip_rw on it, until calling condition returns False. condition must be a function (or functor) that takes the parser as its only argument.
serialize:
Calls exbip_rw on each element in values.
count:
Calls exbip_rw on each element in values.

Iterators

array_iterator(array, constructor, count): #

Returns an iterable object that will construct count array elements if deserializing, and iterate through an array if not. Example:
for i, obj in enumerate(rw.array_iterator(arr, MyObject, my_count)):
    rw.check_stream_offset(obj_offsets[i], "Object {i}", HEX32_FORMATTER)
    rw.rw_obj(obj)
This can be used for more advanced looping behavior than e.g. rw_dynamic_objs.
deserialize:
Returns an iterable object that clears the given array, and then appends a newly-constructed object to the array at the start of each iteration.
serialize:
Returns an iterable object that iterates through the elements of array.
count:
Returns an iterable object that iterates through the elements of array.

array_while_iterator(array, constructor, stop_condition): #

Returns an iterable object that will construct array elements until condition is False if deserializing, and iterate through an array if not. Example:
class Cond:
    def __init__(self, offset):
        self.offset = offset

    def __call__(self, rw):
        return rw.tell() < self.offset

offset_list = []
for obj in rw.array_while_iterator(arr, MyObject, Cond(offset)):
    offset_list.append(rw.tell())
    rw.rw_obj(obj)
This can be used for more advanced looping behavior than e.g. rw_dynamic_objs_while.
deserialize:
Returns an iterable object that clears the given array, and then appends a newly-constructed object to the array at the start of each iteration.
serialize:
Returns an iterable object that iterates through the elements of array.
count:
Returns an iterable object that iterates through the elements of array.

Sections

section_exists(offset, count): #

Returns a bool that states whether a data section defined by a non-zero offset and/or count exists or not.
deserialize:
Returns True if offset is greater than 0.
serialize:
Returns True if count is greater than 0.
count:
Returns True if count is greater than 0.

Stream End-of-file

assert_eof(): #

Raises an exception if the stream pointer is not at the end of the stream, if the parsing mode defines an end-of-stream.
deserialize:
Raises a NotAtEOFError if the stream pointer is not at the end of the stream.
serialize:
Does nothing.
count:
Does nothing.

Stream Alignment

align(offset, alignment(, pad_value=b'\x00'): #

Rounds up offset to the next multiple of alignment, and performs an operation on the section of the stream corresponding to the skipped bytes.
deserialize:
Reads enough bytes to perform the alignment, and validates that they are an array of pad_values. Raises ValueError if the number of bytes required for the alignment is not divisible by the length of pad_value.
serialize:
Writes enough pad_values to the stream to perform the alignment. Raises ValueError if the number of bytes required for the alignment is not divisible by the length of pad_value.
count:
Advances the stream offset to the next multiple of alignment. Raises ValueError if the number of bytes required for the alignment is not divisible by the length of pad_value.

fill(offset, alignment(, fill_value=b'\x00'): #

Rounds up offset to the next multiple of alignment, and performs an operation on the section of the stream corresponding to the skipped bytes.
deserialize:
Reads enough bytes to perform the alignment. Does not perform any validation.
serialize:
Writes enough pad_values to the stream to perform the alignment. Raises ValueError if the number of bytes required for the alignment is not divisible by the length of pad_value.
count:
Advances the stream offset to the next multiple of alignment. Raises ValueError if the number of bytes required for the alignment is not divisible by the length of pad_value.

Stream Offsets

verify_stream_offset(offset, message[, formatter=lambda x: x, notifier=None]): #

Seeks to offset, throws an error if the stream offset is not at offset, or calls notifier with the current stream offset.
deserialize:
Seeks to offset.
serialize:
Throws a UnexpectedOffsetError if the stream offset is not at offset.
count:
Does nothing.
calculate_offsets:
Calls notifier.notify() if notifier is not None. Commonly, notifier is an OffsetMarker object.

navigate_stream_offset(offset, message[, formatter=lambda x: x, notifier=None]): #

Seeks to offset, throws an error if the stream offset is not at offset, or calls notifier with the current stream offset.
deserialize:
Seeks to offset.
serialize:
Does nothing.
count:
Does nothing.
calculate_offsets:
Calls notifier.notify() if notifier is not None. Commonly, notifier is an OffsetMarker object.

verify_stream_offset(offset, message[, formatter=lambda x: x, notifier=None]): #

Throws an error if the stream offset is not at offset, or calls notifier with the current stream offset.
deserialize:
Throws a UnexpectedOffsetError if the stream offset is not at offset.
serialize:
Throws a UnexpectedOffsetError if the stream offset is not at offset.
count:
Does nothing.
calculate_offsets:
Calls notifier.notify() if notifier is not None. Commonly, notifier is an OffsetMarker object.

check_stream_offset(offset, message[, formatter=lambda x: x, notifier=None]): #

An alias for verify_stream_offset. Used by all standard parsers except NonContiguousReader.

check_stream_offset(offset, message[, formatter=lambda x: x, notifier=None]): #

An alias for enforce_stream_offset. Used by NonContiguousReader.

Stream Padding

rw_padding(count[, pad_value=b'\x00', validate=True]): #

Operates on an anonymous bytestring of length count.
deserialize:
Reads count*len(pad_value) bytes from the stream. If validate is True, the bytes are checked to ensure they are an array of pad_value. If they are not, an UnexpectedPaddingError is raised.
serialize:
Writes count pad_values to the stream.
count:
Advances the stream by count*len(pad_value).

Offset Markers

dispatch_marker(marker): #

Operates on an object with a single-argument notify method, expected to be an OffsetMarker object.
deserialize:
Does nothing.
serialize:
Does nothing.
count:
Does nothing.
calculate_offsets:
Calls marker.notify().

Formatters

safe_formatter(formatter): #

Returns a safe_formatter object that calls formatter, which is a format method like e.g. '0b{0:0>8b}'.format, and returns the call return value if it does not throw an exception. On throwing a ValueError or TypeError, the original value is returned. Other exceptions are uncaught.

bin8_formatter(value): #

A safe_formatter that formats value as an 8-bit binary string.

bin16_formatter(value): #

A safe_formatter that formats value as a 16-bit binary string.

bin32_formatter(value): #

A safe_formatter that formats value as a 32-bit binary string.

bin64_formatter(value): #

A safe_formatter that formats value as a 64-bit binary string.

hex8_formatter(value): #

A safe_formatter that formats value as an 8-bit lower-case hex string.

hex16_formatter(value): #

A safe_formatter that formats value as a 16-bit lower-case hex string.

hex32_formatter(value): #

A safe_formatter that formats value as a 32-bit lower-case hex string.

hex64_formatter(value): #

A safe_formatter that formats value as a 64-bit lower-case hex string.

HEX8_formatter(value): #

A safe_formatter that formats value as an 8-bit upper-case hex string.

HEX16_formatter(value): #

A safe_formatter that formats value as a 16-bit upper-case hex string.

HEX32_formatter(value): #

A safe_formatter that formats value as a 32-bit upper-case hex string.

HEX64_formatter(value): #

A safe_formatter that formats value as a 64-bit upper-case hex string.

Structures

OffsetMarker #

A class that holds a list of single-argument callbacks. When notify is called, the offset passed to notify is used to call each of these callbacks, each of which is intended to give a particular variable the value of that offset.
Functions:
clear():
Clears the subscriber list.
subscribe(obj, attr):
Adds a callback lambda offset: setattr(obj, attr, offset) to the OffsetMarker's callbacks list. Returns self so that multiple subscriptions can be chained with the constructor.
subscribe_callback(callback):
Adds the single-argument function callback to the OffsetMarker's callbacks list. Returns self so that multiple subscriptions can be chained with the constructor.
notify(offset):
Iterates through the list of subscribers and calls each one with offset.