Skip to content

Instantly share code, notes, and snippets.

@atttx123
Created November 23, 2016 10:29
Show Gist options
  • Select an option

  • Save atttx123/b345e4dd5fcd9d51e0ce21bbafd3c44c to your computer and use it in GitHub Desktop.

Select an option

Save atttx123/b345e4dd5fcd9d51e0ce21bbafd3c44c to your computer and use it in GitHub Desktop.
文件列表
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import glob
from os.path import join, getmtime
if __name__ == '__main__':
html = "<html><head><titile></titile>"
html += '<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">'
html += '<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>'
html += '<script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>'
html += '<style>span{display:inline-block;text-overflow:ellipsis;overflow:hidden}</style>'
html += '</head><body class="container">'
for phone in glob.glob("*/"):
for date in sorted(glob.glob(join(phone, "*/")), key=getmtime)[-1:]:
for time in sorted(glob.glob(join(date, "*/")), key=getmtime)[-1:]:
html += '<div class="row"><h2>* %s</h2>' % (time)
for name in glob.glob(join(time, "*/")):
html += '<fieldset><legend>** %s</legend><div class="row">' % (name.split("/")[-2])
for img in glob.glob(join(name, "*.png")):
html += '<div class="col-md-2"><img class="img-responsive" '
html += 'src="%s"/><span class="col-md-12">%s</span></div>' % (img, img.split("/")[-1])
html += '</div></fieldset>'
html += '</div>'
html += '</body></html>'
print html
# vim:ai:et:sts=4:sw=4:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment