blob: d60de84d197a4135ed35bbcde5903fd4621237dc (
plain) (
tree)
|
|
#!/usr/bin/env python3
import fnmatch
import hashlib
import json
import sqlite3
import time
import urllib.parse
wiki_query = '''
SELECT
name,
version,
time / 1000000 AS time,
text
FROM wiki
ORDER BY
name, version
'''
attachment_query = '''
SELECT
id,
filename,
size,
author,
description,
ipnr,
time / 1000000 AS createdtime
FROM
attachment
WHERE
id = ?
AND
type = 'wiki'
ORDER BY
filename, time
'''
def isotime(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()
with open("filter.json") as f:
filter = json.load(f)
def keep(name):
for k, v in filter:
assert k in "+-"
if fnmatch.fnmatch(name, v):
return k == "+"
return True
db = sqlite3.connect("trac.db")
db.row_factory = sqlite3.Row
for row in db.execute(wiki_query):
if keep(row["name"]):
print(urllib.parse.quote(row["name"], ""), row["version"])
db.close()
|