-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To maximize adoption, support the full range of Python versions that are not end-of-life. So this change adds the final needed of Python 3.9. This does affect some of the code: * Can no longer use match statements * Use typing.Optional instead of <type> | None * Getting third party plugin via metadata distributions is disabled * Modified how extensions are found by group and loaded Signed-off-by: Eric Brown <[email protected]>
- Loading branch information
Showing
69 changed files
with
478 additions
and
366 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,27 @@ | ||
# Copyright 2024 Secure Sauce LLC | ||
import sys | ||
from importlib.metadata import entry_points | ||
|
||
|
||
def load_extension(group: str, name: str = ""): | ||
if not name: | ||
extensions = {} | ||
|
||
for entry_point in entry_points(group=group): | ||
if sys.version_info >= (3, 10): | ||
eps = entry_points(group=group) | ||
else: | ||
eps = entry_points()[group] | ||
for entry_point in eps: | ||
extension = entry_point.load()() | ||
extensions[entry_point.name] = extension | ||
|
||
return extensions | ||
else: | ||
(entry_point,) = entry_points(group=group, name=name) | ||
return entry_point.load() | ||
if sys.version_info >= (3, 10): | ||
(entry_point,) = entry_points(group=group, name=name) | ||
return entry_point.load() | ||
else: | ||
eps = entry_points()[group] | ||
for entry_point in eps: | ||
if entry_point.name == name: | ||
return entry_point.load() |
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
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
Oops, something went wrong.