capybara/virtualenv/lib/python2.7/site-packages/setuptools/package_index.py
def local_open(url):
    """Read a local path, with special support for directories"""
    scheme, server, path, param, query, frag = urlparse(url)
    filename = url2pathname(path)
    if os.path.isfile(filename):
        return urllib2.urlopen(url)
    elif path.endswith('/') and os.path.isdir(filename):
        files = []
        for f in os.listdir(filename):
            if f=='index.html':
                with open(os.path.join(filename,f),'r') as fp:
                    body = fp.read()
                break
            elif os.path.isdir(os.path.join(filename,f)):
                f+='/'
            files.append("<a href=%r>%s</a>" % (f,f))
        else:
            body = ("<html><head><title>%s</title>" % url) + \
                "</head><body>%s</body></html>" % '\n'.join(files)
        status, message = 200, "OK"
    else:
        status, message, body = 404, "Path not found", "Not found"

    headers = {'content-type': 'text/html'}
    return HTTPError(url, status, message, headers, StringIO(body))
def local_open(url):
    scheme, server, path, param, query, frag = urlparse(url)
    filename = url2pathname(path)
    if os.path.isfile(filename):
        return urllib2.urlopen(url)
    elif path.endswith('/') and os.path.isdir(filename):
        files = []
        for f in os.listdir(filename):
            if f=='index.html':
                with open(os.path.join(filename,f),'r') as fp:
                    body = fp.read()
                break
            elif os.path.isdir(os.path.join(filename,f)):
                f+='/'
            files.append("<a href=%r>%s</a>" % (f,f))
        else:
            body = ("<html><head><title>%s</title>" % url) + \
                "</head><body>%s</body></html>" % '\n'.join(files)
        status, message = 200, "OK"
    else:
        status, message, body = 404, "Path not found", "Not found"

    headers = {'content-type': 'text/html'}
    return HTTPError(url, status, message, headers, StringIO(body))
def local_open ( url ) : scheme , server , path , param , query , frag = urlparse ( url ) filename = url2pathname ( path ) if os . path . isfile ( filename ) : return urllib2 . urlopen ( url ) elif path . endswith ( '/' ) and os . path . isdir ( filename ) : files = [ ] for f in os . listdir ( filename ) : if f == 'index.html' : with open ( os . path . join ( filename , f ) , 'r' ) as fp : body = fp . read ( ) break elif os . path . isdir ( os . path . join ( filename , f ) ) : f += '/' files . append ( "<a href=%r>%s</a>" % ( f , f ) ) else : body = ( "<html><head><title>%s</title>" % url ) + "</head><body>%s</body></html>" % '\n' . join ( files ) status , message = 200 , "OK" else : status , message , body = 404 , "Path not found" , "Not found" headers = { 'content-type' : 'text/html' } return HTTPError ( url , status , message , headers , StringIO ( body ) )
Read a local path, with special support for directories
Read a local path with special support for directories