Beispiel #1
0
Datei: match.py Projekt: aek/zato
    def is_allowed(self, value):
        logger.debug('Cache:`%s`, value:`%s`', self.is_allowed_cache, value)

        if self.special_case is not None:
            return self.special_case

        try:
            return self.is_allowed_cache[value]
        except KeyError:
            _match = globre_match
            is_allowed = None

            for order in self.order1, self.order2:
                for pattern in self.items[order]:
                    if globre_match(pattern, value):
                        is_allowed = order

            # No match at all - we don't allow it in that case
            is_allowed = is_allowed if (is_allowed is not None) else False

            self.is_allowed_cache[value] = is_allowed
            return is_allowed
Beispiel #2
0
    def is_allowed(self, value):
        logger.debug('Cache:`%s`, value:`%s`', self.is_allowed_cache, value)

        if self.special_case is not None:
            return self.special_case

        try:
            return self.is_allowed_cache[value]
        except KeyError:
            _match = globre_match
            is_allowed = None

            for order in self.order1, self.order2:
                for pattern in self.items[order]:
                    if globre_match(pattern, value):
                        is_allowed = order

            # No match at all - we don't allow it in that case
            is_allowed = is_allowed if (is_allowed is not None) else False

            self.is_allowed_cache[value] = is_allowed
            return is_allowed
Beispiel #3
0
 def _name_matches(self, pattern, string, negate):
     """ Matches a string against a pattern and returns True if it found it. 'negate' reverses the result,
     only those not matching the pattern will yield True.
     """
     result = bool(globre_match(pattern, string))
     return not result if negate else result
Beispiel #4
0
 def _name_matches(self, pattern, string, negate):
     """ Matches a string against a pattern and returns True if it found it. 'negate' reverses the result,
     only those not matching the pattern will yield True.
     """
     result = bool(globre_match(pattern, string))
     return not result if negate else result