[mhonarc] expand make_index
- From: Olav Vitters <ovitters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mhonarc] expand make_index
- Date: Mon, 11 Feb 2013 22:11:05 +0000 (UTC)
commit bb1d848db2ba7e33bf6b6d75f71657260e0b5265
Author: Olav Vitters <olav vitters nl>
Date: Mon Feb 11 23:11:02 2013 +0100
expand make_index
archive.py | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/archive.py b/archive.py
index 1f7e152..e09ef19 100755
--- a/archive.py
+++ b/archive.py
@@ -7,6 +7,7 @@ import gzip
import argparse
import time
import dateutil.parser
+import re
class Archiver:
@@ -104,6 +105,37 @@ class Archiver:
def make_index(listname, private=False):
path = os.path.join(self.PRIVATE_ARCHIVE_DIR, listname)
+ dirs = {}
+ re_path = re.compile(r'^(\d+)-(\w+)$')
+ for a_dir in os.listdir(path):
+ mo = re_path.match(a_dir)
+ if mo is None or not os.path.isdir(os.path.join(path, a_dir)):
+ continue
+
+ year = mo.group(1)
+ month = mo.group(2).lower()
+
+ if month in self.MONTHS:
+ dirs[a_dir] = (long(year) * 100) + self.MONTHS[month]
+ else:
+ dirs[a_dir] = a_dir
+
+ with open(os.path.join(path, 'index.html', 'w') as fp:
+ for a_dir in sorted(dirs, key=dirs.get):
+ # XXX - write header
+ # XXX - determine mbox type
+
+ fd.write('''
+ <tr>
+ <td>%s</td>
+ <td>
+ <A href="%s/thread.html">Thread</a>
+ <A href="%s/date.html">Date</a>
+ <A href="%s/author.html">Author</a>
+ </td>
+ <td><A href="%s">%s</a></td>
+ </tr>''' % (a_dir, a_dir, a_dir, a_dir, mboxfile, mboxsize))
+
def mkdate(datestr):
#return time.strptime(datestr, '%Y-%m-%d')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]