snowshu.core.utils

snowshu.core.utils.case_insensitive_dict_value(dictionary, caseless_key) → Any

finds a key in a dict without case sensitivity, returns value.

Searches for the FIRST match (insensitive dict keys can have multiple matches) and returns that value.

Parameters
  • dictionary (-) – The dictionary to traverse.

  • caseless_key (-) – The key case-insensitive search the dictionary for.

Returns

the value of insensitive key. Raises KeyError if not found.

snowshu.core.utils.correct_case(val: str, upper: bool = True)

Returns the case corrected value based on general sql identifier rules

If the value is entirely one case, made up of only word characters and doesn’t begin with a number, we can conform the case

Parameters
  • val (-) – string that is the value to correct case for

  • upper (-) – flag to determine the case to conform to. Defaults to True (uppercase)

Returns

the case corrected value

snowshu.core.utils.fetch_adapter(name: str, section: str) → Union[Type[BaseSourceAdapter], Type[BaseTargetAdapter], Type[BaseSQLAdapter]]

Locates and returns the specified adapter.

Parameters
  • name – The name of the adapter to look up.

  • section – One of (‘source’,’target’,’storage’).

Returns

The adapter if found, raises AdapterNotFound.

snowshu.core.utils.get_config_value(parent: dict, key: str, envar: Optional[str] = None, parent_name: Optional[str] = None) → Any
snowshu.core.utils.get_multiarch_list(local_arch: str) → List[str]

Finds an opposite arch to the one passed here and returns both as a list, ordered in a way that passed arch is first

snowshu.core.utils.key_for_value(dictionary, value)

finds the key for a given value in a dict.

snowshu.core.utils.load_from_file_or_path(loadable: Union[pathlib.Path, str, TextIO]) → dict
snowshu.core.utils.remove_dangling_replica_containers() → None

Cleans up existing containers in situation of a failed build