mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-02-07 16:13:23 +08:00
Fixing a bug related to plugin file names.
Fixed a bug where plugins don't run due to them being named same as inbuilt module from standard library of python.
This commit is contained in:
parent
aceb9a1a66
commit
c3754bd0c6
@ -3,6 +3,7 @@
|
|||||||
"""Utility snippets applying to generic Python code."""
|
"""Utility snippets applying to generic Python code."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import sys
|
||||||
import types
|
import types
|
||||||
import weakref
|
import weakref
|
||||||
import random
|
import random
|
||||||
@ -79,6 +80,8 @@ def getclass(name: str, subclassof: type[T]) -> type[T]:
|
|||||||
splits = name.split('.')
|
splits = name.split('.')
|
||||||
modulename = '.'.join(splits[:-1])
|
modulename = '.'.join(splits[:-1])
|
||||||
classname = splits[-1]
|
classname = splits[-1]
|
||||||
|
if modulename in sys.stdlib_module_names:
|
||||||
|
raise Exception(f'{modulename} is an inbuilt module.')
|
||||||
module = importlib.import_module(modulename)
|
module = importlib.import_module(modulename)
|
||||||
cls: type = getattr(module, classname)
|
cls: type = getattr(module, classname)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user