pylbo.utilities.datfiles.istream_reader

Attributes

DTYPES

NP_DTYPES

BYTE_ORDERS

SIZE_CHAR

SIZE_INT

SIZE_BOOL

SIZE_DOUBLE

SIZE_COMPLEX

Functions

requires_version(version_needed[, default])

read_string_from_istream(→ Union[str, list[str]])

Reads a string from the input stream.

read_int_from_istream(→ Union[int, tuple[int, Ellipsis]])

Reads an integer from the input stream.

read_boolean_from_istream(→ bool)

Reads a boolean from the input stream.

read_float_from_istream(→ Union[float, tuple[float, ...)

Reads a float from the input stream.

read_complex_from_istream(→ Union[complex, ...)

Reads a complex from the input stream.

read_mixed_from_istream(istream, fmt, amount, offset, ...)

Reads a number of mixed types from the input stream.

Module Contents

pylbo.utilities.datfiles.istream_reader.DTYPES
pylbo.utilities.datfiles.istream_reader.NP_DTYPES
pylbo.utilities.datfiles.istream_reader.BYTE_ORDERS
pylbo.utilities.datfiles.istream_reader.SIZE_CHAR
pylbo.utilities.datfiles.istream_reader.SIZE_INT
pylbo.utilities.datfiles.istream_reader.SIZE_BOOL
pylbo.utilities.datfiles.istream_reader.SIZE_DOUBLE
pylbo.utilities.datfiles.istream_reader.SIZE_COMPLEX
pylbo.utilities.datfiles.istream_reader.requires_version(version_needed, default=None)
pylbo.utilities.datfiles.istream_reader.read_string_from_istream(istream: BinaryIO, length: int, amount: int = 1, offset: int = None, byte_order: str = 'native') str | list[str]

Reads a string from the input stream.

Parameters:
  • istream (BinaryIO) – The input stream to read from.

  • length (int) – The length of the string to read.

  • amount (int, optional) – The amount of strings to read, by default 1.

  • offset (int, optional) – The offset to seek to before reading, by default None.

  • byte_order (str, optional) – The byte order to use, by default “native”.

Returns:

The string(s) read from the input stream.

Return type:

str, list of str

pylbo.utilities.datfiles.istream_reader.read_int_from_istream(istream: BinaryIO, amount: int = 1, offset: int = None, byte_order: str = 'native') int | tuple[int, Ellipsis]

Reads an integer from the input stream.

Parameters:
  • istream (BinaryIO) – The input stream to read from.

  • amount (int, optional) – The amount of integers to read, by default 1.

  • offset (int, optional) – The offset to seek to before reading, by default None.

  • byte_order (str, optional) – The byte order to use, by default “native”.

Returns:

The integer(s) read from the input stream.

Return type:

int, tuple of int

pylbo.utilities.datfiles.istream_reader.read_boolean_from_istream(istream: BinaryIO, offset: int = None, byte_order: str = 'native') bool

Reads a boolean from the input stream.

Parameters:
  • istream (BinaryIO) – The input stream to read from.

  • offset (int, optional) – The offset to seek to before reading, by default None.

  • byte_order (str, optional) – The byte order to use, by default “native”.

Returns:

The boolean read from the input stream.

Return type:

bool

pylbo.utilities.datfiles.istream_reader.read_float_from_istream(istream: BinaryIO, amount: int = 1, offset: int = None, byte_order: str = 'native') float | tuple[float, Ellipsis]

Reads a float from the input stream.

Parameters:
  • istream (BinaryIO) – The input stream to read from.

  • amount (int, optional) – The amount of floats to read, by default 1.

  • offset (int, optional) – The offset to seek to before reading, by default None.

  • byte_order (str, optional) – The byte order to use, by default “native”.

Returns:

The float(s) read from the input stream.

Return type:

float, tuple of float

pylbo.utilities.datfiles.istream_reader.read_complex_from_istream(istream: BinaryIO, amount: int = 1, offset: int = None, byte_order: str = 'native') complex | tuple[complex, Ellipsis]

Reads a complex from the input stream.

Parameters:
  • istream (BinaryIO) – The input stream to read from.

  • amount (int, optional) – The amount of complex numbers to read, by default 1.

  • offset (int, optional) – The offset to seek to before reading, by default None.

  • byte_order (str, optional) – The byte order to use, by default “native”.

Returns:

The complex number(s) read from the input stream.

Return type:

complex, tuple of complex

pylbo.utilities.datfiles.istream_reader.read_mixed_from_istream(istream: BinaryIO, fmt: str, amount: int = 1, offset: int = None, byte_order: str = 'native')

Reads a number of mixed types from the input stream.

Parameters:
  • istream (BinaryIO) – The input stream to read from.

  • fmt (str) – The format string to use.

  • amount (int, optional) – The amount of mixed types to read, by default 1.

  • offset (int, optional) – The offset to seek to before reading, by default None.

  • byte_order (str, optional) – The byte order to use, by default “native”.

Returns:

The mixed types read from the input stream.

Return type:

tuple of mixed