Skip to content

Instantly share code, notes, and snippets.

@fwilhe
Created May 6, 2016 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fwilhe/27b3eb278615f2d14d963db478279e26 to your computer and use it in GitHub Desktop.
Save fwilhe/27b3eb278615f2d14d963db478279e26 to your computer and use it in GitHub Desktop.
unextract.py
#!/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