2 from __future__
import annotations
4 from typing
import Any, List, Optional, Sequence
6 logger = logging.getLogger(__name__)
12 def __init__(self, name: str, x_pos: int, parent=
None) ->
None:
13 self.name: str = f
"{name}"
14 self.
x_pos: int = x_pos
15 self.parent: GroupingElement = parent
16 self.show_children: bool =
False
19 self.replaced: bool =
False
25 self.parent.show_children =
True
43 if parent.get_name() == name_string:
45 parent = parent.parent
51 base = self.parent.hash + base
58 while parent
and parent.marked:
61 parent = parent.parent
77 return " " if not self.
checked else "X"
89 class GroupingElement(Element):
91 self, name: str, x_pos: int, parent: GroupingElement =
None
93 super().
__init__(name, x_pos, parent)
94 self.children: List[Element] = []
97 return [el.name
for el
in self.children]
100 matched =
list(
filter(
lambda el: el.name == name, self.children))
108 for child
in self.children:
109 if child.check_filter(filter_text):
114 self.children.
append(child)
119 for child
in self.children:
120 child.update_xpos(new_xpos + INDENT)
124 for child
in self.children:
128 self.children.sort(key=
lambda c: c.get_name().lower())
129 for child
in self.children:
130 if isinstance(child, GroupingElement):
131 child.sort_children()
137 return f
"[{self.get_mark_character()}] {self.get_name()}"
142 return filter_text
in self.
get_name()
145 return str(self.name).
split(
"/")[-1]
148 return "-" if not self.
checked else "*"
151 return f
" {self.get_mark_character()} {self.get_name()}"
156 self, name: str, x_pos: int, value: Any, parent: Element =
None
158 """Value must be initialized first as it is used in hash generating"""
159 self.value: Any = value
160 super().
__init__(name, x_pos, parent)
163 return f
"{self.name} = {self.value}"
166 return str(self.value).
split(
"/")[-1]