Commit 3822e3e7 authored by Jason R. Coombs's avatar Jason R. Coombs

Delint syntax

--HG--
extra : amend_source : 0f58aa917ebc71efd2904638fac3838fd0b0e4dd
parent 2e0ef2a8
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment