Skip to content

Commit

Permalink
Validate plugins in lookup functions
Browse files Browse the repository at this point in the history
  • Loading branch information
rnixx committed Dec 12, 2024
1 parent 31737a9 commit a82da93
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/edutap/wallet_google/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@

def get_image_providers() -> Iterable[ImageProvider]:
eps = entry_points(group="edutap.wallet_google.plugins")
return [ep.load() for ep in eps if ep.name == "ImageProvider"]
plugins = [ep.load() for ep in eps if ep.name == "ImageProvider"]
for plugin in plugins:
if not isinstance(plugin, ImageProvider):
raise ValueError(f"{plugin} not implements ImageProvider")
return [plugin() for plugin in plugins]


def get_callback_handlers() -> Iterable[CallbackHandler]:
eps = entry_points(group="edutap.wallet_google.plugins")
return [ep.load() for ep in eps if ep.name == "CallbackHandler"]
plugins = [ep.load() for ep in eps if ep.name == "CallbackHandler"]
for plugin in plugins:
if not isinstance(plugin, CallbackHandler):
raise ValueError(f"{plugin} not implements CallbackHandler")
return [plugin() for plugin in plugins]

0 comments on commit a82da93

Please sign in to comment.