def regex_uri(e, regexes, tag, default=None):
    "filter incoming URI against a list of regexes"
    path = e['PATH_INFO']
    host = e.get('HTTP_HOST', e.get('SERVER_NAME', 'localhost')).lower()
    i = host.find(':')
    if i > 0:
        host = host[:i]
    key = '%s:%s://%s:%s %s' % \
        (e.get('REMOTE_ADDR', 'localhost'),
         e.get('wsgi.url_scheme', 'http').lower(), host,
         e.get('REQUEST_METHOD', 'get').lower(), path)
    for (regex, value, custom_env) in regexes:
        if regex.match(key):
            e.update(custom_env)
            rewritten = regex.sub(value, key)
            log_rewrite('%s: [%s] [%s] -> %s' % (tag, key, value, rewritten))
            return rewritten
    log_rewrite('%s: [%s] -> %s (not rewritten)' % (tag, key, default))
    return default
dataset/ETHPy150Open uwdata/termite-visualizations/web2py/gluon/rewrite.py/regex_uri/original