module documentation

Common utilies (mostly of the string variety)

Function hex_format Helper function for formatting hex data
Function mode_format Format a Flags field akin to an on-calc mode selection
Function replacer Iteratively applies string replacements
Function split_case Splits a string in any of several naming cases into separate words
Function squash Removes all spaces from a string
Function trim_list Trim a list to some length (from the right), then join it, indicating if any trimming occurred by an ellipsis
Function trim_string Trim a string (from the right) to some length, indicating if any trimming occurred by an ellipsis
def hex_format(data: bytes, format_spec: str) -> str: (source)

Helper function for formatting hex data

The format specifier takes the form {width}?{case}{sep}?. - width is the width of groups of hex digits; negative values group from the end (defaults to no groups) - case is x or X to dictate the case of the hex digits - sep is a single character to separate groups of hex digits (defaults to none)

Parameters
data:bytesThe data to format
format_spec:strThe f-string specifier to format the hexdump
Returns
strdata formatted in hex with some width, case, and separator
def mode_format(flags: Flags, *options: str) -> str: (source)

Format a Flags field akin to an on-calc mode selection

Parameters
flags:FlagsThe Flags field to format
*options:strThe names of the mode options to show
Returns
strThe contents of flags formatted as a mode selection
def replacer(string: str, replacements: dict[str, str]) -> str: (source)

Iteratively applies string replacements

Parameters
string:strThe input string
replacements:dict[str, str]The replacements to make
Returns
strstring with all replacements made in-order
def split_case(string: str) -> list[str]: (source)

Splits a string in any of several naming cases into separate words

Parameters
string:strThe input string
Returns
list[str]The words forming string
def squash(string: str) -> str: (source)

Removes all spaces from a string

Parameters
string:strThe input string
Returns
strstring with all spaces removed
def trim_list(lst: list, length: int, joiner: str = '\n') -> str: (source)

Trim a list to some length (from the right), then join it, indicating if any trimming occurred by an ellipsis

Parameters
lst:listThe list to trim
length:intThe length to trim lst to
joiner:strThe string to join lst by (defaults to a newline)
Returns
strlst trimmed to length and joined by joiner
def trim_string(string: str, length: int) -> str: (source)

Trim a string (from the right) to some length, indicating if any trimming occurred by an ellipsis

Parameters
string:strThe string to trim
length:intThe length to trim string to
Returns
strstring trimmed to length