def create_zero_condition(side: Side) -> 'Condition': assert isinstance(side, Side) and not side.is_empty() s = str(side) var = side.pop_the_latest_variable() s_var = str(var) assert var is not None try: side.move_lo_from_var(var) except SideException as se: raise ConditionException("Can not create zero condition {}".format(s)) c = Condition(Side(var), side, ConditionState.IS_ZERO if side.is_empty() else ConditionState.IS_EQUAL) logger.info("create_zero_condition: var: {}; side: {}. => '{}'".format(s_var, s, c)) return c
def __init__(self, left_side: Side, right_side: Side, state: ConditionState) -> None: """ left_side - is list of Variables left_side - is list of Variables or None if state equal IS_ZERO state - state of condition """ if not right_side.is_empty() and state == ConditionState.IS_ZERO: assert "Internal error" == 0 self.__state = state # type: ConditionState self.__left_side = left_side # type: Side self.__right_side = right_side # type: Side
def create_non_zero_condition(side: Side) -> 'Condition': assert isinstance(side, Side) and not side.is_empty() return Condition(side, Side(), ConditionState.IS_NOT_ZERO)