Skip to content

Commit

Permalink
Create utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
vasusen-code authored Dec 9, 2021
1 parent 1d4de2d commit c6ed305
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions main/utils.py
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)

0 comments on commit c6ed305

Please sign in to comment.