Module zut

Reusable Python utilities.

Functions

fix_restricted_xml_control_characters(text)

Replace invalid XML control characters.

fix_utf8_surrogateescape(text[, ...])

Fix potential encoding issues for files open with file.open('r', encoding='utf-8', errors='surrogateescape').

get_logger(obj)

get_secret_value(name[, default])

human_bytes(value, *[, unit, divider, ...])

Get a human-readable representation of a number of bytes.

human_number(value, *[, unit, divider, ...])

Get a human-readable representation of a number.

is_secret_defined(name)

log_warnings(*[, ignore, logger])

read_bytes(path, *[, sudo])

Open the file in bytes mode, read it, and close the file.

read_text(path, *[, encoding, errors, ...])

Open the file in text mode, read it, and close the file.

skip_utf8_bom(fp[, encoding])

Skip UTF8 byte order mark, if any.

slugen(value[, separator, keep])

Similar as slugify except than some defaults are changed compared to Django's version and some additional letters are handled.

slugify(value, *[, separator, keep, ...])

Generate a slug.

slugify_snake(value[, separator, if_none, ...])

CamèlCase => camel_case

write_bytes(path, data, *[, sudo])

Open the file in bytes mode, write to it, and close the file.

write_text(path, data, *[, encoding, ...])

Open the file in text mode, write to it, and close the file.

Classes

Color()

DelayedStr(*args, **kwargs)

Secret(name[, default])

Exceptions

SecretNotFound(name)

SimpleError(msg, *args, **kwargs)

An error that should result to only an error message being printed on the console, without a stack trace.