2626 Bugzilla4 , Bugzilla42 , Bugzilla44 ,
2727 NovellBugzilla , RHBugzilla3 , RHBugzilla4 )
2828
29- log = getLogger (__name__ )
30-
31-
32- def _getBugzillaClassForURL (url , sslverify ):
33- url = BugzillaBase .fix_url (url )
34- log .debug ("Detecting subclass for %s" , url )
35- s = ServerProxy (url , _RequestsTransport (url , sslverify = sslverify ))
36-
37- if "bugzilla.redhat.com" in url :
38- log .info ("Using RHBugzilla for URL containing bugzilla.redhat.com" )
39- return RHBugzilla
40- if "bugzilla.novell.com" in url :
41- log .info ("Using NovellBugzilla for URL containing bugzilla.novell.com" )
42- return NovellBugzilla
43-
44- # Check for a Red Hat extension
45- try :
46- log .debug ("Checking for Red Hat Bugzilla extension" )
47- extensions = s .Bugzilla .extensions ()
48- if extensions .get ('extensions' , {}).get ('RedHat' , False ):
49- log .debug ("Found RedHat bugzilla extension" )
50- return RHBugzilla
51- except Fault :
52- pass
53-
5429
5530class Bugzilla (BugzillaBase ):
5631 '''
@@ -60,31 +35,47 @@ class Bugzilla(BugzillaBase):
6035 def _init_class_from_url (self , url , sslverify ):
6136 if url is None :
6237 raise TypeError ("You must pass a valid bugzilla URL" )
38+ url = RHBugzilla .fix_url (url )
39+ log .debug ("Detecting subclass for %s" , url )
40+
41+ if "bugzilla.redhat.com" in url :
42+ log .info ("Using RHBugzilla for URL containing bugzilla.redhat.com" )
43+ c = RHBugzilla
44+ else :
45+ # Check for a Red Hat extension
46+ s = ServerProxy (url , _RequestsTransport (url , sslverify = sslverify ))
47+ try :
48+ extensions = s .Bugzilla .extensions ()
49+ if extensions .get ('extensions' , {}).get ('RedHat' , False ):
50+ log .debug ("Found RedHat bugzilla extension" )
51+ c = RHBugzilla
52+ except Fault :
53+ pass
6354
64- c = _getBugzillaClassForURL (url , sslverify )
6555 if not c :
66- return False
56+ return
6757
6858 self .__class__ = c
69- log .info ("Chose subclass %s v%s" , c .__name__ , c .version )
59+ log .info ("Found subclass %s v%s" , c .__name__ , c .version )
7060 return True
7161
7262
73- del (BugzillaBase )
74-
75- # This is the list of possible Bugzilla instances an app can use,
76- # bin/bugzilla used to use it for the --bztype field
77- classlist = [
78- "Bugzilla3" , "Bugzilla32" , "Bugzilla34" , "Bugzilla36" ,
79- "Bugzilla4" , "Bugzilla42" , "Bugzilla44" ,
80- "RHBugzilla3" , "RHBugzilla4" , "RHBugzilla" ,
81- "NovellBugzilla" ,
82- ]
83-
8463# This is the public API. If you are explicitly instantiating any other
8564# class, using some function, or poking into internal files, don't complain
8665# if things break on you.
87- __all__ = classlist + [
66+ __all__ = [
67+ "Bugzilla3" , "Bugzilla32" , "Bugzilla34" , "Bugzilla36" ,
68+ "Bugzilla4" , "Bugzilla42" , "Bugzilla44" ,
69+ "NovellBugzilla" ,
70+ "RHBugzilla3" , "RHBugzilla4" , "RHBugzilla" ,
8871 'BugzillaError' ,
89- 'Bugzilla' ,
72+ 'Bugzilla' , "version" ,
9073]
74+
75+
76+ # Clear all other locals() from the public API
77+ for __sym in locals ().copy ():
78+ if __sym .startswith ("__" ) or __sym in __all__ :
79+ continue
80+ locals ().pop (__sym )
81+ locals ().pop ("__sym" )
0 commit comments