csb43.utils
¶
Note
license: GNU Lesser General Public License v3.0 (see LICENSE)
- csb43.utils.b_left_pad(bvalue: bytes, n: int, fill=b' ') bytes ¶
pad with fill chars at the leftside and return a record of n chars
- csb43.utils.b_right_pad(bvalue: bytes, n: int, fill=b' ') bytes ¶
pad with fill chars at the rightside and return a record of n chars
- csb43.utils.export_currency_code(value) str ¶
export currency code as string
- csb43.utils.export_date(value) str ¶
export a date as a string
- csb43.utils.export_decimal(value: Decimal, fallback: T | None = None) Decimal | float | str | T ¶
export decimal as a serializable type
- csb43.utils.nullable(f)¶
nullable decorator
Return None if function value is None
- class csb43.utils.currency.AnyCurrency(*args, **kwargs)¶
protocol for a currency object compatible with pycountry
- class csb43.utils.currency.CurrencyLite(alpha_3: str | None, numeric: str | None)¶
cheap alternative to pycountry Currency
- csb43.utils.currency.currency_from_iso_code(code: str) AnyCurrency | None ¶
Return AnyCurrency from an ISO 4217 numeric or letter code Return None if no code was found
- csb43.utils.currency.currency_from_iso_letter(alpha_3: str) AnyCurrency ¶
Return a currency object from an alpha_3 ISO 4217 code.
- csb43.utils.currency.currency_from_iso_number(numeric: str | None) AnyCurrency | None ¶
Return a currency object from a numeric ISO 4217 code.
- csb43.utils.currency.is_currency(obj) bool ¶
return True is obj is a currency object
- csb43.utils.currency.simplify_currency(obj: AnyCurrency) CurrencyLite ¶
convert currency to CurrencyLite
- csb43.utils.currency.yaml_currency_representer(dumper, obj: AnyCurrency)¶
a yaml representer for AnyCurrency
functions for tabulated strings manipulation
- csb43.utils.tabulated.adjust_table_width(data: Sequence[str], delim='||', gap=1, indent=0) Iterator[str] ¶
adjust width for columns marked by sep