Node¶
-
class
pyrubrum.
Node
(menu: pyrubrum.menus.base_menu.BaseMenu, children: Optional[Set[Node]] = None)¶ Representation of a single object in a tree, which might have defined a parent (i.e. the
Node
object it is child of) and a set of other nodes, which are its children. EachNode
instance is linked to a subclass ofBaseMenu
.- Parameters
-
add_child
(node: pyrubrum.tree.node.Node)¶ Add a
Node
instance to the set of children.- Parameters
node (Node) – The node which is being added as a child of this object.
Get all the menus that are linked to the children belonging to this instance.
- Returns
A tuple that contains all the retrieved menus.
- Return type
Iterable[BaseMenu]
-
get_family
(menu_id: str, parent: Optional[Node]) → Tuple[Optional[pyrubrum.menus.base_menu.BaseMenu], Optional[Set[pyrubrum.menus.base_menu.BaseMenu]]]¶ Retrieve the menus which are linked to both parent and children of this instance if this instance matches the provided identifier. Otherwise it will search the menu matching it in its children and return its family, if matched. On failure, it will return a tuple of length two filled with null values (i.e.
None
).- Parameters
- Returns
A tuple of length two, whose first element is the parent node of the matched node while the second one is a tuple of all its children If no
Node
is found, the tuple will be filled with null values (i.e.None
).- Return type
Retrieve the set of all the menus which are linked to the nodes belonging to the descent of this class (i.e. the children, the children of the children, etc…).
- Returns
The set of all the retrieved menus.
- Return type
Set[BaseMenu]