pystructtype.utils ================== .. py:module:: pystructtype.utils .. autoapi-nested-parse:: utils: Utility functions for pystructtype. Attributes ---------- .. autoapisummary:: pystructtype.utils.C Functions --------- .. autoapisummary:: pystructtype.utils.list_chunks pystructtype.utils.int_to_bool_list Module Contents --------------- .. py:data:: C .. py:function:: list_chunks[C](_list: list[C], n: int) -> collections.abc.Generator[list[C]] Yield successive n-sized chunks from a list. :param _list: List to chunk out :param n: Size of chunks (must be > 0) :return: Generator of n-sized chunks of _list :raises ValueError: If n <= 0 .. py:function:: int_to_bool_list(data: int | list[int], byte_length: int) -> list[bool] Converts an integer or a list of integers into a list of bools representing the bits. The result is in reverse order so that the Least Significant Bit is in list position 0. ex. ord("A") or 0b01000001 = [True, False, False, False, False, False, True, False] ex. [ord("A"), ord("B")] or [0b01000001, 0b01000010]= [False, True, False, False, False, False, False, True, False, True, False, False, False, False, True, False] :param data: Integer(s) to be converted :param byte_length: Number of bytes to extract from integer(s) :return: List of bools representing each bit in the data