qwikstart.utils package¶
Submodules¶
- qwikstart.utils.core module
- qwikstart.utils.dict_utils module
- qwikstart.utils.filesystem module
- qwikstart.utils.http module
- qwikstart.utils.input_types module
- qwikstart.utils.io module
- qwikstart.utils.logging module
- qwikstart.utils.prompt module
- qwikstart.utils.regex module
- qwikstart.utils.templates module
- qwikstart.utils.text_utils module
Module contents¶
-
qwikstart.utils.
create_regex_flags
(flag_strings: List[str]) → re.RegexFlag¶
-
qwikstart.utils.
ensure_path
(path: Union[pathlib.Path, str]) → pathlib.Path¶ Return path object from
pathlib.Path
or string.While
Path
can be called on strings orPath
and return aPath
, it does not behave correctly for mock path instances. This helper function ensures we can support normal usage and mocked paths used for testing.
-
qwikstart.utils.
first
(iterable: Iterable[T]) → T¶
-
qwikstart.utils.
clean_multiline
(multiline_text: str) → str¶ Return multiline string after dedenting and with empty lines stripped.
-
qwikstart.utils.
full_class_name
(obj: Any) → str¶
-
qwikstart.utils.
get_dataclass_keys
(dataclass: Any) → Iterable[Any]¶
-
qwikstart.utils.
get_dataclass_values
(dataclass: Any) → Iterable[Any]¶
-
qwikstart.utils.
indent
(text: str, space_count: int) → str¶ Return
text
indented byspace_count
spaces.
-
qwikstart.utils.
merge_nested_dicts
(default: Mapping[str, Any], overwrite: Mapping[str, Any], inplace: bool = False) → Dict[str, Any]¶ Return new dictionary from the combination of
default
andoverwrite
.Dict values that are dictionaries themselves will be updated, whilst preserving existing keys.
- Parameters
default – Dictionary containing default values
overwrite – Dictionary containing values that will overwrite default values.
inplace – If True, the
default
dictionary will be modified in-place. Otherwise, a new dictionary will be returned.
Adapted from
cookiecutter.config.merge_configs
.
-
qwikstart.utils.
pformat_json
(data: Dict[Any, Any]) → str¶ Return pretty-formatted string from dictionary assuming json serializable data.
See https://stackoverflow.com/q/3229419 for other printing options.
-
qwikstart.utils.
remap_dict
(original_dict: Mapping[str, Any], key_mapping: Mapping[str, str], nested_key_separator: str = '.') → Dict[str, Any]¶ Return dict with any keys in
key_mapping
renamed.- Parameters
original_dict – Dictionary with keys to be renamed.
key_mapping – Dictionary mapping keys in
original_dict
to new keys. Any keys not inkey_mapping
are returned unchanged.nested_key_separator – Separator used in keys in
key_mapping
to specify nested dictionaries.
-
qwikstart.utils.
strip_empty_lines
(text: Optional[str]) → str¶ Return multi-line string with leading and trailing empty lines stripped.