Skip to content

Commit bdef346

Browse files
committed
Address pkg_resources deprecation
1 parent f2c676d commit bdef346

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

gearbox/commandmanager.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
This comes from OpenStack cliff.
55
"""
66

7-
import inspect
87
import logging
9-
10-
import pkg_resources
8+
from importlib.metadata import entry_points
119

1210
LOG = logging.getLogger(__name__)
1311

@@ -45,7 +43,7 @@ def _load_commands(self):
4543

4644
def load_commands(self, namespace):
4745
"""Load all the commands from an entrypoint"""
48-
for ep in pkg_resources.iter_entry_points(namespace):
46+
for ep in entry_points().select(group=namespace):
4947
LOG.debug("found command %r", ep.name)
5048
cmd_name = (
5149
ep.name.replace("_", " ") if self.convert_underscores else ep.name
@@ -73,16 +71,7 @@ def find_command(self, argv):
7371
name = "%s %s" % (name, next_val) if name else next_val
7472
if name in self.commands:
7573
cmd_ep = self.commands[name]
76-
if hasattr(cmd_ep, "resolve"):
77-
cmd_factory = cmd_ep.resolve()
78-
else:
79-
# NOTE(dhellmann): Some fake classes don't take
80-
# require as an argument. Yay?
81-
arg_spec = inspect.getargspec(cmd_ep.load)
82-
if "require" in arg_spec[0]:
83-
cmd_factory = cmd_ep.load(require=False)
84-
else:
85-
cmd_factory = cmd_ep.load()
74+
cmd_factory = cmd_ep.load()
8675
return (cmd_factory, name, search_args)
8776
else:
8877
raise ValueError("Unknown command %r" % next(iter(argv), ""))

0 commit comments

Comments
 (0)