Skip to content

Utilities

quote_identifier

quote_identifier(identifier: str, quote_character: str = '"') -> str

Quotes the given identifier by surrounding it with the specified quote character.

Parameters:

Name Type Description Default
identifier str

The identifier to be quoted.

required
quote_character str

The character to use for quoting. Defaults to '"'.

'"'

Returns:

Type Description
str

The quoted identifier.

Example
quote_identifier("my_object")
'"my_object"'
quote_identifier("my_object", "'")
"'my_object'"

to_snake_case

to_snake_case(text: str) -> str

Convert a string to snake case.

Parameters:

Name Type Description Default
text str

The string to convert to snake case. Can be converted from PascalCase, camelCase, kebab-case, or mixed case. Non-alphanumeric characters are converted to underscores.

required

Returns:

Type Description
str

The string in snake case.

Example
to_snake_case("CustomerID")
"customer_id"

character_translation

character_translation(text: str, translation_map: dict[str, str]) -> str

Translate characters in a string using a translation map.

Parameters:

Name Type Description Default
text str

The string to translate.

required
translation_map dict[str, str]

A dictionary mapping characters to their replacements.

required

Returns:

Type Description
str

The translated string.

Example
character_translation("Profit&Loss", {"&": "_and"})
"Profit_and_Loss"