TagTree
¶
- class mnemosyne.libmnemosyne.tag_tree.TagTree(component_manager, count_cards=True)¶
Organises the tags in a hierarchical tree. By convention, hierarchical levels in tags are denoted by a :: separator.
This class is not meant to be instantiated at run time, but rather only when it is needed.
The internal tree datastructure for e.g. the two tags A::B::C and A::B::D looks as follows:
self[“__ALL__”] = [“A”] self[“A”] = [“A::B”] self[“A::B”] = [“A::B::C”, “A::B::D”]
Each tree level stores the entire partial tag (i.e. A::B instead of B) to guarantee uniqueness.
Apart from the dictionary in self, this class also contains self.display_name_for_node and self.card_count_for_node, with node being the index field for the main dictionary self.
- delete_subtree(node)¶
- nodes()¶
Also returns internal nodes, even if they have no explicit tag associated with them.
- nodes_in_subtree(tree)¶
- rename_node(node, new_name)¶
- tags_in_subtree(node)¶