Commit 23c06a51 authored by AUTOMATIC1111's avatar AUTOMATIC1111

use 'scripts.' prefix for names of dynamically loaded modules

parent badb70da
...@@ -4,16 +4,20 @@ import importlib.util ...@@ -4,16 +4,20 @@ import importlib.util
from modules import errors from modules import errors
import sys import sys
loaded_scripts = {}
def load_module(path): def load_module(path):
module_spec = importlib.util.spec_from_file_location(os.path.basename(path), path) module_spec = importlib.util.spec_from_file_location(os.path.basename(path), path)
module = importlib.util.module_from_spec(module_spec) module = importlib.util.module_from_spec(module_spec)
module_spec.loader.exec_module(module) module_spec.loader.exec_module(module)
if os.path.isfile(path):
sp = os.path.splitext(path) loaded_scripts[path] = module
module_name = sp[0]
else: module_name, _ = os.path.splitext(os.path.basename(path))
module_name = os.path.basename(path) sys.modules["scripts." + module_name] = module
sys.modules[module_name] = module
return module return module
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment