summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-x[-rw-r--r--]tools/extract.py15
-rwxr-xr-xtools/references/convert-and-slurp-attachments.sh (renamed from tools/convert-and-slurp-attachments.sh)0
-rw-r--r--tools/references/extract-wiki-content.xsl (renamed from tools/extract-wiki-content.xsl)0
-rwxr-xr-xtools/references/generate-json.py (renamed from tools/generate-json.py)0
-rw-r--r--tools/references/rpki-wiki-to-markdown.py (renamed from tools/rpki-wiki-to-markdown.py)0
-rw-r--r--tools/references/schema.sql (renamed from tools/schema.sql)0
-rw-r--r--tools/references/trac-wiki-to-markdown.rb (renamed from tools/trac-wiki-to-markdown.rb)0
-rw-r--r--tools/references/trac2down.py (renamed from tools/trac2down.py)0
-rwxr-xr-xtools/trac2md.py16
9 files changed, 20 insertions, 11 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()
diff --git a/tools/convert-and-slurp-attachments.sh b/tools/references/convert-and-slurp-attachments.sh
index ce7f34d..ce7f34d 100755
--- a/tools/convert-and-slurp-attachments.sh
+++ b/tools/references/convert-and-slurp-attachments.sh
diff --git a/tools/extract-wiki-content.xsl b/tools/references/extract-wiki-content.xsl
index e4376e8..e4376e8 100644
--- a/tools/extract-wiki-content.xsl
+++ b/tools/references/extract-wiki-content.xsl
diff --git a/tools/generate-json.py b/tools/references/generate-json.py
index b8b1f38..b8b1f38 100755
--- a/tools/generate-json.py
+++ b/tools/references/generate-json.py
diff --git a/tools/rpki-wiki-to-markdown.py b/tools/references/rpki-wiki-to-markdown.py
index dff87e6..dff87e6 100644
--- a/tools/rpki-wiki-to-markdown.py
+++ b/tools/references/rpki-wiki-to-markdown.py
diff --git a/tools/schema.sql b/tools/references/schema.sql
index 1515dbb..1515dbb 100644
--- a/tools/schema.sql
+++ b/tools/references/schema.sql
diff --git a/tools/trac-wiki-to-markdown.rb b/tools/references/trac-wiki-to-markdown.rb
index f7d41ae..f7d41ae 100644
--- a/tools/trac-wiki-to-markdown.rb
+++ b/tools/references/trac-wiki-to-markdown.rb
diff --git a/tools/trac2down.py b/tools/references/trac2down.py
index c66a201..c66a201 100644
--- a/tools/trac2down.py
+++ b/tools/references/trac2down.py
diff --git a/tools/trac2md.py b/tools/trac2md.py
index 8729faa..838a36f 100755
--- a/tools/trac2md.py
+++ b/tools/trac2md.py
@@ -19,7 +19,7 @@ strikethrough_pattern = re.compile('~~(.*)~~')
camelcase_pattern = re.compile("!(\w+)")
wikiheading_patterns = tuple((level, re.compile("^{} (.*)[ \t]*=*$".format("=" * level)))
- for level in xrange(1, 7))
+ for level in range(1, 7))
def to_timestamp(tm):
''' Convert to timestamp which can be jsonified '''
@@ -205,10 +205,10 @@ def WikiToMD(content):
return "".join(new_content)
-for f in sys.argv[1:]:
- d = WikiToMD(open(f, "r").read())
- newf = f.replace(".trac", ".md")
- with open(newf, "w") as fp:
- fp.write(d)
- pass
- pass
+if __name__ == "__main__":
+ for f in sys.argv[1:]:
+ d = WikiToMD(open(f, "r").read())
+ newf = f.replace(".trac", ".md")
+ with open(newf, "w") as fp:
+ fp.write(d)
+ pass