How to use the rebulk.utils.get_first_defined function in rebulk

To help you get started, we’ve selected a few rebulk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Toilal / rebulk / rebulk / pattern.py View on Github external
def _process_match_validator(self, match, child=False):
        """
        Process match validation from this pattern configuration.

        :param match:
        :return: True if match is validated by the configured validator, False otherwise.
        """
        included = self._should_include_children if child else self._should_include_parent
        if included or self.validate_all:
            keys = self._match_config_property_keys(match, child=child)
            validator = get_first_defined(self.validators, keys, self._default_validator)
            if validator and not validator(match):
                return False
        return True
github Toilal / rebulk / rebulk / pattern.py View on Github external
def _process_match_formatter(self, match, child=False):
        """
        Process match formatter from this pattern configuration.

        :param match:
        :return:
        """
        included = self._should_include_children if child else self._should_include_parent
        if included or self.format_all:
            keys = self._match_config_property_keys(match, child=child)
            match.formatter = get_first_defined(self.formatters, keys, self._default_formatter)
github Toilal / rebulk / rebulk / pattern.py View on Github external
def _process_match_value(self, match, child=False):
        """
        Process match value from this pattern configuration.
        :param match:
        :return:
        """
        keys = self._match_config_property_keys(match, child=child)
        pattern_value = get_first_defined(self.values, keys, self._default_value)
        if pattern_value:
            match.value = pattern_value