1818log = logging .getLogger ("bugzilla" )
1919
2020
21+ from bugzilla .base import BugzillaError
2122from bugzilla .bugzilla3 import Bugzilla3 , Bugzilla32 , Bugzilla34 , Bugzilla36
22- from bugzilla .bugzilla4 import Bugzilla4
23+ from bugzilla .bugzilla4 import Bugzilla4 , Bugzilla42 , Bugzilla44
2324from bugzilla .nvlbugzilla import NovellBugzilla
2425from bugzilla .rhbugzilla import RHBugzilla , RHBugzilla3 , RHBugzilla4
2526
26- # advertised class list
27- classlist = ['Bugzilla3' , 'Bugzilla32' , 'Bugzilla34' ,
28- 'Bugzilla36' , 'Bugzilla4' , 'RHBugzilla3' , 'RHBugzilla4' ,
29- 'NovellBugzilla' ]
30-
31-
32-
3327
3428def getBugzillaClassForURL (url ):
3529 log .debug ("Choosing subclass for %s" % url )
@@ -60,10 +54,16 @@ def getBugzillaClassForURL(url):
6054 # note preference order: RHBugzilla* wins if available
6155 if rhbz :
6256 c = RHBugzilla
63- else :
64- if bzversion .startswith ("4." ):
57+ elif bzversion . startswith ( "4." ) :
58+ if bzversion .startswith ("4.0 " ):
6559 c = Bugzilla4
66- elif bzversion .startswith ('3.6' ):
60+ elif bzversion .startswith ("4.2" ):
61+ c = Bugzilla42
62+ else :
63+ log .debug ("No explicit match for %s, using latest bz4" % bzversion )
64+ c = Bugzilla44
65+ else :
66+ if bzversion .startswith ('3.6' ):
6767 c = Bugzilla36
6868 elif bzversion .startswith ('3.4' ):
6969 c = Bugzilla34
@@ -77,9 +77,11 @@ def getBugzillaClassForURL(url):
7777
7878
7979class Bugzilla (object ):
80- '''Magical Bugzilla class that figures out which Bugzilla implementation
80+ '''
81+ Magical Bugzilla class that figures out which Bugzilla implementation
8182 to use and uses that. Requires 'url' parameter so we can check available
82- XMLRPC methods to determine the Bugzilla version.'''
83+ XMLRPC methods to determine the Bugzilla version.
84+ '''
8385 def __init__ (self , ** kwargs ):
8486 log .info ("Bugzilla v%s initializing" % __version__ )
8587 if 'url' not in kwargs :
@@ -89,10 +91,28 @@ def __init__(self, **kwargs):
8991 # Use of __init__ of non parent class
9092
9193 c = getBugzillaClassForURL (kwargs ['url' ])
94+ if not c :
95+ raise ValueError ("Couldn't determine Bugzilla version for %s" %
96+ kwargs ['url' ])
97+
9298 if c :
9399 self .__class__ = c
94100 c .__init__ (self , ** kwargs )
95101 log .info ("Chose subclass %s v%s" % (c .__name__ , c .version ))
96- else :
97- raise ValueError ("Couldn't determine Bugzilla version for %s" %
98- kwargs ['url' ])
102+
103+ # This is the list of possible Bugzilla instances an app can use,
104+ # bin/bugzilla uses it for the --bztype field
105+ classlist = [
106+ "Bugzilla3" , "Bugzilla32" , "Bugzilla34" , "Bugzilla36" ,
107+ "Bugzilla4" , "Bugzilla42" , "Bugzilla44" ,
108+ "RHBugzilla3" , "RHBugzilla4" , "RHBugzilla" ,
109+ "NovellBugzilla" ,
110+ ]
111+
112+ # This is the public API. If you are explicitly instantiating any other
113+ # class, using some function, or poking into internal files, don't complain
114+ # if things break on you.
115+ __all__ = classlist + [
116+ 'BugzillaError' ,
117+ 'Bugzilla' ,
118+ ]
0 commit comments