phystool.tags

Module Contents

Classes

Tags

This class allows to tag PDBFiles with user defined tags sorted by custom categories.

Data

logger

API

phystool.tags.logger

“getLogger(…)”

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

This class allows to tag PDBFiles with user defined tags sorted by custom categories.

Warning:

Directly creating an instance without using Tags.validate could lead to unwanted tags.

Paramètres:

tags – tags sorted by category

Initialization

TAGS: ClassVar[phystool.tags.Tags]

None

classmethod validate(list_of_tags: str) Self

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 load() None

Load the static variable Tags.TAGS from the file config.TAGS_PATH that contains all valid tags. If the file does not exist, it will be recreated by calling Tags.reset_all_tags()

classmethod save() None
classmethod reset_all_tags() None

Read all « .json » metadata files to extract all tags and save the result in config.TAGS_PATH so that it can be easily reloaded by calling Tags.load()

classmethod create_new_tag(category: str, tag: str) None

Create a new tag and add it to Tags.TAGS

Paramètres:
  • category – the category of the tag

  • tag – name of the tag

list_tags() None

Prints each tag on a different line.

with_overlap(other: Self) bool

Returns False for the first category where there isn’t any shared 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).

without_overlap(other: Self) bool

Returns False for the first category where there is at least one shared 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).