blob: 3381da592e5329b03bfcb5051172f0aad5df6824 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# -*- coding: utf-8 -*-
from git_taskrepo.command import Command
class List(Command):
"""List Tasks"""
enabled = True
def options(self):
self.parser.usage = "%%prog %s" % self.normalized_name
self.parser.add_option(
"--type",
metavar="TYPE",
action="append",
help="List tasks only of TYPE")
def run(self, *args, **kwargs):
self.set_repo(**kwargs)
self.set_taskrepo(**kwargs)
conn = self.taskrepo
with conn:
cur = conn.cursor()
cur.execute("SELECT origin FROM config")
result = cur.fetchone()
origin = result[0]
values = []
joins = []
where = []
extra = ""
if kwargs.get("type"):
for x in range(0, len(kwargs.get("type"))):
joins.append("LEFT JOIN key_value_inc AS kvi_%d ON kvi_%d.task_id = tasks.id" % (x, x))
where.append("kvi_%d.key='types' AND kvi_%d.value=?" % (x, x))
values.append(kwargs.get("type")[x])
if where:
extra = ' '.join(joins)
extra = "%s WHERE %s" % (extra, ' AND '.join(where))
cur.execute("SELECT name FROM tasks %s" % extra, values)
rows = cur.fetchall()
for row in rows:
print "%s" % row[0]
|