Created
May 6, 2016 20:38
-
-
Save fwilhe/27b3eb278615f2d14d963db478279e26 to your computer and use it in GitHub Desktop.
unextract.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function | |
from jinja2 import Template | |
import zipfile | |
htmlTemplate = ''' | |
<html> | |
<body> | |
<table border="1"> | |
{% for file in files %} | |
{% if not file.filename.endswith("/") %} | |
<tr> | |
<td><a href="{{ file.filename }}">{{ file.filename }}</a></td> | |
<td>{{ file.file_size }}</td> | |
<td>{{ file.date_time[0] }}-{{ file.date_time[1] }}-{{ file.date_time[2] }}</td> | |
</tr> | |
{% endif %} | |
{% endfor %} | |
</table> | |
</body> | |
</html> | |
''' | |
with zipfile.ZipFile('master.zip', 'r') as zipArchive: | |
zipArchive.extractall() | |
with open('index.html', 'w') as indexHtmlFile: | |
print(Template(htmlTemplate).render(files=zipArchive.filelist), file=indexHtmlFile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment