diff options
author | Rob Austein <sra@hactrn.net> | 2021-02-14 01:35:10 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2021-02-14 01:35:10 +0000 |
commit | 23bb68fe7e9cc8af176ff60b56e8a51a70f05a89 (patch) | |
tree | 27c87a0c157e6eb343518031c4c3afd1e95bc488 /tools/extract.py | |
parent | fa8b4d0e872d182ee878020fb1b066ce0da621ae (diff) |
Now generating pages directly from sqlite3
Diffstat (limited to 'tools/extract.py')
-rwxr-xr-x[-rw-r--r--] | tools/extract.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/tools/extract.py b/tools/extract.py index f323d44..3d39eb5 100644..100755 --- a/tools/extract.py +++ b/tools/extract.py @@ -3,10 +3,13 @@ import fnmatch import hashlib import json +import os import sqlite3 import time import urllib.parse +import trac2md + wiki_query = ''' SELECT name, @@ -38,10 +41,10 @@ attachment_query = ''' ''' def isotime(t): - return None if t == 0 else time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(t)) + return None if t == 0 else time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(t)) def hashname(whatever): - return hashlib.sha1(unicode(whatever)).hexdigest() + return hashlib.sha1(unicode(whatever)).hexdigest() with open("filter.json") as f: filter = json.load(f) @@ -62,6 +65,12 @@ db.row_factory = Row for row in db.execute(wiki_query): if keep(row.name): - print(urllib.parse.quote(row.name, ""), row.version) + slug = urllib.parse.quote(row.name, "") + print(slug, row.version) + with open("tracwiki/{}.trac".format(slug), "w") as f: + f.write(row.text) + md = trac2md.WikiToMD(row.text) + with open("markdown/{}.md".format(slug), "w") as f: + f.write(md) db.close() |