diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2015-01-05 14:21:41 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2015-01-05 14:21:41 -0500 |
commit | 92a553d3adeb431cdf92b136ac9ccc3f2ef98bf1 (patch) | |
tree | 5fc6312e181a4dea87a02e700b49c065283c7f9a /pkg_resources/__init__.py | |
parent | 7fa87f2fbdf84d414e069ca96f6c6d860d7e0505 (diff) | |
download | python-setuptools-git-11.3.tar.gz |
Add EntryPoint.resolve and deprecate most usage of EntryPoint.load. Removed EntryPoint._load.11.3
Diffstat (limited to 'pkg_resources/__init__.py')
-rw-r--r-- | pkg_resources/__init__.py | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index b31ae532..fd8efaa8 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -2294,19 +2294,25 @@ class EntryPoint(object): def __repr__(self): return "EntryPoint.parse(%r)" % str(self) - def load(self, require=True, env=None, installer=None): - if require: - self.require(env, installer) - else: + def load(self, require=True, *args, **kwargs): + """ + Require packages for this EntryPoint, then resolve it. + """ + if not require or args or kwargs: warnings.warn( - "`require` parameter is deprecated. Use " - "EntryPoint._load instead.", + "Parameters to load are deprecated. Call .resolve and " + ".require separately.", DeprecationWarning, stacklevel=2, ) - return self._load() + if require: + self.require(*args, **kwargs) + return self.resolve() - def _load(self): + def resolve(self): + """ + Resolve the entry point from its module and attrs. + """ module = __import__(self.module_name, fromlist=['__name__'], level=0) try: return functools.reduce(getattr, self.attrs, module) |