Replaced tuple by dict.

This commit is contained in:
Antoni Boucher 2015-08-07 22:45:54 -04:00
parent 4c1ed35390
commit fedf9d9c72
2 changed files with 8 additions and 6 deletions

View File

@ -49,10 +49,12 @@ def dirbrowser(url):
else: else:
parent = os.path.dirname(url) parent = os.path.dirname(url)
all_files = os.listdir(url) all_files = os.listdir(url)
files = sorted([(file, os.path.join(url, file)) for file in all_files if files = sorted([{'name': file, 'absname': os.path.join(url, file)}
is_file(file)]) for file in all_files if is_file(file)],
directories = sorted([(file, os.path.join(url, file)) for file in key=lambda v: v['name'].lower())
all_files if is_dir(file)]) directories = sorted([{'name': file, 'absname': os.path.join(url, file)}
for file in all_files if is_dir(file)],
key=lambda v: v['name'].lower())
html = template.render(title=title, url=url, icon='', parent=parent, html = template.render(title=title, url=url, icon='', parent=parent,
files=files, directories=directories) files=files, directories=directories)
return html return html

View File

@ -31,11 +31,11 @@
{% endif %} {% endif %}
{% for item in directories %} {% for item in directories %}
<li><a href="file://{{item.1}}">{{item.0}}</a></li> <li><a href="file://{{item.absname}}">{{item.name}}</a></li>
{% endfor %} {% endfor %}
{% for item in files %} {% for item in files %}
<li><a href="file://{{item.1}}">{{item.0}}</a></li> <li><a href="file://{{item.absname}}">{{item.name}}</a></li>
{% endfor %} {% endfor %}
</ul> </ul>
</div> </div>