Commit 117a8a57 authored by Jason R. Coombs's avatar Jason R. Coombs

Construct the 'creds' dictionary directly rather than building imperatively.

parent 113f5557
...@@ -949,20 +949,19 @@ class PyPirc(ConfigParser.ConfigParser): ...@@ -949,20 +949,19 @@ class PyPirc(ConfigParser.ConfigParser):
@property @property
def creds_by_repository(self): def creds_by_repository(self):
creds = {}
sections_with_repositories = [ sections_with_repositories = [
section for section in self.sections() section for section in self.sections()
if self.get(section, 'repository').strip() if self.get(section, 'repository').strip()
] ]
for section in sections_with_repositories: return dict(map(self._get_repo_cred, sections_with_repositories))
cred = Credential(
self.get(section, 'username').strip(), def _get_repo_cred(self, section):
self.get(section, 'password').strip(), repo = self.get(section, 'repository').strip()
) return repo, Credential(
repo = self.get(section, 'repository').strip() self.get(section, 'username').strip(),
creds[repo] = cred self.get(section, 'password').strip(),
return creds )
def find_credential(self, url): def find_credential(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