ref: 5778a58b4eba8d99cfcc06d731a35d7358a3a113
parent: 73dcb5fa40e20c280552255b35edcabf9bd2bff8
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Sep 5 19:39:30 EDT 2016
Update to latest running code.
--- a/mkarchive.py
+++ b/mkarchive.py
@@ -5,6 +5,8 @@
import subprocess
import time
import distutils.dir_util
+import datetime
+from datetime import datetime
p = argparse.ArgumentParser(description = 'Generate a mail archive')
p.add_argument('-o', '--outdir', metavar='outdir', help='generate archive under this directory')
@@ -46,7 +48,6 @@
print maildir
for p in os.listdir(maildir):
if int(p) <= lastindex:
- print "already added ", p
continue
mailfile = os.path.join(maildir, p)
runmailadd(lst, mailfile)
@@ -55,8 +56,13 @@
f.write(str(maxindex))
def datesorted(dates):
- return sorted(dates, reverse=True)
+ def datecmp(a, b):
+ a = datetime.strptime(a, '%Y-%b')
+ b = datetime.strptime(b, '%Y-%b')
+ return b.toordinal() - a.toordinal()
+ return sorted(dates, cmp=datecmp)
+
def genindex(lst):
listdir = os.path.join(opts.outdir, lst)
with open(os.path.join(listdir, 'index.html'), 'w') as f:
@@ -69,6 +75,7 @@
</head>
<body>
<header><h1>Eigenstate: %s list archives</h1></header>
+ <div id=main>
<nav>
<a href="/">Home</a><br>
<ul>
@@ -76,12 +83,13 @@
</ul>
</nav>
<article><ul>""" % (lst, lst))
- for d in datesorted(os.listdir(listdir)):
- if os.path.isdir(os.path.join(listdir, d)):
- f.write('<li><a href=%s>%s</a></li>' % (d, d))
+ dirs = filter(lambda d: os.path.isdir(os.path.join(listdir, d)), os.listdir(listdir))
+ for d in datesorted(dirs):
+ f.write('<li><a href=%s>%s</a></li>' % (d, d))
f.write("""
</ul>
</article>
+ </div>
<footer>Hey, look at me! I'm a footer!</footer>
</body></html>""")