Commit df18a0a8 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

Fix workaround in ugly Cadbiom functions: pass unit tests

parent b81de0e5
......@@ -209,13 +209,28 @@ def get_places_from_condition(condition):
.. note:: This function is only used to get all nodes in a condition when
we know they are all inhibitors nodes.
.. todo:: See the workaround in the code, without using very time consuming
and badly coded functions.
:param: Condition string.
:type: <str>
:return: Set of places.
:rtype: <set>
"""
replacement = ['and', 'or', 'not', '(', ')']
# Valid but very time consuming like any other things in Cadbiom library
# err = Reporter()
# tvi = TableVisitor(err)
# symb_tab = tvi.tab_symb
# cond_sexpr = compile_cond(condition, symb_tab, err)
# inhibitors_nodes = set()
# possible_paths = rec(cond_sexpr, inhibitors_nodes)
# return set(it.chain(*possible_paths))
# Replace parentheses first to make spaces in the string
# As operators are followed or preceded by parentheses, we can detect them
# without false positives (operator string inside an entity name)
replacement = ['(', ')', ' and ', ' or ', ' not ']
for operator in replacement:
condition = condition.replace(operator, ' ')
......@@ -406,6 +421,7 @@ def rec(tree, inhibitors_nodes):
solutions = [path]
return solutions
if isinstance(tree, SigNotExpr):
# tree.operand: the entity, type: SigIdentExpr
LOGGER.debug("NOT OPERAND: %s, %s", tree.operand, type(tree.operand))
try:
current_inhibitors = get_places_from_condition(tree.operand.__str__())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment