scopesim.utils.check_keys#
- scopesim.utils.check_keys(input_dict: Mapping | Iterable, required_keys: Set, action: Literal['error', 'warn', 'warning'] = 'error', all_any: Literal['all', 'any'] = 'all') bool#
Check to see if all/any of the required keys are present in a dict.
Changed in version v0.8.0: The required_keys parameter should now be a set.
- Parameters:
input_dict (Mapping | Iterable) – The mapping to be checked.
required_keys (Set) – Set containing the keys to look for.
action ({"error", "warn", "warning"}, optional) – What to do in case the check does not pass. The default is “error”.
all_any ({"all", "any"}, optional) – Whether to check if “all” or “any” of the required_keys are present. The default is “all”.
- Raises:
ValueError – Raised when an invalid parameter was passed or when action was set to “error” (the default) and the required_keys were not found.
- Returns:
keys_present –
Trueif check succeded,Falseotherwise.- Return type: