summaryrefslogtreecommitdiff
path: root/sandbox/mly/restblog/date_index.py
diff options
context:
space:
mode:
authormly <mly@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2003-06-12 08:49:32 +0000
committermly <mly@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2003-06-12 08:49:32 +0000
commita01c079efafc22be5cecab4e15a01e643b03780b (patch)
tree7b93025af0e21459f3565ff06c32cfcf0fb06b36 /sandbox/mly/restblog/date_index.py
parent0711e77012533cc858e067bc3e4493a50e735912 (diff)
downloaddocutils-a01c079efafc22be5cecab4e15a01e643b03780b.tar.gz
Initial checkin of reStructuredBlog.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@1431 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'sandbox/mly/restblog/date_index.py')
-rwxr-xr-xsandbox/mly/restblog/date_index.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/sandbox/mly/restblog/date_index.py b/sandbox/mly/restblog/date_index.py
new file mode 100755
index 000000000..f430fb08f
--- /dev/null
+++ b/sandbox/mly/restblog/date_index.py
@@ -0,0 +1,39 @@
+#!/usr/bin/python -tt
+
+# date_index.py
+#
+# Create chronological index for reStructuredBlog
+#
+# (C) Magnus Lyckå, Thinkware AB, 2003
+
+import glob, restblog
+import cPickle as pickle
+
+IX_FILE_NAME = 'date_index.dat'
+
+try:
+ db = pickle.load(file(IX_FILE_NAME))
+except:
+ db = {'filenames':[], 'index':[]}
+
+for fn in glob.glob(restblog.source_pattern):
+ if not fn in db['filenames']:
+ db['filenames'].append(fn)
+ meta = restblog.Metadata(fn)
+ db['index'].append((meta.timestamp(),
+ meta.targetname(),
+ meta.subject()))
+db['index'].sort()
+db['index'].reverse()
+pickle.dump(db, file(IX_FILE_NAME, 'w'))
+
+body = ['Index By Date\n--------------------\n\n']
+oldMonthYear = ''
+for ts, fn, subj in db['index']:
+ monthYear = ts.strftime('%B %Y')
+ if monthYear != oldMonthYear:
+ body.append("\n\n%s\n.............................\n\n" % monthYear)
+ oldMonthYear = monthYear
+ body.append("* `%s %s`__\n\n__ %s\n" % (
+ ts.strftime('%Y-%m-%d %H:%M'), subj, fn))
+restblog.makepage('date_index', "\n".join(body))