|
1 | 1 | # python-bugzilla - a Python interface to bugzilla using xmlrpclib. |
2 | 2 | # |
3 | | -# Copyright (C) 2007,2008 Red Hat Inc. |
| 3 | +# Copyright (C) 2007, 2008 Red Hat Inc. |
4 | 4 | # Author: Will Woods <[email protected]> |
5 | 5 | # |
6 | 6 | # This program is free software; you can redistribute it and/or modify it |
|
9 | 9 | # option) any later version. See http://www.gnu.org/copyleft/gpl.html for |
10 | 10 | # the full text of the license. |
11 | 11 |
|
12 | | -from bugzilla3 import Bugzilla3, Bugzilla32, Bugzilla34, Bugzilla36 |
13 | | -from bugzilla4 import Bugzilla4 |
14 | | -from rhbugzilla import RHBugzilla, RHBugzilla3, RHBugzilla4 |
15 | | -from nvlbugzilla import NovellBugzilla |
16 | | -from base import version |
17 | | -import xmlrpclib |
18 | 12 | import logging |
| 13 | +import xmlrpclib |
| 14 | + |
| 15 | +from bugzilla.base import version |
| 16 | +from bugzilla.bugzilla3 import Bugzilla3, Bugzilla32, Bugzilla34, Bugzilla36 |
| 17 | +from bugzilla.bugzilla4 import Bugzilla4 |
| 18 | +from bugzilla.nvlbugzilla import NovellBugzilla |
| 19 | +from bugzilla.rhbugzilla import RHBugzilla, RHBugzilla3, RHBugzilla4 |
| 20 | + |
19 | 21 | log = logging.getLogger("bugzilla") |
20 | 22 |
|
21 | 23 | # advertised class list |
22 | | -classlist = ['Bugzilla3', 'Bugzilla32', 'Bugzilla34', 'Bugzilla36', 'Bugzilla4', |
23 | | - 'RHBugzilla3', 'RHBugzilla4', 'NovellBugzilla'] |
| 24 | +classlist = ['Bugzilla3', 'Bugzilla32', 'Bugzilla34', |
| 25 | + 'Bugzilla36', 'Bugzilla4', 'RHBugzilla3', 'RHBugzilla4', |
| 26 | + 'NovellBugzilla'] |
| 27 | + |
24 | 28 |
|
25 | 29 | def getBugzillaClassForURL(url): |
26 | 30 | log.debug("Choosing subclass for %s" % url) |
@@ -66,19 +70,24 @@ def getBugzillaClassForURL(url): |
66 | 70 |
|
67 | 71 | return c |
68 | 72 |
|
| 73 | + |
69 | 74 | class Bugzilla(object): |
70 | 75 | '''Magical Bugzilla class that figures out which Bugzilla implementation |
71 | 76 | to use and uses that. Requires 'url' parameter so we can check available |
72 | 77 | XMLRPC methods to determine the Bugzilla version.''' |
73 | | - def __init__(self,**kwargs): |
74 | | - log.info("Bugzilla v%s initializing" % base.version) |
75 | | - if 'url' in kwargs: |
76 | | - c = getBugzillaClassForURL(kwargs['url']) |
77 | | - if c: |
78 | | - self.__class__ = c |
79 | | - c.__init__(self,**kwargs) |
80 | | - log.info("Chose subclass %s v%s" % (c.__name__,c.version)) |
81 | | - else: |
82 | | - raise ValueError, "Couldn't determine Bugzilla version for %s" % kwargs['url'] |
| 78 | + def __init__(self, **kwargs): |
| 79 | + log.info("Bugzilla v%s initializing" % version) |
| 80 | + if 'url' not in kwargs: |
| 81 | + raise TypeError("You must pass a valid bugzilla xmlrpc.cgi URL") |
| 82 | + |
| 83 | + # pylint: disable=W0233 |
| 84 | + # Use of __init__ of non parent class |
| 85 | + |
| 86 | + c = getBugzillaClassForURL(kwargs['url']) |
| 87 | + if c: |
| 88 | + self.__class__ = c |
| 89 | + c.__init__(self, **kwargs) |
| 90 | + log.info("Chose subclass %s v%s" % (c.__name__, c.version)) |
83 | 91 | else: |
84 | | - raise TypeError, "You must pass a valid bugzilla xmlrpc.cgi URL" |
| 92 | + raise ValueError("Couldn't determine Bugzilla version for %s" % |
| 93 | + kwargs['url']) |
0 commit comments