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): ...@@ -920,29 +920,29 @@ def _encode_auth(auth):
# strip the trailing carriage return # strip the trailing carriage return
return encoded.rstrip() return encoded.rstrip()
class PyPirc: class PyPirc(object):
def __init__(self): def __init__(self):
""" """
Extract pypirc authentication information from home directory Extract pypirc authentication information from home directory
""" """
self.dict_ = {} self.dict_ = {}
if os.environ.has_key('HOME'): if 'HOME' in os.environ:
rc = os.path.join(os.environ['HOME'], '.pypirc') rc = os.path.join(os.environ['HOME'], '.pypirc')
if os.path.exists(rc): if os.path.exists(rc):
config = ConfigParser.ConfigParser({ config = ConfigParser.ConfigParser({
'username' : '', 'username': '',
'password' : '', 'password': '',
'repository' : ''}) 'repository': ''})
config.read(rc) config.read(rc)
for section in config.sections(): for section in config.sections():
if config.get(section, 'repository').strip(): 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()) config.get(section, 'password').strip())
self.dict_[config.get(section, 'repository').strip()] = value self.dict_[config.get(section, 'repository').strip()] = value
def __call__(self, url): def __call__(self, url):
""" """ """ """
for base_url, auth in self.dict_.items(): for base_url, auth in self.dict_.items():
...@@ -950,7 +950,6 @@ class PyPirc: ...@@ -950,7 +950,6 @@ class PyPirc:
return auth return auth
def open_with_auth(url, opener=urllib2.urlopen): def open_with_auth(url, opener=urllib2.urlopen):
"""Open a urllib2 request, handling HTTP authentication""" """Open a urllib2 request, handling HTTP authentication"""
...@@ -968,7 +967,7 @@ def open_with_auth(url, opener=urllib2.urlopen): ...@@ -968,7 +967,7 @@ def open_with_auth(url, opener=urllib2.urlopen):
if not auth: if not auth:
auth = PyPirc()(url) auth = PyPirc()(url)
log.info('Authentication found for URL: %s'%url) log.info('Authentication found for URL: %s' % url)
if auth: if auth:
auth = "Basic " + _encode_auth(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