Skip to content

Commit 31a91c2

Browse files
committed
bugzilla: Move version differences into the main class
They are minor at this point, so let's just handle them inline
1 parent 1b1e11e commit 31a91c2

4 files changed

Lines changed: 21 additions & 36 deletions

File tree

bugzilla/base.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,11 @@ def logged_in(self):
580580
#############################################
581581

582582
def _getbugfields(self):
583-
raise RuntimeError("This bugzilla version does not support listing "
584-
"bug fields.")
583+
'''
584+
Get the list of valid fields for Bug objects
585+
'''
586+
r = self._proxy.Bug.fields({'include_fields': ['name']})
587+
return [f['name'] for f in r['fields']]
585588

586589
def getbugfields(self, force_refresh=False):
587590
'''
@@ -993,7 +996,8 @@ def build_query(self,
993996
savedsearch=None,
994997
savedsearch_sharer_id=None,
995998
sub_component=None,
996-
tags=None):
999+
tags=None,
1000+
exclude_fields=None):
9971001
"""
9981002
Build a query string from passed arguments. Will handle
9991003
query parameter differences between various bugzilla versions.
@@ -1007,9 +1011,10 @@ def build_query(self,
10071011
10081012
Then pass the output to Bugzilla.query()
10091013
"""
1014+
# These parameters are only used by RHBugzilla, which overwrites
1015+
# this implementation. So ignore them here
10101016
ignore = emailtype
10111017
ignore = booleantype
1012-
ignore = include_fields
10131018

10141019
for key, val in [
10151020
('fixed_in', fixed_in),
@@ -1054,6 +1059,18 @@ def build_query(self,
10541059
"tag": self._listify(tags),
10551060
}
10561061

1062+
# 'include_fields' only available for Bugzilla4+
1063+
if self._check_version(4, 0):
1064+
include_fields = self._convert_include_field_list(include_fields)
1065+
if include_fields:
1066+
if 'id' not in include_fields:
1067+
include_fields.append('id')
1068+
query["include_fields"] = include_fields
1069+
1070+
exclude_fields = self._convert_include_field_list(exclude_fields)
1071+
if exclude_fields:
1072+
query["exclude_fields"] = exclude_fields
1073+
10571074
# Strip out None elements in the dict
10581075
for k, v in query.copy().items():
10591076
if v is None:

bugzilla/bugzilla3.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,3 @@ class Bugzilla34(Bugzilla32):
2727

2828
class Bugzilla36(Bugzilla34):
2929
bz_ver_minor = 6
30-
31-
def _getbugfields(self):
32-
'''Get the list of valid fields for Bug objects'''
33-
r = self._proxy.Bug.fields({'include_fields': ['name']})
34-
return [f['name'] for f in r['fields']]

bugzilla/bugzilla4.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,6 @@ class Bugzilla4(Bugzilla36):
1616
bz_ver_minor = 0
1717

1818

19-
#################
20-
# Query Methods #
21-
#################
22-
23-
def build_query(self, **kwargs):
24-
query = Bugzilla36.build_query(self, **kwargs)
25-
26-
# 'include_fields' only available for Bugzilla4+
27-
include_fields = self._convert_include_field_list(
28-
kwargs.pop('include_fields', None))
29-
if include_fields:
30-
if 'id' not in include_fields:
31-
include_fields.append('id')
32-
query["include_fields"] = include_fields
33-
34-
exclude_fields = self._convert_include_field_list(
35-
kwargs.pop('exclude_fields', None))
36-
if exclude_fields:
37-
query["exclude_fields"] = exclude_fields
38-
39-
return query
40-
41-
4219
class Bugzilla42(Bugzilla4):
4320
bz_ver_minor = 2
4421

tests/misc.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,3 @@ def testRHBZInit(self):
200200
bugzilla.RHBugzilla(None, cookiefile=None, multicall=True,
201201
rhbz_back_compat=True)
202202
bugzilla.log.setLevel(level)
203-
204-
def testUnimplementedAPI(self):
205-
bz3 = bugzilla.Bugzilla3(None, cookiefile=None, tokenfile=None)
206-
self.assertRaises(RuntimeError, bz3.getbugfields)

0 commit comments

Comments
 (0)