summaryrefslogtreecommitdiff
path: root/extract.py
diff options
context:
space:
mode:
Diffstat (limited to 'extract.py')
-rwxr-xr-xextract.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/extract.py b/extract.py
index 9466769..ab77f01 100755
--- a/extract.py
+++ b/extract.py
@@ -40,8 +40,11 @@ attachment_query = '''
filename, time
'''
-def isotime(t):
- return None if t == 0 else time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(t))
+markdown_header = '''\
+Date: {0.isotime}
+Title: {0.name}
+
+'''.format
def attachment_link(row):
h = lambda whatever: hashlib.sha1(whatever.encode()).hexdigest()
@@ -50,7 +53,7 @@ def attachment_link(row):
fn2 = os.path.splitext(row["filename"])[1]
return \
os.path.join("attachments", "wiki", h1[:3], h1, h2 + fn2), \
- os.path.join("pelican", "content", urllib.parse.quote(row.id, ""), urllib.parse.quote(row.filename, ""))
+ os.path.join("pelican", "content", urllib.parse.quote(row.id, ""), row.filename)
class Filter:
@@ -68,9 +71,14 @@ class Filter:
return True
class Row(sqlite3.Row):
+
def __getattr__(self, name):
return self[name]
+ @property
+ def isotime(self):
+ return time.strftime("%Y-%m-%d %H:%M", time.gmtime(self.time))
+
def main():
for dn in ("wiki", "pelican"):
@@ -92,7 +100,7 @@ def main():
print(slug, row.version)
with open("wiki/{}.trac".format(slug), "w") as f:
f.write(row.text)
- md = trac2md.WikiToMD(row.text, slug)
+ md = markdown_header(row) + trac2md.WikiToMD(row.text, slug)
with open("pelican/content/{}.md".format(slug), "w") as f:
f.write(md)