aboutsummaryrefslogtreecommitdiffstats
path: root/pkg_resources/__init__.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2014-12-31 11:59:17 -0500
committerJason R. Coombs <jaraco@jaraco.com>2014-12-31 11:59:17 -0500
commitd1ed7aca039caf079a97d3f47347439db6fd469d (patch)
treef72da1417a56e4ad93df4277b4b97a534e8bf22d /pkg_resources/__init__.py
parent5eb17624d427730b21ec5de800e4aae036014d01 (diff)
downloadexternal_python_setuptools-d1ed7aca039caf079a97d3f47347439db6fd469d.tar.gz
external_python_setuptools-d1ed7aca039caf079a97d3f47347439db6fd469d.tar.bz2
external_python_setuptools-d1ed7aca039caf079a97d3f47347439db6fd469d.zip
Use reduce to retrieve attributes. Reuse error from AttributeError when translating to ImportError.
Diffstat (limited to 'pkg_resources/__init__.py')
-rw-r--r--pkg_resources/__init__.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py
index dc69b725..f3f7bcc9 100644
--- a/pkg_resources/__init__.py
+++ b/pkg_resources/__init__.py
@@ -2258,11 +2258,10 @@ class EntryPoint(object):
self.require(env, installer)
entry = __import__(self.module_name, globals(), globals(),
['__name__'])
- for attr in self.attrs:
- try:
- entry = getattr(entry, attr)
- except AttributeError:
- raise ImportError("%r has no %r attribute" % (entry, attr))
+ try:
+ entry = functools.reduce(getattr, self.attrs, entry)
+ except AttributeError as exc:
+ raise ImportError(str(exc))
return entry
def require(self, env=None, installer=None):