From 8806d73c0b03b3304dc0edd83582c085d0b71299 Mon Sep 17 00:00:00 2001 From: jeffrey k eliasen Date: Tue, 15 May 2018 14:13:04 -0400 Subject: implementation --- pkg_resources/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'pkg_resources/__init__.py') diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index d5b0fe98..09c3546a 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -2667,6 +2667,15 @@ class Distribution(object): raise AttributeError(attr) return getattr(self._provider, attr) + def __dir__(self): + return list( + set(super(Distribution, self).__dir__()) + | set( + attr for attr in self._provider.__dir__() + if not attr.startswith('_') + ) + ) + @classmethod def from_filename(cls, filename, metadata=None, **kw): return cls.from_location( -- cgit v1.2.3 From 58ad1e140703a9214b63e120113a17d48142dc8a Mon Sep 17 00:00:00 2001 From: jeffrey k eliasen Date: Tue, 15 May 2018 15:06:47 -0400 Subject: python 2.7 does not implement object.__dir__() --- pkg_resources/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'pkg_resources/__init__.py') diff --git a/pkg_resources/__init__.py b/pkg_resources/__init__.py index 09c3546a..394930ca 100644 --- a/pkg_resources/__init__.py +++ b/pkg_resources/__init__.py @@ -2676,6 +2676,10 @@ class Distribution(object): ) ) + if not hasattr(object, '__dir__'): + # python 2.7 not supported + del __dir__ + @classmethod def from_filename(cls, filename, metadata=None, **kw): return cls.from_location( -- cgit v1.2.3