Skip to the content.

Utils

Auto-generated documentation for dynamo_query.utils module.

ascii_string_generator

[find in source code]

def ascii_string_generator(length: int = 3) -> Iterator[str]:

Generator to build unique strings from “aa…a” to “zz…z”.

gen = ascii_string_generator()
next(gen)  # 'aaa'
next(gen)  # 'aab'
list(gen)[-1]  # 'zzz'

Arguments

Yields

Lowercased ASCII string like “aaa”

chunkify

[find in source code]

def chunkify(data: Iterable[_T], size: int) -> Iterator[List[_T]]:

Splits data to chunks of size length or less.

data = [1, 2, 3, 4, 5]
for chunk in chunkify(data, size=2):
    print(chunk)

# [1, 2]
# [3, 4]
# [5]

Arguments

Returns

A generator of chunks.

get_format_keys

[find in source code]

def get_format_keys(format_string: str) -> Set[str]:

Extract format keys from a formet-ready string.

keys = get_format_keys('key: {key} {value}')
keys # ['key', 'value']

Arguments

Returns

A set of format keys.

get_nested_item

[find in source code]

def get_nested_item(
    dict_obj: Dict[(str, Any)],
    item_path: Iterable[str],
    raise_errors: bool = False,
) -> Any:

Get nested item_path from dict_obj.

Arguments

Raises

pluralize

[find in source code]

def pluralize(count: int, singular: str, plural: Optional[str] = None) -> str:

Pluralize a noun according to count.

Arguments

Returns

A noun in proper form.