From 117a8a57a9a06521f028eb4e1afc1f6fd4dd8dc8 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Thu, 14 Nov 2013 10:28:27 -0500 Subject: Construct the 'creds' dictionary directly rather than building imperatively. --- setuptools/package_index.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'setuptools/package_index.py') diff --git a/setuptools/package_index.py b/setuptools/package_index.py index 482ba38b..0a409604 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -949,20 +949,19 @@ class PyPirc(ConfigParser.ConfigParser): @property def creds_by_repository(self): - creds = {} sections_with_repositories = [ section for section in self.sections() if self.get(section, 'repository').strip() ] - for section in sections_with_repositories: - cred = Credential( - self.get(section, 'username').strip(), - self.get(section, 'password').strip(), - ) - repo = self.get(section, 'repository').strip() - creds[repo] = cred - return creds + return dict(map(self._get_repo_cred, sections_with_repositories)) + + def _get_repo_cred(self, section): + repo = self.get(section, 'repository').strip() + return repo, Credential( + self.get(section, 'username').strip(), + self.get(section, 'password').strip(), + ) def find_credential(self, url): """ -- cgit v1.2.3