diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2013-11-14 10:20:22 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2013-11-14 10:20:22 -0500 |
commit | b7ee88761b75f2c63eb5553f7b28e5e8a88be186 (patch) | |
tree | 4c00ca554db7d0bb67f7245dbf137bcfadce002a /setuptools/package_index.py | |
parent | bf742c3f6069802d26c09118dd6c36d55634e22d (diff) | |
download | external_python_setuptools-b7ee88761b75f2c63eb5553f7b28e5e8a88be186.tar.gz external_python_setuptools-b7ee88761b75f2c63eb5553f7b28e5e8a88be186.tar.bz2 external_python_setuptools-b7ee88761b75f2c63eb5553f7b28e5e8a88be186.zip |
Replaced __call__ with find_credential (for clarity of purpose). Removed dict_.
Diffstat (limited to 'setuptools/package_index.py')
-rwxr-xr-x | setuptools/package_index.py | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/setuptools/package_index.py b/setuptools/package_index.py index 5b8dc357..c63ae29a 100755 --- a/setuptools/package_index.py +++ b/setuptools/package_index.py @@ -949,8 +949,8 @@ class PyPirc(ConfigParser.ConfigParser): self.read(rc) @property - def dict_(self): - dict_ = {} + def creds_by_repository(self): + creds = {} sections_with_repositories = [ section for section in self.sections() if self.get(section, 'repository').strip() @@ -962,14 +962,17 @@ class PyPirc(ConfigParser.ConfigParser): self.get(section, 'password').strip(), ) repo = self.get(section, 'repository').strip() - dict_[repo] = cred - return dict_ + creds[repo] = cred + return creds - def __call__(self, url): - """ """ - for base_url, auth in self.dict_.items(): - if url.startswith(base_url): - return auth + def find_credential(self, url): + """ + If the URL indicated appears to be a repository defined in this + config, return the credential for that repository. + """ + for repository, cred in self.creds_by_repository.items(): + if url.startswith(repository): + return cred def open_with_auth(url, opener=urllib2.urlopen): @@ -988,8 +991,10 @@ def open_with_auth(url, opener=urllib2.urlopen): auth = None if not auth: - auth = str(PyPirc()(url)) - log.info('Authentication found for URL: %s' % url) + cred = PyPirc().find_credential(url) + if cred: + auth = str(cred) + log.info('Authentication found for URL: %s' % url) if auth: auth = "Basic " + _encode_auth(auth) |