From 490fb9247135327a71157a14a07cedd809995c63 Mon Sep 17 00:00:00 2001 From: Bill Peck Date: Wed, 6 May 2015 16:16:21 -0400 Subject: Initialized to use tito. --- git_taskrepo/sub_commands/cmd_list.py | 45 ---------------------------- git_taskrepo/sub_commands/cmd_list_runfor.py | 24 +++++++++++++++ git_taskrepo/sub_commands/cmd_list_tasks.py | 45 ++++++++++++++++++++++++++++ git_taskrepo/sub_commands/cmd_list_types.py | 24 +++++++++++++++ 4 files changed, 93 insertions(+), 45 deletions(-) delete mode 100644 git_taskrepo/sub_commands/cmd_list.py create mode 100644 git_taskrepo/sub_commands/cmd_list_runfor.py create mode 100644 git_taskrepo/sub_commands/cmd_list_tasks.py create mode 100644 git_taskrepo/sub_commands/cmd_list_types.py (limited to 'git_taskrepo') diff --git a/git_taskrepo/sub_commands/cmd_list.py b/git_taskrepo/sub_commands/cmd_list.py deleted file mode 100644 index 3381da5..0000000 --- a/git_taskrepo/sub_commands/cmd_list.py +++ /dev/null @@ -1,45 +0,0 @@ - -# -*- 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] diff --git a/git_taskrepo/sub_commands/cmd_list_runfor.py b/git_taskrepo/sub_commands/cmd_list_runfor.py new file mode 100644 index 0000000..fca58bb --- /dev/null +++ b/git_taskrepo/sub_commands/cmd_list_runfor.py @@ -0,0 +1,24 @@ + +# -*- coding: utf-8 -*- + +import xml.dom.minidom +from git_taskrepo.command import Command + +class List_RunFor(Command): + """List Runfor""" + enabled = True + + def options(self): + self.parser.usage = "%%prog %s" % self.normalized_name + + def run(self, *args, **kwargs): + self.set_repo(**kwargs) + self.set_taskrepo(**kwargs) + conn = self.taskrepo + with conn: + cur = conn.cursor() + cur.execute("SELECT DISTINCT value FROM runfor") + rows = cur.fetchall() + + for row in rows: + print "%s" % row[0] diff --git a/git_taskrepo/sub_commands/cmd_list_tasks.py b/git_taskrepo/sub_commands/cmd_list_tasks.py new file mode 100644 index 0000000..3381da5 --- /dev/null +++ b/git_taskrepo/sub_commands/cmd_list_tasks.py @@ -0,0 +1,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] diff --git a/git_taskrepo/sub_commands/cmd_list_types.py b/git_taskrepo/sub_commands/cmd_list_types.py new file mode 100644 index 0000000..0000a4f --- /dev/null +++ b/git_taskrepo/sub_commands/cmd_list_types.py @@ -0,0 +1,24 @@ + +# -*- coding: utf-8 -*- + +import xml.dom.minidom +from git_taskrepo.command import Command + +class List_Types(Command): + """List Types""" + enabled = True + + def options(self): + self.parser.usage = "%%prog %s" % self.normalized_name + + def run(self, *args, **kwargs): + self.set_repo(**kwargs) + self.set_taskrepo(**kwargs) + conn = self.taskrepo + with conn: + cur = conn.cursor() + cur.execute("SELECT DISTINCT value FROM types") + rows = cur.fetchall() + + for row in rows: + print "%s" % row[0] -- cgit