Misc tidying

This commit is contained in:
Keith Edmunds 2024-12-22 15:23:22 +00:00
parent b389a348c1
commit a1709e92ae
2 changed files with 4 additions and 21 deletions

View File

@ -404,22 +404,6 @@ def show_warning(parent: Optional[QMainWindow], title: str, msg: str) -> None:
QMessageBox.warning(parent, title, msg, buttons=QMessageBox.StandardButton.Cancel)
def singleton(cls):
"""
Make a class a Singleton class (see
https://realpython.com/primer-on-python-decorators/#creating-singletons)
"""
@functools.wraps(cls)
def wrapper_singleton(*args, **kwargs):
if not wrapper_singleton.instance:
wrapper_singleton.instance = cls(*args, **kwargs)
return wrapper_singleton.instance
wrapper_singleton.instance = None
return wrapper_singleton
def trailing_silence(
audio_segment: AudioSegment,
silence_threshold: int = -50,

View File

@ -72,7 +72,9 @@ class NoteColours(dbtables.NoteColoursTable):
return result
@staticmethod
def get_colour(session: Session, text: str, foreground: bool = False) -> Optional[str]:
def get_colour(
session: Session, text: str, foreground: bool = False
) -> Optional[str]:
"""
Parse text and return background (foreground if foreground==True) colour
string if matched, else None
@ -245,10 +247,7 @@ class Playlists(dbtables.PlaylistsTable):
return session.scalars(
select(cls)
.where(
cls.is_template.is_(True),
cls.deleted.is_not(True)
)
.where(cls.is_template.is_(True), cls.deleted.is_not(True))
.order_by(cls.name)
).all()