smartie.structures module

class smartie.structures.c_uint128(value: int = 0)[source]

Bases: Structure

Utility shim to make it easier to work with 128-bit integers.

high

Structure/Union member

low

Structure/Union member

property value: int
smartie.structures.embed_bytes(data: bytes, *, indent=0, char='    ', max_width=80) str[source]

Pretty-prints data in such a way that it can be embedded cleanly in a Python file.

This exists to embed SCSI commands and responses into tests.

Parameters:
  • data – The binary data to be formatted.

  • indent – The number of characters to indent each line.

  • char – The character to use for indentation.

  • max_width – The maximum length of each line.

Returns:

The formatted result.

smartie.structures.pprint_structure(s: Structure)[source]

Debugging utility method to pretty-print a ctypes.Structure.

smartie.structures.structure_to_dict(s: Structure) Dict[str, Any][source]

Converts a ctypes.Structure into a dictionary.

smartie.structures.swap_bytes(src)[source]
smartie.structures.swap_int(c: int, n: int) int[source]