diff options
Diffstat (limited to 'setuptools/package_index.py')
-rwxr-xr-x | setuptools/package_index.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/setuptools/package_index.py b/setuptools/package_index.py index ca228997..a0bb936d 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -920,29 +920,29 @@ def _encode_auth(auth): # strip the trailing carriage return return encoded.rstrip() -class PyPirc: +class PyPirc(object): def __init__(self): """ - Extract pypirc authentication information from home directory + Extract pypirc authentication information from home directory """ self.dict_ = {} - if os.environ.has_key('HOME'): + if 'HOME' in os.environ: rc = os.path.join(os.environ['HOME'], '.pypirc') if os.path.exists(rc): config = ConfigParser.ConfigParser({ - 'username' : '', - 'password' : '', - 'repository' : ''}) + 'username': '', + 'password': '', + 'repository': ''}) config.read(rc) for section in config.sections(): if config.get(section, 'repository').strip(): - value = '%s:%s'%(config.get(section, 'username').strip(), + value = '%s:%s' % (config.get(section, 'username').strip(), config.get(section, 'password').strip()) self.dict_[config.get(section, 'repository').strip()] = value - + def __call__(self, url): """ """ for base_url, auth in self.dict_.items(): @@ -950,7 +950,6 @@ class PyPirc: return auth - def open_with_auth(url, opener=urllib2.urlopen): """Open a urllib2 request, handling HTTP authentication""" @@ -968,7 +967,7 @@ def open_with_auth(url, opener=urllib2.urlopen): if not auth: auth = PyPirc()(url) - log.info('Authentication found for URL: %s'%url) + log.info('Authentication found for URL: %s' % url) if auth: auth = "Basic " + _encode_auth(auth) |