summaryrefslogtreecommitdiff
path: root/extract.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2021-02-14 21:23:06 +0000
committerRob Austein <sra@hactrn.net>2021-02-14 21:23:06 +0000
commit88aaae1214226791cb1a862d02319a8470eea7e4 (patch)
tree6a48249b0e721b2170f37a3405b95e77de54bb76 /extract.py
parent5dc6a6966bb950cb19439e0dc57f77a630254f19 (diff)
Fix publication dates
Diffstat (limited to 'extract.py')
-rwxr-xr-xextract.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/extract.py b/extract.py
index ab77f01..33a49e1 100755
--- a/extract.py
+++ b/extract.py
@@ -40,12 +40,6 @@ attachment_query = '''
filename, time
'''
-markdown_header = '''\
-Date: {0.isotime}
-Title: {0.name}
-
-'''.format
-
def attachment_link(row):
h = lambda whatever: hashlib.sha1(whatever.encode()).hexdigest()
h1 = h(row.id)
@@ -79,6 +73,14 @@ class Row(sqlite3.Row):
def isotime(self):
return time.strftime("%Y-%m-%d %H:%M", time.gmtime(self.time))
+def markdown_header(row, first_published):
+ if row.name in first_published:
+ modtime = "Modified: {}\n".format(row.isotime)
+ else:
+ modtime = ""
+ first_published[row.name] = row.isotime
+ return "Title: {}\nDate: {}\n{}\n".format(row.name, first_published[row.name], modtime)
+
def main():
for dn in ("wiki", "pelican"):
@@ -91,6 +93,8 @@ def main():
keep = Filter()
+ first_published = {}
+
db = sqlite3.connect("trac.db")
db.row_factory = Row
@@ -100,7 +104,7 @@ def main():
print(slug, row.version)
with open("wiki/{}.trac".format(slug), "w") as f:
f.write(row.text)
- md = markdown_header(row) + trac2md.WikiToMD(row.text, slug)
+ md = markdown_header(row, first_published) + trac2md.WikiToMD(row.text, slug)
with open("pelican/content/{}.md".format(slug), "w") as f:
f.write(md)