cliconfig.tag_routines
Routines to manipulate the tags on the keys of a dict.
Used by the processing functions.
- clean_tag(flat_key, tag_name)
Clean a tag from a flat key.
It removes all occurrences of the tag with the exact name.
- Parameters:
- Returns:
flat_key – The cleaned flat key.
- Return type:
Note
tag_name
is supposed to be the exact name of the tag.Examples
>>> clean_tag('abc@tag.def@tag_2.ghi@tag', 'tag') abc.def@tag_2.ghi
- clean_all_tags(flat_key)
Clean all tags from a flat key.
- dict_clean_tags(flat_dict)
Clean a dict from all tags and return the list of keys with tags.
- is_tag_in(flat_key, tag_name, *, full_key=False)
Check if a tag is in a flat key.
The tag name must be the exact name, with or without the “@”. It supports the case where there are other tags that are prefixes or suffixes of the considered tag.
- Parameters:
flat_key (str) – The flat key to check.
tag_name (str) – The name of the tag to check, with or without the ‘@’ prefix.
full_key (bool, optional) – If True, check for the full key. If False, check for the last part of the flat key (after the last dot) that correspond to the parameter name. By default, False.
- Returns:
True if the tag is in the flat key, False otherwise.
- Return type: