def match(self, url, environ=None, sub_domains=False,
              sub_domains_ignore=None, domain_match=''):
        """Match a url to our regexp.

        While the regexp might match, this operation isn't
        guaranteed as there's other factors that can cause a match to
        fail even though the regexp succeeds (Default that was relied
        on wasn't given, requirement regexp doesn't pass, etc.).

        Therefore the calling function shouldn't assume this will
        return a valid dict, the other possible return is False if a
        match doesn't work out.

        """
        # Static routes don't match, they generate only
        if self.static:
            return False

        match = self.regmatch.match(url)

        if not match:
            return False

        sub_domain = None

        if sub_domains and environ and 'HTTP_HOST' in environ:
            host = environ['HTTP_HOST'].split(':')[0]
            sub_match = re.compile('^(.+?)\.%s$' % domain_match)
            subdomain = re.sub(sub_match, r'\1', host)
            if subdomain not in sub_domains_ignore and host != subdomain:
                sub_domain = subdomain

        if self.conditions:
            if 'method' in self.conditions and environ and \
                    environ['REQUEST_METHOD'] not in self.conditions['method']:
                return False

            # Check sub-domains?
            use_sd = self.conditions.get('sub_domain')
            if use_sd and not sub_domain:
                return False
            elif not use_sd and 'sub_domain' in self.conditions and sub_domain:
                return False
            if isinstance(use_sd, list) and sub_domain not in use_sd:
                return False

        matchdict = match.groupdict()
        result = {}
        extras = self._default_keys - frozenset(matchdict.keys())
        for key, val in six.iteritems(matchdict):
            if key != 'path_info' and self.encoding:
                # change back into python unicode objects from the URL
                # representation
                try:
                    val = as_unicode(val, self.encoding, self.decode_errors)
                except __HOLE__:
                    return False

            if not val and key in self.defaults and self.defaults[key]:
                result[key] = self.defaults[key]
            else:
                result[key] = val
        for key in extras:
            result[key] = self.defaults[key]

        # Add the sub-domain if there is one
        if sub_domains:
            result['sub_domain'] = sub_domain

        # If there's a function, call it with environ and expire if it
        # returns False
        if self.conditions and 'function' in self.conditions and \
                not self.conditions['function'](environ, result):
            return False

        return result
dataset/ETHPy150Open bbangert/routes/routes/route.py/Route.match