annotate shelltools/query-pr/query.py @ 45:233dcc4d80e1

update
author David A. Holland
date Mon, 16 Jun 2014 01:27:54 -0400
parents 298c8a7f5181
children 73e6dac29391
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
c013fb703183 Empty placeholder scripts so the build will run.
David A. Holland
parents:
diff changeset
1 #!@PYTHON@
33
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
2
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
3 import argparse
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
4 import psycopg2
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
5
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
6 program_description = """
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
7 Search for and retrieve problem reports.
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
8 """
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
9 program_version = "@VERSION@"
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
10
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
11 ############################################################
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
12 # settings
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
13
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
14 outfile = sys.stdout
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
15 outmaterial = "headers"
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
16 outformat = "text"
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
17
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
18 ############################################################
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
19 # database
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
20
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
21 dblink = None
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
22
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
23 def opendb():
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
24 global dblink
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
25
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
26 host = "localhost"
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
27 user = "swallowtail"
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
28 database = "swallowtail"
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
29 dblink = psycopg2.connect("host=%s user=%s dbname=%s" %
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
30 (host, user, database))
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
31 # end opendb
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
32
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
33 def closedb():
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
34 global dblink
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
35
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
36 dblink.close()
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
37 dblink = None
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
38 # end closedb
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
39
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
40 def querydb(qtext, args):
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
41 print "Executing this query:"
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
42 print qtext
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
43 print "Args are:"
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
44 print args
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
45
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
46 cursor = dblink.cursor()
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
47 cursor.execute(qtext, args)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
48 result = cursor.fetchall()
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
49 cursor.close()
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
50 return result
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
51 # end querydb
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
52
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
53 ############################################################
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
54 #
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
55
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
56 ############################################################
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
57 # query class for searches
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
58
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
59 class Query:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
60 __init__(self):
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
61 self.selections = []
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
62 self.tables = []
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
63 self.constraints = []
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
64 self.args = []
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
65 prtables = ["PRs"]
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
66 prconstraints = []
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
67
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
68 def select(self, s):
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
69 self.selections.append(s)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
70
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
71 def addtable(self, t):
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
72 assert(t not in self.tables)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
73 self.tables.append(t)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
74
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
75 def constrain(self, expr):
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
76 self.constraints.append(t)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
77
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
78 def internval(self, val):
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
79 num = len(self.args)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
80 self.args[num] = val
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
81 return "$%d" % num
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
82
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
83 def textify(self):
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
84 s = "SELECT %s\n" % ",".join(self.selections)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
85 f = "FROM %s\n" % ",".join(self.tables)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
86 w = "WHERE %s\n" % " AND ".join(self.constraints)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
87 return s + f + w
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
88 # end class Query
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
89
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
90 def regexp_constraint(q, field, value):
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
91 cleanval = q.internval(value)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
92 if not isregexp(value):
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
93 return "%s = %s" % (field, cleanval)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
94 else:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
95 # XXX what's the right operator again?
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
96 return "%s ~= %s" % (field, cleanval)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
97 # end regexp_constraint
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
98
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
99 def intrange_constraint(q, field, value):
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
100 (lower, upper) = args.number
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
101 if lower is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
102 assert(typeof(lower) == int)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
103 prq.constrain("%s >= %d" % (field, lower))
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
104 if upper is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
105 assert(typeof(upper) == int)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
106 prq.constrain("%s <= %d" % (field, upper))
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
107 # end intrange_constraint
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
108
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
109 def daterange_constraint(q, field, value):
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
110 # XXX
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
111 assert(0)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
112 # end daterange_constraint
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
113
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
114 ############################################################
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
115 # arg handling
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
116
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
117 def getargs(classification_schemes, classification_schemetypes):
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
118 global outmaterial
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
119 global outformat
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
120
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
121 p = argparse.ArgumentParser(program_description)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
122
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
123 # note: -h/--help is built in by default
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
124 p.add_argument("-v", "--version",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
125 action='version' version=program_version,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
126 help="Print program version and exit")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
127
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
128 p.add_argument("--short",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
129 action='store_const', const="short",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
130 dest='outmaterial',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
131 help="Output in short form (one per line)")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
132 p.add_argument("--headers",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
133 action='store_const', const="headers",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
134 dest='outmaterial',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
135 help="Output in default form (headers only)")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
136 p.add_argument("--full",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
137 action='store_const', const="full",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
138 dest='outmaterial',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
139 help="Output in full form (all material)")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
140 p.add_argument("--attach", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
141 type=int,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
142 action='store',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
143 dest='attach',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
144 help="Output specified attachment")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
145 p.add_argument("--message", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
146 type=int,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
147 action='store',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
148 dest='message',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
149 help="Output specified message")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
150
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
151 p.add_argument("--text",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
152 action='store_const', const="text",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
153 dest='outformat',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
154 help="Output as text (default)")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
155 p.add_argument("--csv",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
156 action='store_const', const="csv",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
157 dest='outformat',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
158 help="Output as comma-separated values")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
159 p.add_argument("--xml",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
160 action='store_const', const="xml",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
161 dest='outformat',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
162 help="Output as XML")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
163 p.add_argument("--json",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
164 action='store_const', const="json",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
165 dest='outformat',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
166 help="Output as JSON")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
167 p.add_argument("--rdf",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
168 action='store_const', const="rdf",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
169 dest='outformat',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
170 help="Output as RDF")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
171 p.add_argument("--rdflike",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
172 action='store_const', const="rdflike",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
173 dest='outformat',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
174 help="Output as RDF-like text")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
175
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
176 p.add_argument("--closed",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
177 action='store_true',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
178 dest='closed', default=False,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
179 help="Search closed PRs as well as open")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
180 p.add_argument("--public",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
181 action='store_true',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
182 dest='public', default=False,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
183 help="Search only public information")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
184
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
185 p.add_argument("--number", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
186 type=intrange,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
187 dest='number',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
188 help="Restrict search to a range of PRs by number")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
189 p.add_argument("--synopsis", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
190 dest='synopsis',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
191 help="Search PRs by their synopsis field")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
192 p.add_argument("--confidential", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
193 type=yesno, choices=["yes", "no"],
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
194 dest='confidential',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
195 help="Search PRs by their confidentiality setting")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
196 p.add_argument("--state", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
197 dest='state',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
198 help="Search PRs by their state")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
199 p.add_argument("--locked", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
200 type=yesno, choices=["yes", "no"],
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
201 dest='locked',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
202 help="Search PRs by their locked setting")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
203 p.add_argument("--arrival-schemaversion", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
204 type=intrange,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
205 dest='arrival_schemaversion',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
206 help="Search PRs by their original schema version")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
207 p.add_argument("--arrival-date", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
208 type=daterange,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
209 dest='arrival_date',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
210 help="Search PRs by arrival date")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
211 p.add_argument("--closed-date", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
212 type=daterange,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
213 dest='closed_date',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
214 help="Search PRs by the date they were closed")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
215 p.add_argument("--last-modified", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
216 type=daterange,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
217 dest='last_modified',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
218 help="Search PRs by the date they were last modified")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
219 p.add_argument("--release", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
220 dest='release',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
221 help="Search PRs by their release information")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
222 p.add_argument("--environment", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
223 dest='environment',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
224 help="Search PRs by their environment information")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
225
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
226 p.add_argument("--originator-name", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
227 dest='originator_name',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
228 help="Search PRs by the name of their originator")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
229 p.add_argument("--originator-email", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
230 dest='originator_email',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
231 help="Search PRs by the email of their originator")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
232 p.add_argument("--originator-id", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
233 type=intrange,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
234 dest='originator_id',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
235 help="Search PRs by the database ID of their originator")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
236
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
237
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
238 p.add_argument("--responsible", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
239 dest='responsible',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
240 help="Search PRs by who's responsible for them")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
241 p.add_argument("--respondent", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
242 dest='respondent',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
243 help="Search PRs by who's a respondent")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
244 p.add_argument("--subscribed", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
245 dest='subscribed',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
246 help="Search PRs by who's subscribed")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
247
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
248 p.add_argument("--messages", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
249 dest='messages',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
250 help="Search PRs by text in the message log")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
251 p.add_argument("--adminlog", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
252 dest='adminlog',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
253 help="Search PRs by text in the administrative log")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
254 p.add_argument("--anytext", nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
255 dest='anytext',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
256 help="Search PRs by text in various fields")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
257
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
258 for scheme in classification_schemes:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
259 p.add_argument("--%s" % scheme, nargs=1,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
260 dest=scheme,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
261 help="Search PRs by the %s classification scheme" %
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
262 scheme)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
263
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
264 p.add_argument("prs", nargs='*', metavar="PR",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
265 type=int,
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
266 action='append',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
267 dest='prs',
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
268 help="Specific PRs to retrieve by number")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
269
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
270 args = p.parse_args()
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
271
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
272 if args.outmaterial is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
273 outmaterial = args.outmaterial
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
274 if args.outformat is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
275 outformat = args.outformat
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
276
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
277 # If we're doing something other than a search, do it now
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
278 if args.attach is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
279 get_attachment(args.attach)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
280 exit(0)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
281 if args.message is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
282 get_message(args.message)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
283 exit(0)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
284
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
285 if args.prs is not None and len(args.prs) > 0:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
286 show_prs(args.prs)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
287 exit(0)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
288
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
289 #
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
290 # Collect up the search constraints
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
291 #
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
292
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
293 # 1. Constraints on the PRs table
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
294 checkprtable = False
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
295 prq = Query()
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
296 prq.select("PRs.id as id")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
297 prq.addtable("PRs")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
298 if not args.closed:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
299 checkprtable = True
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
300 prq.addtable("states")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
301 prq.constrain("PRs.state = states.name")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
302 prq.constrain("states.closed = FALSE")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
303 if args.public:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
304 checkprtable = True
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
305 prq.constrain("NOT PRs.confidential")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
306 if args.number is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
307 checkprtable = True
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
308 intrange_constraint(prq, "PRs.id", args.number)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
309 if args.synopsis is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
310 checkprtable = True
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
311 regexp_constraint(prq, "PRs.synopsis", args.synopsis)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
312 if args.confidential is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
313 checkprtable = True
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
314 assert(typeof(args.confidential) == bool)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
315 if args.confidential:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
316 prq.constrain("PRs.confidential")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
317 else:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
318 prq.constrain("not PRs.confidential")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
319 if args.state is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
320 checkprtable = True
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
321 regexp_constraint(prq, "PRs.state", args.state)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
322 if args.locked is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
323 checkprtable = True
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
324 assert(typeof(args.locked) == bool)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
325 if args.locked:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
326 prq.constrain("PRs.locked")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
327 else:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
328 prq.constrain("not PRs.locked")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
329 if args.arrival_schemaversion is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
330 checkprtable = True
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
331 intrange_constraint(prq, "PRs.arrival_schemaversion",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
332 args.arrival_schemaversion)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
333 if args.arrival_date is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
334 checkprtable = True
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
335 daterange_constraint(prq, "PRs.arrival_date",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
336 args.arrival_date)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
337 if args.closed_date is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
338 checkprtable = True
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
339 daterange_constraint(prq, "PRs.closed_date",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
340 args.closed_date)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
341 if args.last_modified is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
342 checkprtable = True
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
343 daterange_constraint(prq, "PRs.last_modified",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
344 args.last_modified)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
345 if args.release is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
346 checkprtable = True
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
347 regexp_constraint(prq, "PRs.release", args.release)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
348 if args.environment is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
349 checkprtable = True
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
350 regexp_constraint(prq, "PRs.environment", args.environment)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
351
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
352 if args.originator_name is not None or
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
353 args.originator_email is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
354 prq.addtable("usermail as originator")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
355 prq.constrain("PRs.originator = originator.id")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
356 if args.originator_name is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
357 checkprtable = True
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
358 regexp_constraint(prq, "originator.realname",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
359 args.originator_name)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
360 if args.originator_email is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
361 checkprtable = True
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
362 regexp_constraint(prq, "originator.email",
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
363 args.originator_name)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
364 if args.originator_id is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
365 checkprtable = True
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
366 intrange_constraint(prq, "PRs.originator", args.originator_id)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
367
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
368 queries = []
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
369 if checkprtable:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
370 queries.append(prq)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
371
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
372 if args.responsible is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
373 sq = Query()
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
374 sq.select("subscriptions.pr as id")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
375 sq.addtable("subscriptions")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
376 sq.addtable("users")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
377 sq.constrain("subscriptions.userid = users.id")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
378 regexp_constraint(sq, "users.realname", args.responsible)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
379 sq.constrain("subscriptions.responsible")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
380 queries.append(sq)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
381 if args.respondent is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
382 sq = Query()
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
383 sq.select("subscriptions.pr as id")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
384 sq.addtable("subscriptions")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
385 sq.addtable("users as subscribed")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
386 sq.constrain("subscriptions.userid = users.id")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
387 regexp_constraint(sq, "users.realname", args.respondent)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
388 sq.constrain("subscriptions.reporter")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
389 queries.append(sq)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
390 if args.subscribed is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
391 sq = Query()
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
392 sq.select("subscriptions.pr as id")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
393 sq.addtable("subscriptions")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
394 sq.addtable("users as subscribed")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
395 sq.constrain("subscriptions.userid = users.id")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
396 regexp_constraint(sq, "users.realname", args.subscribed)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
397 queries.append(sq)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
398
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
399 if args.messages is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
400 mq = Query()
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
401 mq.select("messages.pr as id")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
402 mq.addtable("messages")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
403 regexp_constraint(sq, "messages.text", args.messages)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
404 queries.append(mq)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
405
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
406 if args.adminlog is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
407 aq = Query()
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
408 aq.select("adminlog.pr as id")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
409 aq.addtable("adminlog")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
410 regexp_constraint(sq, "adminlog.change", args.adminlog)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
411 regexp_constraint(sq, "adminlog.comment", args.adminlog)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
412 assert(len(aq.constraints) == 2)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
413 x = "%s OR %s" % (aq.constraints[0], aq.constraints[1])
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
414 aq.constraints = [x]
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
415 queries.append(aq)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
416
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
417 if args.anytext is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
418 choke("--anytext isn't supported yet")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
419
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
420 for scheme in classification_schemes:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
421 if args[scheme] is not None:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
422 schemetype = classification_schemetypes[scheme]
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
423 tbl = "%sclass_data" % schemetype
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
424 cq = Query()
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
425 cq.select("scheme.pr as id")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
426 cq.addtable("%s as scheme" % schemetype)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
427 cq.constrain("scheme.scheme = '%s'" % scheme)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
428 regexp_constraint(cq, "scheme.value", args[scheme])
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
429 queries.append(cq)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
430 # end loop
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
431
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
432 querytexts = [q.textify() for q in queries]
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
433 return "INTERSECT\n".join(querytexts)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
434 # end getargs
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
435
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
436 ############################################################
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
437 # main
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
438
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
439 def main():
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
440 opendb()
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
441 (classification_schemes, classification_schemetypes) = getclassify()
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
442 query = getargs(classification_schemes, classification_schemetypes)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
443 ids = querydb(query)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
444 if len(ids) > 0:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
445 show_prs(ids)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
446 else:
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
447 sys.stderr.write("No PRs matched.\n")
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
448 exit(1)
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
449 closedb()
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
450 return 0
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
451 # end main
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
452
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
453 # real python hackers doubtless laugh at this
298c8a7f5181 begin hacking
David A. Holland
parents: 7
diff changeset
454 exit(main())