diff options
| author | Steve Kowalik <steven@wedontsleep.org> | 2015-12-10 11:37:29 +1300 |
|---|---|---|
| committer | Steve Kowalik <steven@wedontsleep.org> | 2015-12-10 11:37:29 +1300 |
| commit | 792edda4143317996f83ac5f1ae0db0695173397 (patch) | |
| tree | 2fb5ddca2484116572fc1142a8fb51e052c1be75 /setuptools/package_index.py | |
| parent | a718819d2849196e902808301c9a95724510c5c1 (diff) | |
| parent | 81ca4fea9e4672f39864439f2049108ad731c8fa (diff) | |
| download | python-setuptools-git-792edda4143317996f83ac5f1ae0db0695173397.tar.gz | |
Merge from master.
Diffstat (limited to 'setuptools/package_index.py')
| -rwxr-xr-x | setuptools/package_index.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/setuptools/package_index.py b/setuptools/package_index.py index cabf1039..525cb645 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -1031,16 +1031,18 @@ def local_open(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: + filepath = os.path.join(filename, f) + if f == 'index.html': + with open(filepath, '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)) + elif os.path.isdir(filepath): + f += '/' + files.append('<a href="{name}">{name}</a>'.format(name=f)) else: - body = ("<html><head><title>%s</title>" % url) + \ - "</head><body>%s</body></html>" % '\n'.join(files) + tmpl = ("<html><head><title>{url}</title>" + "</head><body>{files}</body></html>") + body = tmpl.format(url=url, files='\n'.join(files)) status, message = 200, "OK" else: status, message, body = 404, "Path not found", "Not found" |
