summaryrefslogtreecommitdiff
path: root/setuptools/package_index.py
diff options
context:
space:
mode:
authorSteve Kowalik <steven@wedontsleep.org>2015-12-10 11:37:29 +1300
committerSteve Kowalik <steven@wedontsleep.org>2015-12-10 11:37:29 +1300
commit792edda4143317996f83ac5f1ae0db0695173397 (patch)
tree2fb5ddca2484116572fc1142a8fb51e052c1be75 /setuptools/package_index.py
parenta718819d2849196e902808301c9a95724510c5c1 (diff)
parent81ca4fea9e4672f39864439f2049108ad731c8fa (diff)
downloadpython-setuptools-git-792edda4143317996f83ac5f1ae0db0695173397.tar.gz
Merge from master.
Diffstat (limited to 'setuptools/package_index.py')
-rwxr-xr-xsetuptools/package_index.py16
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"