Skip to content

Commit

Permalink
πŸ”Œ re-add plugin support
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshix-1 committed May 26, 2024
1 parent 04ddf88 commit a92b43b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions an_website/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from configparser import ConfigParser
from functools import partial
from hashlib import sha256
from importlib.metadata import EntryPoints, entry_points
from multiprocessing.process import _children # type: ignore[attr-defined]
from socket import socket
from typing import Any, Final, TypedDict, TypeGuard, cast
Expand Down Expand Up @@ -147,6 +148,23 @@ def get_module_infos() -> str | tuple[ModuleInfo, ...]:
module_infos.extend(_module_infos)
loaded_modules.append(module_name)

plugin_entry_points: EntryPoints = entry_points(group='an_website-modules', name="get_module_infos")
for entry_point in plugin_entry_points:
if entry_point.module in IGNORED_MODULES:
continue
try:
module_infos.extend(entry_point.load()())
except Exception as exc:
raise ValueError(f"Failed to load entry point {entry_point}, add {entry_point.module!r} to IGNORED_MODULES") from exc
else:
loaded_modules.append(entry_point.module)
LOGGER.info(
(
"Found module_infos in external module %r"
),
entry_point.module,
)

if len(errors) > 0:
if sys.flags.dev_mode:
# exit to make sure it gets fixed
Expand Down

0 comments on commit a92b43b

Please sign in to comment.