-
Notifications
You must be signed in to change notification settings - Fork 885
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d4de2d
commit c6ed305
Showing
1 changed file
with
14 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import sys | ||
import logging | ||
import importlib | ||
from pathlib import Path | ||
|
||
def load_plugins(plugin_name): | ||
path = Path(f"main/plugins/{plugin_name}.py") | ||
name = "main.plugins.{}".format(plugin_name) | ||
spec = importlib.util.spec_from_file_location(name, path) | ||
load = importlib.util.module_from_spec(spec) | ||
load.logger = logging.getLogger(plugin_name) | ||
spec.loader.exec_module(load) | ||
sys.modules["main.plugins." + plugin_name] = load | ||
print("main has Imported " + plugin_name) |