diff options
author | Will Woods <wwoods@redhat.com> | 2008-06-06 17:01:54 -0400 |
---|---|---|
committer | Will Woods <wwoods@redhat.com> | 2008-06-06 17:01:54 -0400 |
commit | 951c16ed6f67be44bfe507d48cd36de49942b9f7 (patch) | |
tree | 0365928d228e7b747c047588208b97dc1ae83ae9 | |
parent | 1805ac8a6645c3d9ee191e597320d7792f6b91f8 (diff) | |
download | python-bugzilla-951c16ed6f67be44bfe507d48cd36de49942b9f7.tar.gz python-bugzilla-951c16ed6f67be44bfe507d48cd36de49942b9f7.tar.xz python-bugzilla-951c16ed6f67be44bfe507d48cd36de49942b9f7.zip |
Begin adding .bugzillarc support
-rw-r--r-- | bugzilla/base.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/bugzilla/base.py b/bugzilla/base.py index f00bc86..e97cd40 100644 --- a/bugzilla/base.py +++ b/bugzilla/base.py @@ -1,4 +1,4 @@ -# bugzilla.py - a Python interface to bugzilla.redhat.com, using xmlrpclib. +# base.py - the base classes etc. for a Python interface to bugzilla # # Copyright (C) 2007,2008 Red Hat Inc. # Author: Will Woods <wwoods@redhat.com> @@ -81,6 +81,20 @@ class BugzillaBase(object): #---- Methods for establishing bugzilla connection and logging in + configpath = ['/etc/bugzillarc','~/.bugzillarc'] + def readconfig(self,configpath=None): + '''Read bugzillarc file(s) into memory.''' + configpath = [os.path.expanduser(p) for p in configpath] + import ConfigParser + c = ConfigParser.SafeConfigParser() + if not configpath: + configpath = self.configpath + r = c.read(configpath) + if not r: + return + # FIXME save parsed config in a more lightweight form? + self.conf = c + def connect(self,url): '''Connect to the bugzilla instance with the given url.''' # Set up the transport @@ -97,6 +111,8 @@ class BugzillaBase(object): self._opener = urllib2.build_opener(handler) self._opener.addheaders = [('User-agent',self.user_agent)] self.url = url + # TODO if we have a matching config section for this url, load those + # values now # Note that the bugzilla methods will ignore an empty user/password if you # send authentication info as a cookie in the request headers. So it's |