summaryrefslogtreecommitdiff
path: root/tools/extract.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/extract.py')
-rwxr-xr-x[-rw-r--r--]tools/extract.py15
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()