Skip to content

Commit c3e2f7e

Browse files
committed
bugzilla: Simplify magic bugzilla class
1 parent 9b7f609 commit c3e2f7e

2 files changed

Lines changed: 14 additions & 17 deletions

File tree

bugzilla/__init__.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class NovellBugzilla(Bugzilla34):
3737
pass
3838

3939

40-
def getBugzillaClassForURL(url, sslverify):
40+
def _getBugzillaClassForURL(url, sslverify):
4141
url = Bugzilla3.fix_url(url)
4242
log.debug("Detecting subclass for %s", url)
4343
s = ServerProxy(url, _RequestsTransport(url, sslverify=sslverify))
@@ -99,29 +99,18 @@ def getBugzillaClassForURL(url, sslverify):
9999
class Bugzilla(_BugzillaBase):
100100
'''
101101
Magical Bugzilla class that figures out which Bugzilla implementation
102-
to use and uses that. Requires 'url' parameter so we can check available
103-
XMLRPC methods to determine the Bugzilla version.
102+
to use and uses that.
104103
'''
105-
# pylint: disable=W0231
106-
# __init__ method of base class not called
107-
108-
def __init__(self, **kwargs):
109-
log.info("Bugzilla v%s initializing", __version__)
110-
if 'url' not in kwargs:
104+
def _init_class_from_url(self, url, sslverify):
105+
if url is None:
111106
raise TypeError("You must pass a valid bugzilla URL")
112107

113-
# pylint: disable=W0233
114-
# Use of __init__ of non parent class
115-
# We base of _BugzillaBase to help pylint figure things out
116-
117-
c = getBugzillaClassForURL(kwargs['url'],
118-
kwargs.get('sslverify', True))
108+
c = _getBugzillaClassForURL(url, sslverify)
119109
if not c:
120110
raise ValueError("Couldn't determine Bugzilla version for %s" %
121-
kwargs['url'])
111+
url)
122112

123113
self.__class__ = c
124-
c.__init__(self, **kwargs)
125114
log.info("Chose subclass %s v%s", c.__name__, c.version)
126115

127116

bugzilla/base.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,10 @@ def fix_url(url):
308308

309309
def __init__(self, url=None, user=None, password=None, cookiefile=-1,
310310
sslverify=True):
311+
# Hook to allow Bugzilla autodetection without weirdly overriding
312+
# __init__
313+
self._init_class_from_url(url, sslverify)
314+
311315
# Settings the user might want to tweak
312316
self.user = user or ''
313317
self.password = password or ''
@@ -357,6 +361,10 @@ def __init__(self, url=None, user=None, password=None, cookiefile=-1,
357361
if url:
358362
self.connect(url)
359363

364+
def _init_class_from_url(self, url, sslverify):
365+
ignore = url
366+
ignore = sslverify
367+
360368
def _init_private_data(self):
361369
'''initialize private variables used by this bugzilla instance.'''
362370
self._proxy = None

0 commit comments

Comments
 (0)