ripple-down-rules 0.4.0__py3-none-any.whl → 0.4.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -155,10 +155,23 @@ class CollapsibleBox(QWidget):
155
155
 
156
156
  def toggle(self):
157
157
  is_expanded = self.toggle_button.isChecked()
158
+ self.update_object_diagram(is_expanded)
158
159
  self.toggle_button.setArrowType(
159
160
  Qt.ArrowType.DownArrow if is_expanded else Qt.ArrowType.RightArrow
160
161
  )
161
162
  self.content_area.setVisible(is_expanded)
163
+
164
+ self.update_object_diagram(is_expanded)
165
+
166
+ # toggle children
167
+ if not is_expanded:
168
+ for i in range(self.content_layout.count()):
169
+ item = self.content_layout.itemAt(i)
170
+ if isinstance(item.widget(), CollapsibleBox):
171
+ item.widget().toggle_button.setChecked(False)
172
+ item.widget().toggle()
173
+
174
+ def update_object_diagram(self, is_expanded):
162
175
  if is_expanded and self.viewer is not None:
163
176
  self.viewer.included_attrs.append(self.chain_name)
164
177
  main_obj_name = self.chain_name.split('.')[0]
@@ -173,15 +186,7 @@ class CollapsibleBox(QWidget):
173
186
  main_obj_name = self.chain_name.split('.')[0]
174
187
  main_obj = self.main_obj.get(main_obj_name)
175
188
  self.viewer.update_object_diagram(
176
- main_obj, main_obj_name
177
- )
178
- # toggle children
179
- if not is_expanded:
180
- for i in range(self.content_layout.count()):
181
- item = self.content_layout.itemAt(i)
182
- if isinstance(item.widget(), CollapsibleBox):
183
- item.widget().toggle_button.setChecked(False)
184
- item.widget().toggle()
189
+ main_obj, main_obj_name)
185
190
 
186
191
  def add_widget(self, widget):
187
192
  self.content_layout.addWidget(widget)
@@ -400,15 +405,15 @@ class RDRCaseViewer(QMainWindow):
400
405
  if isinstance(item.widget(), CollapsibleBox):
401
406
  self.expand_collapse_all(item.widget(), expand=False)
402
407
 
403
- def expand_collapse_all(self, widget, expand=True):
408
+ def expand_collapse_all(self, widget, expand=True, curr_depth=0, max_depth=2):
404
409
  widget.toggle_button.setChecked(expand)
405
410
  widget.toggle()
406
- if expand:
411
+ if expand and curr_depth < max_depth:
407
412
  # do it for recursive children
408
413
  for i in range(widget.content_layout.count()):
409
414
  item = widget.content_layout.itemAt(i)
410
415
  if isinstance(item.widget(), CollapsibleBox):
411
- self.expand_collapse_all(item.widget(), expand=True)
416
+ self.expand_collapse_all(item.widget(), expand=True, curr_depth=curr_depth + 1, max_depth=max_depth)
412
417
 
413
418
 
414
419
 
@@ -28,11 +28,11 @@ def get_colored_value(value):
28
28
 
29
29
 
30
30
  def generate_object_graph(obj, name='root', seen=None, graph=None, current_depth=0, max_depth=3, chain_name=None,
31
- included_attrs=None):
31
+ included_attrs=None, iterable_limit=3):
32
32
  if seen is None:
33
33
  seen = set()
34
34
  if graph is None:
35
- graph = graphviz.Digraph(format='svg', graph_attr={'dpi': '300'})
35
+ graph = graphviz.Digraph(format='svg')
36
36
  graph.attr('node', shape='plaintext')
37
37
 
38
38
  obj_id = id(obj)
@@ -49,9 +49,13 @@ def generate_object_graph(obj, name='root', seen=None, graph=None, current_depth
49
49
 
50
50
  if isinstance(obj, (list, tuple, set, dict)):
51
51
  items = obj.items() if isinstance(obj, dict) else enumerate(obj)
52
+ i = 0
52
53
  for idx, item in items:
53
54
  if idx == "scope":
54
55
  continue
56
+ if i >= iterable_limit:
57
+ rows.append(f'<TR><TD ALIGN="LEFT" PORT="{idx}">...</TD><TD ALIGN="LEFT">...</TD></TR>')
58
+ break
55
59
  # Represent items as attr = index + type (for the label)
56
60
  if is_simple(item):
57
61
  val_colored = get_colored_value(item)
@@ -61,6 +65,7 @@ def generate_object_graph(obj, name='root', seen=None, graph=None, current_depth
61
65
  rows.append(
62
66
  f'<TR><TD ALIGN="LEFT" PORT="{idx}">[{idx}]</TD><TD ALIGN="LEFT"><I>{type_name}</I></TD></TR>')
63
67
  non_simple_attrs.append((str(idx), item))
68
+ i += 1
64
69
 
65
70
  else:
66
71
  for attr in dir(obj):
@@ -977,7 +977,11 @@ def copy_case(case: Union[Case, SQLTable]) -> Union[Case, SQLTable, Any]:
977
977
  continue
978
978
  attr_value = getattr(case, attr)
979
979
  if is_iterable(attr_value):
980
- setattr(case_copy, attr, copy(attr_value))
980
+ try:
981
+ setattr(case_copy, attr, copy(attr_value))
982
+ except AttributeError as e:
983
+ # if the attribute is not settable, just skip it
984
+ pass
981
985
  return case_copy
982
986
 
983
987
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ripple_down_rules
3
- Version: 0.4.0
3
+ Version: 0.4.2
4
4
  Summary: Implements the various versions of Ripple Down Rules (RDR) for knowledge representation and reasoning.
5
5
  Author-email: Abdelrhman Bassiouny <abassiou@uni-bremen.de>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -6,20 +6,20 @@ ripple_down_rules/helpers.py,sha256=TvTJU0BA3dPcAyzvZFvAu7jZqsp8Lu0HAAwvuizlGjg,
6
6
  ripple_down_rules/rdr.py,sha256=UhFKsb7bCKLfplZhCSY-FAulvMfsBqVk_-K7o5WMP4o,43709
7
7
  ripple_down_rules/rdr_decorators.py,sha256=VdmE0JrE8j89b6Af1R1tLZiKfy3h1VCvhAUefN_FLLQ,6753
8
8
  ripple_down_rules/rules.py,sha256=QQy7NBG6mKiowxVG_LjQJBxLTDW2hMyx5zAgwUxdCMM,17183
9
- ripple_down_rules/utils.py,sha256=tmYlbL1q8Au7iXlWNUW2j80pKqSaz6tvgwzL3fL5Cg8,48935
9
+ ripple_down_rules/utils.py,sha256=kJEqmKuq3NxM8gY7MrXSps2Xvf1FsYFgTMo3PSYZJY8,49098
10
10
  ripple_down_rules/datastructures/__init__.py,sha256=V2aNgf5C96Y5-IGghra3n9uiefpoIm_QdT7cc_C8cxQ,111
11
11
  ripple_down_rules/datastructures/callable_expression.py,sha256=jA7424_mWPbOoPICW3eLMX0-ypxnsW6gOqxrJ7JpDbE,11610
12
12
  ripple_down_rules/datastructures/case.py,sha256=oC8OSdhXvHE-Zx1IIQlad-fsKzQQqr6MZBW24c-dbeU,15191
13
13
  ripple_down_rules/datastructures/dataclasses.py,sha256=GWnUF4h4zfNHSsyBIz3L9y8sLkrXRv0FK_OxzzLc8L8,8183
14
14
  ripple_down_rules/datastructures/enums.py,sha256=ce7tqS0otfSTNAOwsnXlhsvIn4iW_Y_N3TNebF3YoZs,5700
15
15
  ripple_down_rules/user_interface/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- ripple_down_rules/user_interface/gui.py,sha256=xjuJCEhZ4Oy59AZQDjftcgOce76T6PWMhX5eq4sFLWU,25703
16
+ ripple_down_rules/user_interface/gui.py,sha256=p4HIAXXa8ijylw5PIpzHGNL4AhbjKmcInEYg-i7jzlI,25941
17
17
  ripple_down_rules/user_interface/ipython_custom_shell.py,sha256=tc7ms80iPNElm9AYC6i1FlfMKkqHLT8wmOEXg_k9yAU,6275
18
- ripple_down_rules/user_interface/object_diagram.py,sha256=TaAsjCbsCBAsO1Ffp6l8otbK-mculUW2jnVrDRFq1hU,4249
18
+ ripple_down_rules/user_interface/object_diagram.py,sha256=84JlEH0nQmtGmP8Su5iRX3ZfqByYHbVwd0BQYYPuckY,4436
19
19
  ripple_down_rules/user_interface/prompt.py,sha256=tQyIrRno1YuS3K0c4p48FVTdDJGG0HCE63WHVKpSJ1I,7976
20
20
  ripple_down_rules/user_interface/template_file_creator.py,sha256=PegwW_g8UScjEF2GGe1eV0VoWUzxPhA27L9ExbL7Y_E,12610
21
- ripple_down_rules-0.4.0.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
22
- ripple_down_rules-0.4.0.dist-info/METADATA,sha256=HAmijc0VYsXxNqGWwnGems2bOKDhJczdDdqbTgdzyNs,42668
23
- ripple_down_rules-0.4.0.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
24
- ripple_down_rules-0.4.0.dist-info/top_level.txt,sha256=VeoLhEhyK46M1OHwoPbCQLI1EifLjChqGzhQ6WEUqeM,18
25
- ripple_down_rules-0.4.0.dist-info/RECORD,,
21
+ ripple_down_rules-0.4.2.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
22
+ ripple_down_rules-0.4.2.dist-info/METADATA,sha256=s8NdJ2_MsA-ABMI1mO5jsDb-waIEA2pvFLNnQCw3ysk,42668
23
+ ripple_down_rules-0.4.2.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
24
+ ripple_down_rules-0.4.2.dist-info/top_level.txt,sha256=VeoLhEhyK46M1OHwoPbCQLI1EifLjChqGzhQ6WEUqeM,18
25
+ ripple_down_rules-0.4.2.dist-info/RECORD,,