1
2
3
4 import csv
5 import urllib2
6
7 from moap.bug import bug
8
10
11 if URL.find('bugzilla') == -1:
12 return None
13
14 return URL
15
17 """
18 Queries bugzilla using the CSV format.
19 CSV is supported by both Red Hat's and GNOME's bugzilla.
20 """
22
23
24 if URL and 'enter_bug.cgi' in URL:
25 URL = URL[:URL.find('enter_bug.cgi')]
26 bug.BugTracker.__init__(self, URL)
27 self.debug('Initialized with URL %s' % URL)
28
29 - def getBug(self, id, handle=None):
30
31 return self.query('bug_id=%s' % id, handle)[0]
32
33 - def query(self, queryString, handle=None):
34 result = []
35
36 if not handle:
37 url = self.URL + \
38 "/buglist.cgi?query_format=advanced&ctype=csv&%s" % queryString
39 self.debug('Retrieving url %s' % url)
40 handle = urllib2.urlopen(url)
41
42 reader = csv.reader(handle)
43
44 header = reader.next()
45 for row in reader:
46
47 d = {}
48 pairs = map(None, header, row)
49 for key, value in pairs:
50 d[key] = value
51
52
53 b = bug.Bug(d['bug_id'], d['short_short_desc'])
54 result.append(b)
55
56 return result
57
58
60 """
61 I wrap an RDF location from a bugzilla server.
62 """
67
70
72 querystring = """
73 PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
74 PREFIX bz: <http://www.bugzilla.org/rdf#>
75 PREFIX nc: <http://home.netscape.com/NC-rdf#>
76 SELECT ?description
77 WHERE {
78 ?result rdf:type bz:result .
79 ?result bz:short_short_desc ?description
80 }
81 """
82 list = self._querier.query(querystring, query_language='sparql')
83 print list
84 assert len(list) == 1, \
85 "Length of list is %d instead of 1" % len(list)
86
87 for r in list: pass
88
89 BugClass = Bugzilla
90