2018-01-01 22:56:47 +01:00
|
|
|
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
|
|
|
TRACDB = 'trac.db'
|
|
|
|
|
2018-02-13 09:26:11 +01:00
|
|
|
|
2018-01-01 22:56:47 +01:00
|
|
|
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]
|
2018-02-13 09:26:11 +01:00
|
|
|
for kw in line[pos1 + 1:].split(' '):
|
2018-01-01 23:08:58 +01:00
|
|
|
if kw == '':
|
|
|
|
continue
|
2018-01-01 22:56:47 +01:00
|
|
|
if kw not in ret:
|
|
|
|
ret[kw] = []
|
2018-02-13 09:26:11 +01:00
|
|
|
ret[kw].append(nr)
|
2018-01-01 22:56:47 +01:00
|
|
|
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)
|