mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-01-29 18:53:22 +08:00
Adding check to be used only for plugins
This commit is contained in:
parent
a1007b10fb
commit
6002525af1
@ -67,7 +67,10 @@ def existing(obj: ExistableT | None) -> ExistableT | None:
|
||||
return obj if obj is not None and obj.exists() else None
|
||||
|
||||
|
||||
def getclass(name: str, subclassof: type[T]) -> type[T]:
|
||||
def getclass(name: str,
|
||||
subclassof: type[T],
|
||||
check_sdlib_modulename_clash: bool = False
|
||||
) -> type[T]:
|
||||
"""Given a full class name such as foo.bar.MyClass, return the class.
|
||||
|
||||
Category: **General Utility Functions**
|
||||
@ -80,7 +83,7 @@ def getclass(name: str, subclassof: type[T]) -> type[T]:
|
||||
splits = name.split('.')
|
||||
modulename = '.'.join(splits[:-1])
|
||||
classname = splits[-1]
|
||||
if modulename in sys.stdlib_module_names:
|
||||
if modulename in sys.stdlib_module_names and check_sdlib_modulename_clash:
|
||||
raise Exception(f'{modulename} is an inbuilt module.')
|
||||
module = importlib.import_module(modulename)
|
||||
cls: type = getattr(module, classname)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user