tricc-oo 1.4.6__tar.gz → 1.4.8__tar.gz

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.
Files changed (52) hide show
  1. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/PKG-INFO +3 -3
  2. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/pyproject.toml +2 -2
  3. tricc_oo-1.4.8/tricc_oo/converters/utils.py +52 -0
  4. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/converters/xml_to_tricc.py +10 -4
  5. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/strategies/output/xlsform_cht.py +1 -1
  6. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/visitors/tricc.py +48 -20
  7. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo.egg-info/PKG-INFO +2 -2
  8. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo.egg-info/requires.txt +1 -1
  9. tricc_oo-1.4.6/tricc_oo/converters/utils.py +0 -57
  10. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/LICENSE +0 -0
  11. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/README.md +0 -0
  12. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/setup.cfg +0 -0
  13. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tests/build.py +0 -0
  14. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tests/test_cql.py +0 -0
  15. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tests/to_ocl.py +0 -0
  16. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/__init__.py +0 -0
  17. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/converters/__init__.py +0 -0
  18. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/converters/codesystem_to_ocl.py +0 -0
  19. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/converters/cql/cqlLexer.py +0 -0
  20. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/converters/cql/cqlListener.py +0 -0
  21. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/converters/cql/cqlParser.py +0 -0
  22. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/converters/cql/cqlVisitor.py +0 -0
  23. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/converters/cql_to_operation.py +0 -0
  24. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/converters/datadictionnary.py +0 -0
  25. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/converters/drawio_type_map.py +0 -0
  26. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/converters/tricc_to_xls_form.py +0 -0
  27. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/models/__init__.py +0 -0
  28. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/models/base.py +0 -0
  29. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/models/calculate.py +0 -0
  30. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/models/lang.py +0 -0
  31. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/models/ocl.py +0 -0
  32. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/models/ordered_set.py +0 -0
  33. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/models/tricc.py +0 -0
  34. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/parsers/__init__.py +0 -0
  35. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/parsers/xml.py +0 -0
  36. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/serializers/__init__.py +0 -0
  37. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/serializers/planuml.py +0 -0
  38. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/serializers/xls_form.py +0 -0
  39. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/strategies/__init__.py +0 -0
  40. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/strategies/input/__init__.py +0 -0
  41. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/strategies/input/base_input_strategy.py +0 -0
  42. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/strategies/input/drawio.py +0 -0
  43. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/strategies/output/base_output_strategy.py +0 -0
  44. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/strategies/output/spice.py +0 -0
  45. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/strategies/output/xls_form.py +0 -0
  46. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/strategies/output/xlsform_cdss.py +0 -0
  47. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/strategies/output/xlsform_cht_hf.py +0 -0
  48. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/visitors/__init__.py +0 -0
  49. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo/visitors/xform_pd.py +0 -0
  50. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo.egg-info/SOURCES.txt +0 -0
  51. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo.egg-info/dependency_links.txt +0 -0
  52. {tricc_oo-1.4.6 → tricc_oo-1.4.8}/tricc_oo.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.3
2
2
  Name: tricc-oo
3
- Version: 1.4.6
3
+ Version: 1.4.8
4
4
  Summary: Python library that converts CDSS L2 in L3
5
5
  Project-URL: Homepage, https://github.com/SwissTPH/tricc
6
6
  Project-URL: Issues, https://github.com/SwissTPH/tricc/issues
@@ -11,7 +11,7 @@ Requires-Python: >=3.8
11
11
  Description-Content-Type: text/markdown
12
12
 
13
13
  Requires-Dist: lxml
14
- Requires-Dist: html2text
14
+ Requires-Dist: markdownify
15
15
  Requires-Dist: pydantic
16
16
  Requires-Dist: babel
17
17
  Requires-Dist: xlsxwriter
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tricc-oo"
7
- version = "1.4.6"
7
+ version = "1.4.8"
8
8
  description = "Python library that converts CDSS L2 in L3"
9
9
  readme = "README.md"
10
10
  license-files = ["LICENSE"]
@@ -16,7 +16,7 @@ classifiers = [
16
16
  ]
17
17
  dependencies = [
18
18
  "lxml",
19
- "html2text",
19
+ "markdownify",
20
20
  "pydantic",
21
21
  "babel",
22
22
  "xlsxwriter",
@@ -0,0 +1,52 @@
1
+ import logging
2
+ import random
3
+ import string
4
+ import hashlib
5
+ from markdownify import markdownify as md
6
+
7
+
8
+ logger = logging.getLogger("default")
9
+
10
+
11
+ def replace_all(text, list_char, replacement):
12
+ for i in list_char:
13
+ text = text.replace(i, replacement)
14
+ return text
15
+
16
+
17
+ def clean_str(name, replace_dots=False):
18
+ replacement_list = ["-", " ", ",", "."] if replace_dots else ["-", " ", ","]
19
+ return replace_all(name, replacement_list, "_")
20
+
21
+
22
+ def clean_name(name, prefix="", replace_dots=False):
23
+ name = clean_str(name, replace_dots)
24
+ if name[0].isdigit():
25
+ name = "id_" + name
26
+ elif name[0].isdigit() == "_":
27
+ name = name[1:]
28
+ return name
29
+
30
+
31
+ def generate_id(name=None, length=18):
32
+ if name:
33
+ h = hashlib.blake2b(digest_size=length)
34
+ h.update(name.encode("utf-8") if isinstance(name, str) else name)
35
+ return h.hexdigest()
36
+ else:
37
+ return "".join(
38
+ random.choices(
39
+ string.ascii_lowercase + string.digits + string.ascii_uppercase,
40
+ k=length,
41
+ )
42
+ )
43
+
44
+
45
+ def get_rand_name(name=None, length=8):
46
+ return "n" + generate_id(name=name, length=length)
47
+
48
+
49
+ # the soup.text strips off the html formatting also
50
+ def remove_html(string):
51
+ text = md(string, strip=["img", "table", "a"])
52
+ return text
@@ -29,7 +29,11 @@ TRICC_FOLLOW_LABEL = ["follow", "suivre", "continue"]
29
29
  NO_LABEL = "NO_LABEL"
30
30
  TRICC_LIST_NAME = "list_{0}"
31
31
  import logging
32
-
32
+ DISPLAY_ATTRIBUTES = [
33
+ 'label',
34
+ 'hint',
35
+ 'help'
36
+ ]
33
37
  logger = logging.getLogger("default")
34
38
 
35
39
 
@@ -753,10 +757,12 @@ def set_mandatory_attribute(elm, mandatory_attributes, diagram=None):
753
757
  exit(1)
754
758
  if attributes == "link":
755
759
  param[attributes] = clean_link(attribute_value)
756
- elif attributes in ("parent", "id", "source", "target"):
757
- param[attributes] = attribute_value
760
+
758
761
  elif attribute_value is not None:
759
- param[attributes] = remove_html(attribute_value.strip())
762
+ if attributes in DISPLAY_ATTRIBUTES:
763
+ param[attributes] = remove_html(attribute_value.strip())
764
+ else:
765
+ param[attributes] = attribute_value.strip() if isinstance(attribute_value, str) else attribute_value
760
766
  return param
761
767
 
762
768
 
@@ -117,7 +117,7 @@ class XLSFormCHTStrategy(XLSFormCDSSStrategy):
117
117
  # pause
118
118
  ends = []
119
119
  for p in self.project.pages.values():
120
- p_ends = list(filter(lambda x: issubclass(x.__class__, TriccNodeEnd) and hasattr(x, 'hint'), p.nodes.values() ))
120
+ p_ends = list(filter(lambda x: issubclass(x.__class__, TriccNodeEnd) and getattr(x, 'hint', None) is not None, p.nodes.values() ))
121
121
  if p_ends:
122
122
  ends += p_ends
123
123
  if ends:
@@ -115,7 +115,8 @@ def process_calculate(node,processed_nodes, stashed_nodes, calculates, used_calc
115
115
  ):
116
116
  if kwargs.get('warn', True):
117
117
  logger.debug('Processing relevance for node {0}'.format(node.get_name()))
118
- last_version = get_last_version(node.name, processed_nodes) if issubclass(node.__class__, (TriccNodeDisplayModel, TriccNodeDisplayCalculateBase)) and not isinstance(node, TriccNodeSelectOption) else None
118
+ node_name = node.name if not isinstance(node, TriccNodeEnd) else 'tricc_end'
119
+ last_version = get_last_version(node_name, processed_nodes) if issubclass(node.__class__, (TriccNodeDisplayModel, TriccNodeDisplayCalculateBase)) and not isinstance(node, TriccNodeSelectOption) else None
119
120
  #last_version = processed_nodes.find_prev(node, lambda item: hasattr(item, 'name') and item.name == node.name)
120
121
  if last_version:
121
122
  # 0-100 for manually specified instance. 100-200 for auto instance
@@ -128,9 +129,7 @@ def process_calculate(node,processed_nodes, stashed_nodes, calculates, used_calc
128
129
  if (
129
130
  issubclass(node.__class__, (TriccNodeDisplayCalculateBase )) and node.name is not None
130
131
  ):
131
- node_name = node.name if not isinstance(node, TriccNodeEnd) else 'tricc_end'
132
-
133
- #logger.debug("set last to false for node {} and add its link it to next one".format(last_used_calc.get_name()))
132
+ #logger.debug("set last to false for node {} and add its link it to next one".format(last_used_calc.get_name()))
134
133
  if node.prev_nodes:
135
134
  set_prev_next_node(last_version, node)
136
135
  else:
@@ -1113,21 +1112,38 @@ def check_stashed_loop(stashed_nodes, prev_stashed_nodes, processed_nodes, len_p
1113
1112
  logger.critical("Stashed node list was unchanged: loop likely or unresolved dependence")
1114
1113
  waited, looped = get_all_dependant(stashed_nodes, stashed_nodes, processed_nodes)
1115
1114
  logger.debug(f"{len(looped)} nodes waiting stashed nodes")
1116
- logger.info("looped nodes")
1117
- for es_node in looped:
1115
+ logger.info("unresolved reference")
1116
+ for es_node in [n for n in stashed_nodes if isinstance(n, TriccReference)]:
1118
1117
  logger.info("Stashed node {}:{}|{} {}".format(
1119
1118
  es_node.activity.get_name() if hasattr(es_node,'activity') else '' ,
1120
1119
  es_node.activity.instance if hasattr(es_node,'activity') else '',
1121
1120
  es_node.__class__,
1122
1121
  es_node.get_name()))
1122
+ logger.info("looped nodes")
1123
+ for dep_list in looped:
1124
+ for d in looped[dep_list]:
1125
+ if d.get_name() == dep_list:
1126
+ logger.critical("[{}] depends on itself".format(
1127
+ dep_list,
1128
+ ))
1129
+ logger.error("[{}] depends on [{}]".format(
1130
+ dep_list, str(d)
1131
+ ))
1132
+ if dep_list in waited:
1133
+ for d in waited[dep_list]:
1134
+ logger.warning("[{}] depends on [{}]".format(
1135
+ dep_list, str(d)
1136
+ ))
1137
+
1123
1138
  #reverse_walkthrough(es_node, es_node, print_trace, processed_nodes, stashed_nodes)
1124
1139
  logger.info("waited nodes")
1125
- for es_node in waited:
1126
- logger.info("Stashed node {}:{}|{} {}".format(
1127
- es_node.activity.get_name() if hasattr(es_node,'activity') else '' ,
1128
- es_node.activity.instance if hasattr(es_node,'activity') else '',
1129
- es_node.__class__,
1130
- es_node.get_name()))
1140
+ for dep_list in waited:
1141
+ if dep_list not in looped:
1142
+ for d in waited[dep_list]:
1143
+ logger.warning("[{}] depends on [{}]".format(
1144
+ dep_list, d.get_name()
1145
+ ))
1146
+
1131
1147
  if len(stashed_nodes) == len(prev_stashed_nodes):
1132
1148
  exit(1)
1133
1149
  else:
@@ -1136,12 +1152,25 @@ def check_stashed_loop(stashed_nodes, prev_stashed_nodes, processed_nodes, len_p
1136
1152
  loop_count = 0
1137
1153
  return loop_count
1138
1154
 
1155
+
1156
+ def add_to_tree(tree, n, d):
1157
+ n_str = str(n)
1158
+ if n_str not in tree:
1159
+ tree[n_str] = []
1160
+ if d not in tree[n_str]:
1161
+ tree[n_str].append(d)
1162
+ return tree
1163
+
1139
1164
 
1140
- def get_all_dependant(loop, stashed_nodes, processed_nodes, depth=0, waited=[] , looped=[]):
1165
+ def get_all_dependant(loop, stashed_nodes, processed_nodes, depth=0, waited=None , looped=None):
1166
+ if looped is None:
1167
+ looped = {}
1168
+ if waited is None:
1169
+ waited = {}
1141
1170
  for n in loop:
1142
1171
  dependant = OrderedSet()
1143
1172
  i=0
1144
- logger.critical(f"{i}: {n.__class__}::{n.get_name()}::{getattr(n,'instance','')}::{process_reference(n, processed_nodes, [])}")
1173
+ #logger.critical(f"{i}: {n.__class__}::{n.get_name()}::{getattr(n,'instance','')}::{process_reference(n, processed_nodes, [])}")
1145
1174
  i += 1
1146
1175
  if hasattr(n, 'prev_nodes') and n.prev_nodes:
1147
1176
  dependant = dependant | n.prev_nodes
@@ -1156,16 +1185,15 @@ def get_all_dependant(loop, stashed_nodes, processed_nodes, depth=0, waited=[] ,
1156
1185
  if isinstance(d, TriccReference):
1157
1186
  if not any(n.name == d.value for n in processed_nodes):
1158
1187
  if not any(n.name == d.value for n in stashed_nodes):
1159
- waited.append(d)
1188
+ waited = add_to_tree(waited, n, d)
1160
1189
  else :
1161
- looped.append(d)
1190
+ looped = add_to_tree(looped, n, d)
1162
1191
 
1163
1192
  elif d not in processed_nodes:
1164
-
1165
- if d not in stashed_nodes:
1166
- waited.append(d)
1193
+ if d in stashed_nodes:
1194
+ looped = add_to_tree(looped, n, d)
1167
1195
  else :
1168
- looped.append(d)
1196
+ waited = add_to_tree(waited, n, d)
1169
1197
  if depth < MAX_DRILL:
1170
1198
  return get_all_dependant(waited, stashed_nodes, processed_nodes, depth+1, waited , looped)
1171
1199
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tricc-oo
3
- Version: 1.4.6
3
+ Version: 1.4.8
4
4
  Summary: Python library that converts CDSS L2 in L3
5
5
  Project-URL: Homepage, https://github.com/SwissTPH/tricc
6
6
  Project-URL: Issues, https://github.com/SwissTPH/tricc/issues
@@ -11,7 +11,7 @@ Requires-Python: >=3.8
11
11
  Description-Content-Type: text/markdown
12
12
  License-File: LICENSE
13
13
  Requires-Dist: lxml
14
- Requires-Dist: html2text
14
+ Requires-Dist: markdownify
15
15
  Requires-Dist: pydantic
16
16
  Requires-Dist: babel
17
17
  Requires-Dist: xlsxwriter
@@ -1,5 +1,5 @@
1
1
  lxml
2
- html2text
2
+ markdownify
3
3
  pydantic
4
4
  babel
5
5
  xlsxwriter
@@ -1,57 +0,0 @@
1
- import logging
2
- import random
3
- import string
4
- import hashlib
5
- import html2text
6
-
7
-
8
-
9
- logger = logging.getLogger("default")
10
-
11
- def replace_all(text, list_char, replacement):
12
- for i in list_char:
13
- text = text.replace(i, replacement)
14
- return text
15
-
16
- def clean_str(name, replace_dots=False):
17
- replacement_list = ['-', ' ', ',', '.'] if replace_dots else ['-', ' ', ',']
18
- return replace_all(name, replacement_list,'_')
19
-
20
- def clean_name( name, prefix='', replace_dots=False):
21
- name = clean_str(name, replace_dots)
22
- if name[0].isdigit():
23
- name = 'id_' + name
24
- elif name[0].isdigit() == '_':
25
- name = name[1:]
26
- return name
27
-
28
- def generate_id(name=None, length=18):
29
- if name:
30
- h = hashlib.blake2b(digest_size=length)
31
- h.update(name.encode('utf-8') if isinstance(name, str) else name)
32
- return h.hexdigest()
33
- else:
34
- return ''.join(random.choices(string.ascii_lowercase + string.digits + string.ascii_uppercase, k=length))
35
-
36
-
37
- def get_rand_name(name=None, length=8):
38
- return "n" + generate_id(name=name, length=length)
39
-
40
- # the soup.text strips off the html formatting also
41
- def remove_html(string):
42
- h = html2text.HTML2Text()
43
- h.body_width = 0 # Prevents line wrapping
44
- h.ignore_links = True # Ignores any link processing
45
- h.ignore_images = True # Ignores image processing
46
- h.ignore_tables = True # Ignores table formatting
47
- text = h.handle(string).rstrip() # rstrip()
48
- text = text.strip('\n') # get rid of empty lines at the end (and beginning)
49
- text = text.split('\n') # split string into a list at new lines
50
- text = '\n'.join([i.strip(' ') for i in text if i]) # in each element in that list strip empty space (at the end of line)
51
- # and delete empty lines
52
- return text
53
-
54
-
55
-
56
-
57
-
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes