tricc-oo 1.4.18__tar.gz → 1.4.19__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 (51) hide show
  1. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/PKG-INFO +1 -1
  2. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/pyproject.toml +1 -1
  3. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/converters/cql_to_operation.py +17 -4
  4. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/models/base.py +1 -1
  5. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/serializers/xls_form.py +2 -3
  6. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/strategies/output/xlsform_cht.py +1 -1
  7. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/visitors/tricc.py +15 -7
  8. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo.egg-info/PKG-INFO +1 -1
  9. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/README.md +0 -0
  10. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/setup.cfg +0 -0
  11. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tests/build.py +0 -0
  12. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tests/test_cql.py +0 -0
  13. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tests/to_ocl.py +0 -0
  14. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/__init__.py +0 -0
  15. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/converters/__init__.py +0 -0
  16. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/converters/codesystem_to_ocl.py +0 -0
  17. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/converters/cql/cqlLexer.py +0 -0
  18. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/converters/cql/cqlListener.py +0 -0
  19. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/converters/cql/cqlParser.py +0 -0
  20. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/converters/cql/cqlVisitor.py +0 -0
  21. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/converters/datadictionnary.py +0 -0
  22. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/converters/drawio_type_map.py +0 -0
  23. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/converters/tricc_to_xls_form.py +0 -0
  24. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/converters/utils.py +0 -0
  25. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/converters/xml_to_tricc.py +0 -0
  26. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/models/__init__.py +0 -0
  27. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/models/calculate.py +0 -0
  28. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/models/lang.py +0 -0
  29. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/models/ocl.py +0 -0
  30. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/models/ordered_set.py +0 -0
  31. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/models/tricc.py +0 -0
  32. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/parsers/__init__.py +0 -0
  33. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/parsers/xml.py +0 -0
  34. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/serializers/__init__.py +0 -0
  35. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/serializers/planuml.py +0 -0
  36. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/strategies/__init__.py +0 -0
  37. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/strategies/input/__init__.py +0 -0
  38. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/strategies/input/base_input_strategy.py +0 -0
  39. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/strategies/input/drawio.py +0 -0
  40. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/strategies/output/base_output_strategy.py +0 -0
  41. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/strategies/output/spice.py +0 -0
  42. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/strategies/output/xls_form.py +0 -0
  43. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/strategies/output/xlsform_cdss.py +0 -0
  44. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/strategies/output/xlsform_cht_hf.py +0 -0
  45. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/visitors/__init__.py +0 -0
  46. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/visitors/utils.py +0 -0
  47. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo/visitors/xform_pd.py +0 -0
  48. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo.egg-info/SOURCES.txt +0 -0
  49. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo.egg-info/dependency_links.txt +0 -0
  50. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo.egg-info/requires.txt +0 -0
  51. {tricc_oo-1.4.18 → tricc_oo-1.4.19}/tricc_oo.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: tricc-oo
3
- Version: 1.4.18
3
+ Version: 1.4.19
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tricc-oo"
7
- version = "1.4.18"
7
+ version = "1.4.19"
8
8
  description = "Python library that converts CDSS L2 in L3"
9
9
  readme = "README.md"
10
10
 
@@ -33,6 +33,7 @@ FUNCTION_MAP = {
33
33
  class cqlToXlsFormVisitor(cqlVisitor):
34
34
  def __init__(self):
35
35
  self.xlsform_rows = []
36
+ self.errors= []
36
37
 
37
38
  def resolve_scv(self, arg):
38
39
 
@@ -42,9 +43,15 @@ class cqlToXlsFormVisitor(cqlVisitor):
42
43
  # if no code or not found return None
43
44
  if arg.startswith('"') and arg.endswith('"'):
44
45
  return TriccReference(arg[1:-1])
45
- else:
46
+ elif arg.lower() in ['true', 'false']:
47
+ return TriccStatic(arg.lower() == 'true')
48
+ elif arg != 'runner':
49
+ self.errors.append(f"'{arg}' will be poccessed as reference ")
46
50
  return TriccReference(arg)
47
51
 
52
+ else:
53
+ return 'runner'
54
+
48
55
  def translate(self, arg, type=ANY):
49
56
  return self.resolve_scv(arg) or str(arg)
50
57
 
@@ -368,13 +375,13 @@ class CQLErrorListener(ErrorListener):
368
375
  self.errors.append(error)
369
376
 
370
377
  def transform_cql_to_operation(cql_input, context=None):
371
- cql_input = f"""
378
+ lib_input = f"""
372
379
  library runner
373
380
 
374
381
  define "calc":
375
382
  {cql_input.replace('−', '-')}
376
383
  """
377
- input_stream = InputStream(chr(10).join(cql_input.split('\n')))
384
+ input_stream = InputStream(chr(10).join(lib_input.split('\n')))
378
385
  lexer = cqlLexer(input_stream)
379
386
  stream = CommonTokenStream(lexer)
380
387
  parser = cqlParser(stream)
@@ -390,12 +397,18 @@ def transform_cql_to_operation(cql_input, context=None):
390
397
  # Check for errors
391
398
  if error_listener.errors:
392
399
  for error in error_listener.errors:
393
- print(f"CQL Grammar Error: {error}")
400
+ print(f"CQL Grammar Error: {error} \n in:\n {cql_input}")
394
401
  return None # Or handle errors as appropriate for your use case
395
402
 
396
403
  # If no errors, proceed with visitor
397
404
  visitor = cqlToXlsFormVisitor()
405
+
398
406
  visitor.visit(tree)
407
+ if visitor.errors:
408
+ logger.warning(f"while visiting cql: \n{cql_input}")
409
+ for e in visitor.errors:
410
+ logger.warning(e)
411
+
399
412
  return visitor.xlsform_rows[0]['calculation']
400
413
 
401
414
  def transform_cql_lib_to_operations(cql_input):
@@ -305,7 +305,7 @@ class TriccStatic(BaseModel):
305
305
  return str(self.value)
306
306
 
307
307
  def __repr__(self):
308
- return "TriccStatic:"+str(type(self.value))+':' +str(self.value)
308
+ return self.__class__.__name__+":"+str(type(self.value))+':' +str(self.value)
309
309
 
310
310
  def get_references(self):
311
311
  return OrderedSet()
@@ -62,12 +62,11 @@ def start_group(
62
62
 
63
63
  if not relevance:
64
64
  relevance_expression = ""
65
- elif isinstance(relevance_expression, TriccOperation):
65
+ elif isinstance(relevance_expression, (TriccOperation, TriccStatic)):
66
66
  relevance_expression = strategy.get_tricc_operation_expression(
67
67
  relevance_expression
68
68
  )
69
- elif isinstance(relevance_expression, TriccStatic):
70
- relevance_expression = str(relevance_expression.value)
69
+
71
70
 
72
71
  # elif is_activity:
73
72
  # relevance_expression = TRICC_CALC_EXPRESSION.format(get_export_name(cur_group.root))
@@ -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 getattr(x, 'hint', None) is not None, p.nodes.values() ))
120
+ p_ends = list(filter(lambda x: issubclass(x.__class__, TriccNodeEnd) and getattr(x, 'process', '') == 'pause', p.nodes.values() ))
121
121
  if p_ends:
122
122
  ends += p_ends
123
123
  if ends:
@@ -120,7 +120,7 @@ def process_calculate(node,processed_nodes, stashed_nodes, calculates, used_calc
120
120
  node_name = node.name if not isinstance(node, TriccNodeEnd) else node.get_reference()
121
121
  last_version = get_last_version(node_name, processed_nodes) if issubclass(node.__class__, (TriccNodeDisplayModel, TriccNodeDisplayCalculateBase, TriccNodeEnd)) and not isinstance(node, TriccNodeSelectOption) else None
122
122
  #last_version = processed_nodes.find_prev(node, lambda item: hasattr(item, 'name') and item.name == node.name)
123
- if last_version:
123
+ if last_version and getattr(node, 'process', '') != 'pause':
124
124
  # 0-100 for manually specified instance. 100-200 for auto instance
125
125
  node.version = last_version.version + 1
126
126
  last_version.last = False
@@ -526,12 +526,15 @@ def process_reference(node, processed_nodes, calculates, used_calculates=None,
526
526
  node.reference = list(modified_expression.get_references())
527
527
  node.expression_reference = modified_expression
528
528
  elif getattr(node, 'reference', None):
529
- if isinstance(node.reference, list):
529
+ reference = node.reference
530
+ if isinstance(reference, list):
531
+ if isinstance(node, TriccNodeWait):
532
+ reference = [TriccOperation(TriccOperator.ISTRUE,[n]) for n in reference]
530
533
  if len(node.reference) == 1 :
531
- operation = node.reference[0]
534
+ operation = reference[0]
532
535
  else:
533
536
  operation = and_join(
534
- node.reference
537
+ reference
535
538
  )
536
539
  modified_expression = process_operation_reference(
537
540
  operation,
@@ -1468,7 +1471,7 @@ def get_node_expression( in_node, processed_nodes, is_calculate=False, is_prev=F
1468
1471
  expression = None
1469
1472
  negate_expression = None
1470
1473
  node = in_node
1471
- if isinstance(node, (TriccNodeActivityStart,TriccNodeMainStart, TriccNodeActivityEnd)):
1474
+ if isinstance(node, (TriccNodeActivityStart,TriccNodeMainStart)):
1472
1475
  if is_prev and is_calculate:
1473
1476
  expression = get_node_expression(
1474
1477
  node.activity,
@@ -1478,7 +1481,9 @@ def get_node_expression( in_node, processed_nodes, is_calculate=False, is_prev=F
1478
1481
  negate=negate,
1479
1482
  process=process
1480
1483
  )
1481
- elif isinstance(node, (TriccNodeActivityStart)):
1484
+ if isinstance(node, TriccNodeMainStart):
1485
+ expression = get_applicability_expression(node.activity, processed_nodes, process, expression )
1486
+ elif isinstance(node, (TriccNodeActivityStart)):
1482
1487
  return None
1483
1488
 
1484
1489
  elif isinstance(node, TriccNodeWait):
@@ -1538,7 +1543,7 @@ def get_node_expression( in_node, processed_nodes, is_calculate=False, is_prev=F
1538
1543
  # else:
1539
1544
  expression = node.expression_reference
1540
1545
  elif not is_prev and hasattr(node, 'relevance') and isinstance(node.relevance, TriccOperation):
1541
- expression = node.relevance
1546
+ expression = node.relevance
1542
1547
  elif is_prev and isinstance(node, TriccNodeSelectOption):
1543
1548
  if negate:
1544
1549
  negate_expression = get_selected_option_expression(node, negate)
@@ -1625,6 +1630,9 @@ def get_process_skip_expression(node, processed_nodes, process, expression=None)
1625
1630
  f_end_expression = get_end_expression(processed_nodes)
1626
1631
  if f_end_expression:
1627
1632
  end_expressions.append(f_end_expression)
1633
+ b_end_expression = get_end_expression(processed_nodes, 'pause')
1634
+ if b_end_expression:
1635
+ end_expressions.append(b_end_expression)
1628
1636
  if process[0] in PROCESSES:
1629
1637
  for p in PROCESSES[PROCESSES.index(process[0])+1:]:
1630
1638
  p_end_expression = get_end_expression(processed_nodes, p)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tricc-oo
3
- Version: 1.4.18
3
+ Version: 1.4.19
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
File without changes
File without changes
File without changes
File without changes
File without changes