phystool.tags

Module Contents

Classes

Tags

Helper class that manages tags.

Data

logger

API

phystool.tags.logger

“getLogger(…)”

class phystool.tags.Tags(tags: dict[str, set[str]])

Helper class that manages tags.

Paramètres:

tags – tags sorted by category

Initialization

classmethod validate(list_of_tags: str) phystool.tags.Tags

Converts a string of comma separated words into a valid Tags instance.

The string is split after each comma. If the words in the resulting list are valid tags, they will be sorted by category.

Paramètres:

list_of_tags – string of comma separated words

Renvoie:

a Tags instance with only valid sorted tags

classmethod TAGS(force_reload: bool = False) phystool.tags.Tags

Contains all available tags.

If the class doesn’t have an attribute « _TAGS » or if force_reload is True, the Tags are loaded from the SQL database.

Paramètres:

force_reload – reload the tags from the SQL database.

Renvoie:

all available tags

classmethod create_new_tag(category_name: str, tag_name: str) None

Create a new tag

Paramètres:
  • category_name – name of the category’s tag

  • tag_name – name of the tag

classmethod from_ids(pks: list[int]) phystool.tags.Tags
list_tags() None

Prints each tag on a different line.

as_ids() set[int]
with_overlap(other: phystool.tags.Tags) bool

Returns False if a category doesn’t share any tag between this instance and the other instance, otherwise, returns True

Warning:

Returns False if, for any category, either set or the two sets are empty (should not happen in the code).

without_overlap(other: phystool.tags.Tags) bool

Returns False if a category shares at least one tag between this instance and the other instance, otherwise, returns True

Warning:

Doesn’t necessarily return True if, for a given category, either set or the two sets are empty (should not happen in the code).