Commit b79e972b authored by Jason R. Coombs's avatar Jason R. Coombs

Refactor for flatter code

parent 3822e3e7
......@@ -928,20 +928,30 @@ class PyPirc(object):
"""
self.dict_ = {}
if 'HOME' in os.environ:
rc = os.path.join(os.environ['HOME'], '.pypirc')
if os.path.exists(rc):
config = ConfigParser.ConfigParser({
'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(),
config.get(section, 'password').strip())
self.dict_[config.get(section, 'repository').strip()] = value
if 'HOME' not in os.environ:
return
rc = os.path.join(os.environ['HOME'], '.pypirc')
if not os.path.exists(rc):
return
initial = dict.fromkeys(['username', 'password', 'repository'], '')
config = ConfigParser.ConfigParser(initial)
config.read(rc)
sections_with_repositories = [
section for section in config.sections()
if config.get(section, 'repository').strip()
]
for section in sections_with_repositories:
auth = (
config.get(section, 'username').strip(),
config.get(section, 'password').strip(),
)
value = '%s:%s' % auth
repo = config.get(section, 'repository').strip()
self.dict_[repo] = value
def __call__(self, url):
""" """
......
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