-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add way for 3rd party resources to register into the PMR cli. (#…
…199)
- Loading branch information
Showing
3 changed files
with
31 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import importlib | ||
import sys | ||
from typing import Iterable | ||
|
||
if sys.version_info < (3, 8): | ||
import importlib_metadata | ||
else: | ||
import importlib.metadata as importlib_metadata | ||
|
||
|
||
def find_entrypoints() -> Iterable[str]: | ||
modules = set() | ||
for dist in importlib_metadata.distributions(): | ||
for ep in dist.entry_points: | ||
if ep.group.lower() != "pmr": | ||
continue | ||
|
||
modules.add(ep.value) | ||
return sorted(modules) | ||
|
||
|
||
def load_entrypoints(modules: Iterable[str]): | ||
for module in modules: | ||
importlib.import_module(module) |