import os import time out_filename = 'index.html' header = \ '\n' \ '\n' \ 'Miscellany\n' \ '\n' \ '\n' \ '\n' \ '\n' \ '

http://rainwarrior.ca/misc/

\n' \ '
\n' \ '\n' \ '\n' \ '\n' footer0 = \ '
./
../
\n' \ '
\n' \ '
\n' \ '
  ___     ___      ___\n' \
    ' {o,o}   {o.o}    {o,o}\n' \
    ' |)__)   |)_(|    (__(|\n' \
    ' -"-"-   -"-"-    -"-"-\n' \
    'O RLY?  YA RLY   NO WAI!
\n' \ '
\n' \ '

\n' \ 'rainwarrior @ gmail.com
\n' footer1 = \ '
\n' \ '\n' \ '\n' def dump_files(): s = header for dirpath, dirnames, filenames in os.walk('.'): for dirname in dirnames: s += ('%s/' \ '' \ '' \ '' \ '\n' \ % (dirname, dirname)) for filename in filenames: if filename == out_filename: continue stat = os.stat(filename) fsize = int(stat.st_size / 1024) fdate = time.localtime(stat.st_mtime) s += ('%s' \ '%d kB' \ '%2d/%02d/%4d' \ '%2d:%02d:%02d' \ '\n' \ % (filename, filename, fsize, \ fdate.tm_mon, fdate.tm_mday, fdate.tm_year, \ fdate.tm_hour, fdate.tm_min, fdate.tm_sec)) s += footer0 now = time.localtime() s += ('%2d/%02d/%04d' % (now.tm_mon, now.tm_mday, now.tm_year)) s += footer1 print(s) fo = open(out_filename, 'wt') fo.write(s) fo.close() if __name__ == "__main__": dump_files()