From 2ad8ed0931836e44201b25856b1499b0482a6da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 1 Jan 2018 22:56:47 +0100 Subject: [PATCH] Tools: Add simple script that extract keywords from given trac database --- tools/trac-keywords.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tools/trac-keywords.py diff --git a/tools/trac-keywords.py b/tools/trac-keywords.py new file mode 100644 index 000000000..7332bc6f6 --- /dev/null +++ b/tools/trac-keywords.py @@ -0,0 +1,37 @@ + +import subprocess +import sys + +TRACDB = 'trac.db' + +def readdb(): + global TRACDB + cmds = ['sqlite3', TRACDB, 'SELECT id,keywords FROM ticket WHERE status<>"closed";'] + p = subprocess.Popen(cmds, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + comm = p.communicate() + data = comm[0] + ret = {} + for line in data.splitlines(): + pos1 = line.find('|') + if pos1 <= 0: + continue + nr = line[:pos1] + for kw in line[pos1+1:].split(' '): + if kw not in ret: + ret[kw] = [] + ret[kw].append(nr); + return ret + +for arg in sys.argv[1:]: + if arg.endswith('/trac.db'): + global TRACDB + TRACDB = arg + +data = readdb() +for kw in sorted(data.keys()): + out = kw + ':' + for ticket in data[kw]: + out = out + ' ' + ticket + print(out) + +