utils

Utilities for the application.

General utility functions.

src.utils.camel_case(string: str) str[source]

Convert a string to camel case.

Parameters:

string – The string to convert.

Returns:

The camel cased string.

src.utils.case_insensitive_string_compare(a: str, b: str, /) bool[source]

Compare two strings case insensitively.

Parameters:
  • a – The first string.

  • b – The second string.

Returns:

Whether the strings are equal.

src.utils.dataclass_as_dict_shallow(dataclass: Any, *, exclude_none: bool = False) dict[str, Any][source]

Convert a dataclass to a dict.

Parameters:
  • dataclass – The dataclass to convert.

  • exclude_none – Whether to exclude None values.

Returns:

The dataclass as a dict.

src.utils.import_string(dotted_path: str) Any[source]

Import a class/function from a dotted path.

Parameters:

dotted_path – The dotted path to the class/function.

Returns:

The imported class/function.

src.utils.module_to_os_path(dotted_path: str = 'src') Path[source]

Get the path to a module.

Parameters:

dotted_path – The dotted path to the module.

Returns:

The path to the module.

src.utils.slugify(value: str, allow_unicode: bool = False, separator: str | None = None) str[source]

Convert a string to a slug.

Parameters:
  • value – The string to slugify.

  • allow_unicode – Whether to allow unicode characters.

  • separator – The separator to use.

Returns:

The slugified string.