ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
python.iconfTool.models.structure.ComponentsStructure Class Reference
Inheritance diagram for python.iconfTool.models.structure.ComponentsStructure:
Collaboration diagram for python.iconfTool.models.structure.ComponentsStructure:

Public Member Functions

None __init__ (self, Dict flags_dict, Set checked_elements)
 
None replace_references (self, GroupingElement element)
 
None generate (self, int x_pos=1, structure_dict=None)
 
List[Element] group_elements (self, List[Element] structure_list, int x_pos)
 
List[Element] get_list (self)
 
None filter_by_text (self, str filter_text)
 
None sort (self)
 
Dict generate_structure_dict (self)
 
None generate_for_element (self, GroupingElement grouping_element, Dict structure)
 
None add_to_checked (self, Element element)
 
None remove_from_checked (self, Element element)
 

Public Attributes

 structure_dict
 
 structure_list
 
 filter
 

Detailed Description

Definition at line 101 of file structure.py.

Constructor & Destructor Documentation

◆ __init__()

None python.iconfTool.models.structure.ComponentsStructure.__init__ (   self,
Dict  flags_dict,
Set  checked_elements 
)

Definition at line 102 of file structure.py.

102  def __init__(self, flags_dict: Dict, checked_elements: Set) -> None:
103  super().__init__(flags_dict, checked_elements)
104  self.roots_dict: Dict = {}
105  self.structure_list: List[Element] = []
106  self.filter: ComponentsStructureFilter # Filter object used in search
107 

Member Function Documentation

◆ add_to_checked()

None python.iconfTool.models.structure.Structure.add_to_checked (   self,
Element  element 
)
inherited

Definition at line 91 of file structure.py.

91  def add_to_checked(self, element: Element) -> None:
92  hash_value = element.hash
93  self.checked_elements.add(hash_value)
94 

◆ filter_by_text()

None python.iconfTool.models.structure.ComponentsStructure.filter_by_text (   self,
str  filter_text 
)

Definition at line 183 of file structure.py.

183  def filter_by_text(self, filter_text: str) -> None:
184  self.filter.generate_by_text(filter_text)
185  for element in self.structure_list:
186  assert isinstance(element, GroupingElement)
187  element.children = list(
188  filter(
189  lambda child: child.get_reference_name()
190  in self.filter.comps_to_save
191  or child not in self.roots_dict,
192  element.children,
193  )
194  )
195 

◆ generate()

None python.iconfTool.models.structure.ComponentsStructure.generate (   self,
int   x_pos = 1,
  structure_dict = None 
)

Definition at line 121 of file structure.py.

121  def generate(self, x_pos: int = 1, structure_dict=None) -> None:
122 
123  self.structure_dict = structure_dict or self.generate_structure_dict()
124  for root_name in self.structure_dict:
125  if isinstance(self.structure_dict[root_name], dict):
126  root_group = GroupingElement(root_name, x_pos)
127  if root_group.hash in self.checked_elements:
128  root_group.set_as_checked()
129  self.generate_for_element(
130  root_group, self.structure_dict[root_name]
131  )
132  self.structure_list.append(root_group)
133  self.roots_dict[root_name] = root_group
134 
135  self.structure_list = self.group_elements(
136  self.structure_list, x_pos - 1
137  )
138 
139  self.sort()
140  self.filter = ComponentsStructureFilter(self.structure_dict)
141 

◆ generate_for_element()

None python.iconfTool.models.structure.Structure.generate_for_element (   self,
GroupingElement  grouping_element,
Dict   structure 
)
inherited

Definition at line 56 of file structure.py.

56  def generate_for_element(
57  self, grouping_element: GroupingElement, structure: Dict
58  ) -> None:
59  child_x_pos = grouping_element.x_pos + INDENT
60  for child in structure:
61  try:
62  # Handles situation when list or dict is provided as a string
63  structure[child] = ast.literal_eval(structure[child])
64  except (ValueError, SyntaxError):
65  pass
66 
67  if isinstance(structure[child], dict):
68  group = GroupingElement(child, child_x_pos, grouping_element)
69  if group.hash in self.checked_elements:
70  group.set_as_checked()
71  self.generate_for_element(group, structure[child])
72  grouping_element.add_child(group)
73  elif isinstance(structure[child], list):
74  group = GroupingElement(child, child_x_pos, grouping_element)
75  if group.hash in self.checked_elements:
76  group.set_as_checked()
77  for el in structure[child]:
78  no_value_child = SingleElement(el, child_x_pos + INDENT)
79  if no_value_child.hash in self.checked_elements:
80  no_value_child.set_as_checked()
81  group.add_child(no_value_child)
82  grouping_element.add_child(group)
83  else:
84  flag = ValueElement(
85  child, child_x_pos, structure[child], grouping_element
86  )
87  if flag.hash in self.checked_elements:
88  flag.set_as_checked()
89  grouping_element.add_child(flag)
90 

◆ generate_structure_dict()

Dict python.iconfTool.models.structure.Structure.generate_structure_dict (   self)
inherited
Split dictionary keys into nested structure
e.g. Test1.Test2: Value -> Test1: {Test2: Value}

Definition at line 27 of file structure.py.

27  def generate_structure_dict(self) -> Dict:
28  """Split dictionary keys into nested structure
29  e.g. Test1.Test2: Value -> Test1: {Test2: Value}
30  """
31  structure_dict: Dict = {}
32 
33  for flag, value in self.flags_dict.items():
34  groups = flag.split(".")
35  structure_point = structure_dict
36  for i in range(len(groups) - 1):
37  if groups[i] not in structure_point:
38  structure_point[groups[i]] = {}
39  elif isinstance(structure_point[groups[i]], str):
40  structure_point[groups[i]] = {
41  structure_point[groups[i]]: {}
42  }
43  structure_point = structure_point[groups[i]]
44  if groups:
45  last = groups[-1]
46  if (
47  last in structure_point
48  and isinstance(structure_point[last], dict)
49  and isinstance(value, dict)
50  ):
51  structure_point[last].update(value)
52  else:
53  structure_point[last] = value
54  return structure_dict
55 

◆ get_list()

List[Element] python.iconfTool.models.structure.ComponentsStructure.get_list (   self)

Definition at line 179 of file structure.py.

179  def get_list(self) -> List[Element]:
180  self.filter.reset()
181  return self.structure_list
182 

◆ group_elements()

List[Element] python.iconfTool.models.structure.ComponentsStructure.group_elements (   self,
List[Element]  structure_list,
int   x_pos 
)

Definition at line 142 of file structure.py.

142  def group_elements(
143  self, structure_list: List[Element], x_pos: int
144  ) -> List[Element]:
145 
146  algs = GroupingElement("Algorithms and Sequences", x_pos)
147  tools = GroupingElement("Public tools", x_pos)
148  settings = GroupingElement("Application Settings and Services", x_pos)
149 
150  new_structure_list: List[Element] = [algs, tools, settings]
151 
152  seq_names = []
153 
154  def get_ath_sequences(el) -> None:
155  if isinstance(el, GroupingElement):
156  members_obj = el.get_child_by_name("Members")
157  if members_obj:
158  assert isinstance(members_obj, GroupingElement)
159  for member in members_obj.children:
160  ref_name = member.get_reference_name()
161  seq_names.append(ref_name)
162  get_ath_sequences(self.roots_dict.get(ref_name))
163 
164  seq_names.append("AthMasterSeq")
165  get_ath_sequences(self.roots_dict["AthMasterSeq"])
166 
167  for el in structure_list:
168  if el.name == "AthMasterSeq":
169  algs.add_child(el)
170  elif (
171  el.name == "ToolSvc"
172  ): # any of ToolSvc children is not present in roots dict
173  tools.add_child(el)
174  elif el.name not in seq_names:
175  settings.add_child(el)
176 
177  return new_structure_list
178 

◆ remove_from_checked()

None python.iconfTool.models.structure.Structure.remove_from_checked (   self,
Element  element 
)
inherited

Definition at line 95 of file structure.py.

95  def remove_from_checked(self, element: Element) -> None:
96  hash_value = element.hash
97  if hash_value in self.checked_elements:
98  self.checked_elements.remove(hash_value)
99 
100 

◆ replace_references()

None python.iconfTool.models.structure.ComponentsStructure.replace_references (   self,
GroupingElement  element 
)

Definition at line 108 of file structure.py.

108  def replace_references(self, element: GroupingElement) -> None:
109  element.replaced = True
110  for i, child in enumerate(element.children):
111  if isinstance(child, SingleElement):
112  ref_name = child.get_reference_name()
113  if ref_name in self.roots_dict and not element.has_parent(
114  self.roots_dict[ref_name].get_name()
115  ):
116  element.children[i] = self.roots_dict[ref_name]
117 
118  element.children[i].parent = element
119  element.update_xpos(element.x_pos)
120 

◆ sort()

None python.iconfTool.models.structure.ComponentsStructure.sort (   self)

Definition at line 196 of file structure.py.

196  def sort(self) -> None:
197  self.structure_list.sort(key=lambda el: el.get_name().lower())
198  for element in self.structure_list:
199  element.sort_children()
200 
201 

Member Data Documentation

◆ filter

python.iconfTool.models.structure.ComponentsStructure.filter

Definition at line 140 of file structure.py.

◆ structure_dict

python.iconfTool.models.structure.ComponentsStructure.structure_dict

Definition at line 123 of file structure.py.

◆ structure_list

python.iconfTool.models.structure.ComponentsStructure.structure_list

Definition at line 135 of file structure.py.


The documentation for this class was generated from the following file:
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
covarianceTool.filter
filter
Definition: covarianceTool.py:514
PixelModuleFeMask_create_db.remove
string remove
Definition: PixelModuleFeMask_create_db.py:83
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
add
bool add(const std::string &hname, TKey *tobj)
Definition: fastadd.cxx:55
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
python.MadGraphUtils.generate
def generate(process_dir='PROC_mssm_0', grid_pack=False, gridpack_compile=False, extlhapath=None, required_accuracy=0.01, runArgs=None, bias_module=None, requirePMGSettings=False)
Definition: MadGraphUtils.py:385
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:79
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
dqt_zlumi_pandas.update
update
Definition: dqt_zlumi_pandas.py:42
CxxUtils::reset
constexpr std::enable_if_t< is_bitmask_v< E >, E & > reset(E &lhs, E rhs)
Convenience function to clear bits in a class enum bitmask.
Definition: bitmask.h:243
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127