Skip to main content

utils.strings

human_readable_file_size

def human_readable_file_size(size: int, suffix="B") -> str

Converts a file size to a human-readable string.

Arguments:

  • size - The file size to convert.
  • suffix - Default suffix.

Returns:

The human-readable file size.

format_elapsed_time

def format_elapsed_time(elapsed: float) -> str

Converts a number of seconds into a readable string.

Arguments:

  • elapsed - The elapsed time in seconds.

Returns:

The string representation.

ensure_starts_with

def ensure_starts_with(s: str, start: str) -> str

Ensures that a string starts with a given string.

Arguments:

  • s - The string.
  • start - The start to ensure.

Returns:

The new string.