accessories
Accessory functions.
- TRACE = 5
Custom TRACE log level, below DEBUG (10).
- encoding_from_lang(lang)[source]
Parse encoding from LANG environment value.
Returns the encoding portion if present, or None if the LANG value does not contain an encoding suffix (no ‘.’ separator).
- Parameters:
lang (
str) – LANG environment value (e.g., ‘en_US.UTF-8@misc’)- Return type:
- Returns:
Encoding string (e.g., ‘UTF-8’) or None if no encoding found.
Example:
>>> encoding_from_lang('en_US.UTF-8@misc') 'UTF-8' >>> encoding_from_lang('en_IL') None
- eightbits(number)[source]
Binary representation of
numberpadded to 8 bits.Example:
>>> eightbits(ord('a')) '0b01100001'
- Return type:
- hexdump(data, prefix='')[source]
Format data as
hexdump -Cstyle output.Each 16-byte row shows the offset, hex bytes grouped 8+8, and printable ASCII on the right:
00000000 48 65 6c 6c 6f 20 57 6f 72 6c 64 0d 0a |Hello World..|
- make_logger(name, loglevel='info', logfile=None, logfmt='%(levelname)s %(filename)s:%(lineno)d %(message)s', filemode='a')[source]
Create and return simple logger for given arguments.
- Return type:
- repr_mapping(mapping)[source]
Return printable string, ‘key=value [key=value …]’ for mapping.
- Return type: