bw2data.backends.typos
#
Module Contents#
Functions#
|
Checks keys of a dictionary obj against a set of valid keys. If a key |
|
Validates the type_value against a set of valid types. If the `type_value |
Attributes#
- bw2data.backends.typos._check_keys(obj: dict, kind: str, valid: Iterable[str]) None [source]#
Checks keys of a dictionary obj against a set of valid keys. If a key is a close match to any of the valid keys, a warning is raised indicating a possible incorrect key.
Parameters#
- objdict
The dictionary whose keys are to be checked.
- kindstr
The category of the keys being checked (e.g., ‘activity’, ‘exchange’).
- validIterable[str]
An iterable of valid key values.
Raises#
- UserWarning
Warns if a key in obj is not in valid but is close to a valid key.
Examples#
>>> _check_keys({"actvty": "value"}, "activity", ["activity", "process"]) Possible incorrect activity key found: Given `actvty` but `activity` is more common
- bw2data.backends.typos._check_type(type_value: str, kind: str, valid: Iterable[str]) None [source]#
Validates the type_value against a set of valid types. If the `type_value is a close match (based on Damerau-Levenshtein distance) to any of the valid types a warning is raised indicating a possible typo.
Parameters#
- type_valuestr
The type value to be checked.
- kindstr
The category of the type being checked (e.g., ‘activity’, ‘exchange’).
- validIterable[str]
An iterable of valid type values.
Raises#
- UserWarning
Warns if type_value is not in valid but is close to a valid value.
Examples#
>>> _check_type("actvty", "activity", ["activity", "process"]) Possible typo found: Given activity type `actvty` but `activity` is more common
- bw2data.backends.typos.VALID_ACTIVITY_KEYS = ('CAS number', 'activity', 'activity type', 'authors', 'categories', 'classifications', 'code',...[source]#
- bw2data.backends.typos.VALID_ACTIVITY_TYPES = ('process', 'emission', 'natural resource', 'product', 'economic', 'inventory indicator')[source]#
- bw2data.backends.typos.VALID_EXCHANGE_KEYS = ('activity', 'amount', 'classifications', 'code', 'comment', 'flow', 'input', 'loc', 'maximum',...[source]#