Merge pull request #718 from vishal332008/master

Fixing a bug related to Plugin File Names.
This commit is contained in:
Eric Froemling 2024-07-25 12:27:36 -07:00 committed by GitHub
commit ff819aff9d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 3 deletions

View File

@ -3,6 +3,7 @@
"""Utility snippets applying to generic Python code."""
from __future__ import annotations
import sys
import types
import weakref
import random
@ -66,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**
@ -79,6 +83,8 @@ 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 and check_sdlib_modulename_clash:
raise Exception(f'{modulename} is an inbuilt module.')
module = importlib.import_module(modulename)
cls: type = getattr(module, classname)

View File

@ -278,7 +278,7 @@ class PluginSpec:
if not self.loadable:
return None
try:
cls = getclass(self.class_path, Plugin)
cls = getclass(self.class_path, Plugin, True)
except Exception as exc:
_babase.getsimplesound('error').play()
_babase.screenmessage(

View File

@ -400,7 +400,7 @@ class PlaylistCustomizeBrowserWindow(bui.Window):
txtw = bui.textwidget(
parent=self._columnwidget,
size=(self._width - 40, 30),
maxwidth=self._width - 110,
maxwidth=440,
text=self._get_playlist_display_name(pname),
h_align='left',
v_align='center',

View File

@ -122,6 +122,7 @@ class PlaylistEditWindow(bui.Window):
h_align='left',
v_align='center',
max_chars=40,
maxwidth=380,
autoselect=True,
color=(0.9, 0.9, 0.9, 1.0),
description=bui.Lstr(resource=f'{self._r}.listNameText'),