bundle.core.utils

Attributes

Functions

ensure_path(→ pathlib.Path)

Ensures existence of a path's directories. For file paths, creates missing parent directories.

format_duration_ns(→ str)

Formats a duration in nanoseconds to a human-readable string.

format_date_ns(→ str)

Converts a timestamp in nanoseconds to a formatted UTC date string.

Module Contents

bundle.core.utils.logger
bundle.core.utils.ensure_path(path: pathlib.Path | str) pathlib.Path[source]

Ensures existence of a path’s directories. For file paths, creates missing parent directories. For directory paths, creates the directory if missing. Logs creation actions.

Parameters:

path (Path) – Target file or directory path.

Returns:

Verified path

Return type:

Path

bundle.core.utils.format_duration_ns(ns: int) str[source]

Formats a duration in nanoseconds to a human-readable string.

Converts nanoseconds to days, hours, minutes, seconds, milliseconds, and microseconds, displaying only the non-zero units.

Parameters:

ns (int) – The duration in nanoseconds.

Returns:

The formatted duration string.

Return type:

str

bundle.core.utils.format_date_ns(ns: int) str[source]

Converts a timestamp in nanoseconds to a formatted UTC date string.

Formats the timestamp to include year, month, day, hour, minute, second, and extends to show milliseconds, microseconds, and nanoseconds.

Parameters:

ns (int) – The timestamp in nanoseconds since the Unix epoch.

Returns:

The formatted date string in UTC.

Return type:

str