Skip to content

Commit bf619b8

Browse files
committed
Compatibility with older python versions
1 parent bdef346 commit bf619b8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

gearbox/commandmanager.py

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

7+
import importlib.metadata
78
import logging
8-
from importlib.metadata import entry_points
99

1010
LOG = logging.getLogger(__name__)
1111

@@ -43,7 +43,12 @@ def _load_commands(self):
4343

4444
def load_commands(self, namespace):
4545
"""Load all the commands from an entrypoint"""
46-
for ep in entry_points().select(group=namespace):
46+
entry_points = importlib.metadata.entry_points()
47+
if hasattr(entry_points, "select"):
48+
entry_points = entry_points.select(group=namespace)
49+
else:
50+
entry_points = entry_points.get(group=namespace, default=[])
51+
for ep in entry_points:
4752
LOG.debug("found command %r", ep.name)
4853
cmd_name = (
4954
ep.name.replace("_", " ") if self.convert_underscores else ep.name

0 commit comments

Comments
 (0)