TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/alex-ber/AlexBerUtils/llms.txt
Use this file to discover all available pages before exploring further.
parsers module provides the foundational parsing primitives used by init_app_conf and other modules. It also monkey-patches configparser.ConfigParser and argparse.ArgumentParser with convenience as_dict() methods.
safe_eval
Converts a string representation of a Python number to its correct built-in numeric type.String to evaluate. Processed with
ast.literal_eval; if that raises SyntaxError or ValueError, the original string is returned unchanged.int, float, or the original value when conversion is not possible. Does not support decimal.Decimal, datetime, or NumPy types.
is_empty
Checks whether a value isNone or an empty iterable.
Value to check. Behaviour is undefined for non-iterable, non-
None values.bool — True if the value is None or an empty iterable, False otherwise.
parse_boolean
Converts a value tobool with case-insensitive string matching.
Value to convert. A
bool is returned as-is. A str equal to 'true' or 'false' (case-insensitive) returns the corresponding bool. Any other string raises ValueError.bool | None — True, False, or None when the input is None.
Raises: ValueError — when the string cannot be interpreted as a boolean.
parse_sys_args
Parses command-line arguments and returns both typed params and a raw flat dictionary of unknown arguments.Optional
argparse.ArgumentParser instance. If not supplied, a new one is created. The function adds --general.config.file to it before parsing.If not
None, suppresses sys.argv and uses this list as the argument source.(params, sys_d) — params is the argparse.Namespace (with .config_file populated), sys_d is an OrderedDict of remaining --key=value arguments.
ConfigParser.as_dict
Monkey-patched method added toconfigparser.ConfigParser. Converts all sections and their key/value pairs into an OrderedDict of OrderedDicts.
OrderedDict[str, OrderedDict[str, str]] — all sections with their string key/value pairs.
ArgumentParser.as_dict
Monkey-patched method added toargparse.ArgumentParser. Parses arguments of the form --key=value and returns them as a flat OrderedDict, stripping the -- prefix.
Argument list to parse. If
None, sys.argv[1:] is used (note: sys.argv[0] is always ignored).OrderedDict[str, str | None] — keys without the -- prefix; value is None for bare flags with no =.