def should_show_prompt()

in source/idea/idea-sdk/src/ideasdk/user_input/framework.py [0:0]


    def should_show_prompt(self, when: Optional[SocaUserInputParamCondition]) -> bool:
        """
        Evaluate the given when clause
        :param when:
        :return: True, if prompt 'should' be shown, False otherwise
        """

        if when is None:
            return True

        if Utils.are_empty(when.param, when.and_, when.or_):
            return True

        if Utils.is_not_empty(when.param):

            param_value = self.args.get(when.param)

            # todo - between, min, max

            if Utils.is_true(when.empty) and Utils.is_empty(param_value):
                return True
            elif Utils.is_true(when.not_empty) and Utils.is_not_empty(param_value):
                return True
            elif Utils.is_not_empty(when.eq) and param_value == when.eq:
                return True
            elif Utils.is_not_empty(when.not_eq) and param_value != when.not_eq:
                return True
            elif Utils.is_not_empty(when.gt) and param_value > when.gt:
                return True
            elif Utils.is_not_empty(when.gte) and param_value >= when.gte:
                return True
            elif Utils.is_not_empty(when.lt) and param_value < when.lt:
                return True
            elif Utils.is_not_empty(when.lte) and param_value <= when.lte:
                return True
            elif Utils.is_not_empty(when.in_) and param_value in when.in_:
                return True
            elif Utils.is_not_empty(when.contains) and param_value is not None and when.contains in param_value:
                return True
            elif Utils.is_not_empty(when.not_contains) and param_value is not None and when.not_contains not in param_value:
                return True
            elif Utils.is_not_empty(when.not_in) and param_value not in when.not_in:
                return True

            return False

        if Utils.is_not_empty(when.and_):
            for condition in when.and_:
                if not self.should_show_prompt(condition):
                    return False
            return True

        if Utils.is_not_empty(when.or_):
            for condition in when.or_:
                if self.should_show_prompt(condition):
                    return True
            return False

        return True