def url_for(*args, **kargs):
    anchor = kargs.get('anchor')
    host = kargs.get('host')
    protocol = kargs.pop('protocol', None)
    qualified = kargs.pop('qualified', None)

    # Remove special words from kargs, convert placeholders
    for key in ['anchor', 'host']:
        if kargs.get(key):
            del kargs[key]
        if key+'_' in kargs:
            kargs[key] = kargs.pop(key+'_')

    if 'protocol_' in kargs:
        kargs['protocol_'] = protocol

    config = request_config()
    route = None
    static = False
    encoding = config.mapper.encoding
    url = ''
    if len(args) > 0:
        route = config.mapper._routenames.get(args[0])

        # No named route found, assume the argument is a relative path
        if not route:
            static = True
            url = args[0]

        if url.startswith('/') and hasattr(config, 'environ') \
                and config.environ.get('SCRIPT_NAME'):
            url = config.environ.get('SCRIPT_NAME') + url

        if static:
            if kargs:
                url += '?'
                query_args = []
                for key, val in six.iteritems(kargs):
                    if isinstance(val, (list, tuple)):
                        for value in val:
                            query_args.append("%s=%s" % (
                                urllib.parse.quote(six.text_type(key).encode(encoding)),
                                urllib.parse.quote(six.text_type(value).encode(encoding))))
                    else:
                        query_args.append("%s=%s" % (
                            urllib.parse.quote(six.text_type(key).encode(encoding)),
                            urllib.parse.quote(six.text_type(val).encode(encoding))))
                url += '&'.join(query_args)
    environ = getattr(config, 'environ', {})
    if 'wsgiorg.routing_args' not in environ:
        environ = environ.copy()
        mapper_dict = getattr(config, 'mapper_dict', None)
        if mapper_dict is not None:
            match_dict = mapper_dict.copy()
        else:
            match_dict = {}
        environ['wsgiorg.routing_args'] = ((), match_dict)

    if not static:
        route_args = []
        if route:
            if config.mapper.hardcode_names:
                route_args.append(route)
            newargs = route.defaults.copy()
            newargs.update(kargs)

            # If this route has a filter, apply it
            if route.filter:
                newargs = route.filter(newargs)

            if not route.static:
                # Handle sub-domains
                newargs = _subdomain_check(newargs, config.mapper, environ)
        else:
            newargs = _screenargs(kargs, config.mapper, environ)
        anchor = newargs.pop('_anchor', None) or anchor
        host = newargs.pop('_host', None) or host
        protocol = newargs.pop('_protocol', protocol)
        url = config.mapper.generate(*route_args, **newargs)
    if anchor is not None:
        url += '#' + _url_quote(anchor, encoding)
    if host or (protocol is not None) or qualified:
        if not host and not qualified:
            # Ensure we don't use a specific port, as changing the protocol
            # means that we most likely need a new port
            host = config.host.split(':')[0]
        elif not host:
            host = config.host
        if protocol is None:
            protocol = config.protocol
        if protocol != '':
            protocol += ':'
        if url is not None:
            url = protocol + '//' + host + url

    if not ascii_characters(url) and url is not None:
        raise GenerationException("url_for can only return a string, got "
                        "unicode instead: %s" % url)
    if url is None:
        raise GenerationException(
            "url_for could not generate URL. Called with args: %s %s" % \
            (args, kargs))
    return url
Return the list of (format, self.externalsig) for every format whose extension matches the filename.
dataset/ETHPy150Open bbangert/routes/routes/util.py/url_for--crossover with--dataset/ETHPy150Open openpreserve/fido/fido/fido.py/Fido.match_extensions