Command out @log_call decorators

This commit is contained in:
Keith Edmunds 2025-04-12 19:24:25 +01:00
parent 728d012257
commit 0c717241ff
4 changed files with 68 additions and 68 deletions

View File

@ -50,7 +50,7 @@ cache_region = make_region().configure(
# Helper functions
@log_call
# @log_call
def _remove_substring_case_insensitive(parent_string: str, substring: str) -> str:
"""
Remove all instances of substring from parent string, case insensitively
@ -166,7 +166,7 @@ def get_colour(text: str, foreground: bool = False) -> str:
return rec.colour
@log_call
# @log_call
def remove_colour_substring(text: str) -> str:
"""
Remove text that identifies the colour to be used if strip_substring is True
@ -178,7 +178,7 @@ def remove_colour_substring(text: str) -> str:
# Track functions
@log_call
# @log_call
def _tracks_where(query: BinaryExpression | ColumnElement[bool],) -> list[TrackDTO]:
"""
filter_by_last_played: bool = False,
@ -378,7 +378,7 @@ def get_filtered_tracks(filter: Filter) -> list[TrackDTO]:
return results
@log_call
# @log_call
def add_track_to_header(playlistrow_id: int, track_id: int) -> None:
"""
Add a track to this (header) row
@ -393,7 +393,7 @@ def add_track_to_header(playlistrow_id: int, track_id: int) -> None:
session.commit()
@log_call
# @log_call
def create_track(path: str, metadata: dict[str, str | int | float]) -> TrackDTO:
"""
Create a track db entry from a track path and return the DTO
@ -425,7 +425,7 @@ def create_track(path: str, metadata: dict[str, str | int | float]) -> TrackDTO:
return new_track
@log_call
# @log_call
def update_track(
path: str, track_id: int, metadata: dict[str, str | int | float]
) -> TrackDTO:
@ -480,7 +480,7 @@ def delete_track(track_id: int) -> None:
# Playlist functions
@log_call
# @log_call
def _playlists_where(
query: BinaryExpression | ColumnElement[bool],
) -> list[PlaylistDTO]:
@ -513,7 +513,7 @@ def _playlists_where(
return results
@log_call
# @log_call
def playlist_by_id(playlist_id: int) -> PlaylistDTO | None:
"""
Return playlist with specified id
@ -638,7 +638,7 @@ def _check_playlist_integrity(
raise ApplicationError(msg)
@log_call
# @log_call
def playlist_mark_status(playlist_id: int, open: bool) -> None:
"""Mark playlist as open or closed"""
@ -652,7 +652,7 @@ def playlist_mark_status(playlist_id: int, open: bool) -> None:
session.commit()
@log_call
# @log_call
def _shift_rows(
session: Session, playlist_id: int, starting_row: int, shift_by: int
) -> None:
@ -671,7 +671,7 @@ def _shift_rows(
)
@log_call
# @log_call
def move_rows(
from_rows: list[int],
from_playlist_id: int,
@ -763,7 +763,7 @@ def move_rows(
_check_playlist_integrity(session, to_playlist_id, fix=False)
@log_call
# @log_call
def update_row_numbers(
playlist_id: int, id_to_row_number: list[dict[int, int]]
) -> None:
@ -780,7 +780,7 @@ def update_row_numbers(
_check_playlist_integrity(session, playlist_id, fix=False)
@log_call
# @log_call
def create_playlist(name: str, template_id: int, as_template: bool = False) -> PlaylistDTO:
"""
Create playlist and return DTO.
@ -840,7 +840,7 @@ def playlist_row_count(playlist_id: int) -> int:
return count
@log_call
# @log_call
def insert_row(
playlist_id: int, row_number: int, track_id: int | None, note: str
) -> PlaylistRowDTO:
@ -880,7 +880,7 @@ def insert_row(
return new_playlist_row
@log_call
# @log_call
def remove_comments(playlist_id: int, row_numbers: list[int]) -> None:
"""
Remove comments from rows in playlist
@ -898,7 +898,7 @@ def remove_comments(playlist_id: int, row_numbers: list[int]) -> None:
session.commit()
@log_call
# @log_call
def remove_rows(playlist_id: int, row_numbers: list[int]) -> None:
"""
Remove rows from playlist
@ -920,7 +920,7 @@ def remove_rows(playlist_id: int, row_numbers: list[int]) -> None:
session.commit()
@log_call
# @log_call
def update_template_favourite(template_id: int, favourite: bool) -> None:
"""Update template favourite"""
@ -933,7 +933,7 @@ def update_template_favourite(template_id: int, favourite: bool) -> None:
session.commit()
@log_call
# @log_call
def playlist_save_tabs(playlist_id_to_tab: dict[int, int]) -> None:
"""
Save the tab numbers of the open playlists.
@ -957,7 +957,7 @@ def playlist_save_tabs(playlist_id_to_tab: dict[int, int]) -> None:
# Playlist Rows
@log_call
# @log_call
def get_playlist_row(playlistrow_id: int) -> PlaylistRowDTO | None:
"""
Return specific row DTO
@ -1028,7 +1028,7 @@ def get_playlist_rows(
# Playdates
@log_call
# @log_call
def get_last_played_dates(track_id: int, limit: int = 5) -> str:
"""
Return the most recent 'limit' dates that this track has been played
@ -1105,7 +1105,7 @@ def playdates_between_dates(
# Queries
@log_call
# @log_call
def _queries_where(
query: BinaryExpression | ColumnElement[bool],
) -> list[QueryDTO]:

View File

@ -482,7 +482,7 @@ class ManageQueries(ItemlistManager):
self.populate_table(query_list)
@log_call
# @log_call
def delete_item(self, query_id: int) -> None:
"""delete query"""
@ -579,7 +579,7 @@ class ManageTemplates(ItemlistManager):
self.populate_table(template_list)
@log_call
# @log_call
def delete_item(self, template_id: int) -> None:
"""delete template"""
@ -1403,7 +1403,7 @@ class Window(QMainWindow):
# # # # # # # # # # Playlist management functions # # # # # # # # # #
@log_call
# @log_call
def _create_playlist(self, name: str, template_id: int) -> Playlists:
"""
Create a playlist in the database, populate it from the template
@ -1412,7 +1412,7 @@ class Window(QMainWindow):
return ds.create_playlist(name, template_id)
@log_call
# @log_call
def _open_playlist(self, playlist: PlaylistDTO, is_template: bool = False) -> int:
"""
With passed playlist:
@ -1441,7 +1441,7 @@ class Window(QMainWindow):
return idx
@log_call
# @log_call
def create_playlist_from_template(self, template_id: int) -> None:
"""
Prompt for new playlist name and create from passed template_id
@ -1461,7 +1461,7 @@ class Window(QMainWindow):
_ = ds.create_playlist(playlist_name, template_id)
@log_call
# @log_call
def delete_playlist(self, checked: bool = False) -> None:
"""
Delete current playlist. checked paramater passed by menu system
@ -1705,7 +1705,7 @@ class Window(QMainWindow):
self.signals.search_songfacts_signal.connect(self.open_songfacts_browser)
self.signals.search_wikipedia_signal.connect(self.open_wikipedia_browser)
@log_call
# @log_call
def current_row_or_end(self) -> int:
"""
If a row or rows are selected, return the row number of the first
@ -1756,7 +1756,7 @@ class Window(QMainWindow):
self.footer_section.btnDrop3db.isChecked()
)
@log_call
# @log_call
def enable_escape(self, enabled: bool) -> None:
"""
Manage signal to enable/disable handling ESC character.
@ -1768,7 +1768,7 @@ class Window(QMainWindow):
if "clear_selection" in self.menu_actions:
self.menu_actions["clear_selection"].setEnabled(enabled)
@log_call
# @log_call
def end_of_track_actions(self) -> None:
"""
@ -1905,7 +1905,7 @@ class Window(QMainWindow):
dlg = TrackInsertDialog(parent=self, playlist_id=self.active_tab().playlist_id)
dlg.exec()
@log_call
# @log_call
def load_last_playlists(self) -> None:
"""Load the playlists that were open when app was last closed"""
@ -1956,7 +1956,7 @@ class Window(QMainWindow):
f"mark_rows_for_moving(): {self.move_source_rows=} {self.move_source_model=}"
)
@log_call
# @log_call
def move_playlist_rows(self, row_numbers: list[int]) -> None:
"""
Move passed playlist rows to another playlist
@ -2033,7 +2033,7 @@ class Window(QMainWindow):
webbrowser.get("browser").open_new_tab(url)
@log_call
# @log_call
def paste_rows(self, checked: bool = False) -> None:
"""
Paste earlier cut rows.
@ -2067,7 +2067,7 @@ class Window(QMainWindow):
if set_next_row:
to_playlist_model.set_next_row(set_next_row)
@log_call
# @log_call
def play_next(
self, position: Optional[float] = None, checked: bool = False
) -> None:
@ -2422,7 +2422,7 @@ class Window(QMainWindow):
height = ds.get_setting("mainwindow_height") or 100
self.setGeometry(x, y, width, height)
@log_call
# @log_call
def set_selected_track_next(self, checked: bool = False) -> None:
"""
Set currently-selected row on visible playlist tab as next track
@ -2436,7 +2436,7 @@ class Window(QMainWindow):
# else:
# log.error("No active tab")
@log_call
# @log_call
def set_tab_colour(self, widget: PlaylistTab, colour: QColor) -> None:
"""
Find the tab containing the widget and set the text colour
@ -2498,7 +2498,7 @@ class Window(QMainWindow):
self.active_tab().scroll_to_top(playlist_track.row_number)
@log_call
# @log_call
def stop(self, checked: bool = False) -> None:
"""Stop playing immediately"""

View File

@ -147,7 +147,7 @@ class PlaylistModel(QAbstractTableModel):
return header_row
@log_call
# @log_call
def add_track_to_header(self, track_details: InsertTrack) -> None:
"""
Handle signal_add_track_to_header
@ -241,7 +241,7 @@ class PlaylistModel(QAbstractTableModel):
return QBrush()
@log_call
# @log_call
def begin_reset_model(self, playlist_id: int) -> None:
"""
Reset model if playlist_id is ours
@ -256,7 +256,7 @@ class PlaylistModel(QAbstractTableModel):
return len(Col)
@log_call
# @log_call
def track_started(self, play_track: PlayTrack) -> None:
"""
Notification from musicmuster that the current track has just
@ -382,7 +382,7 @@ class PlaylistModel(QAbstractTableModel):
return QVariant()
@log_call
# @log_call
def delete_rows(self, row_numbers: list[int]) -> None:
"""
Delete passed rows from model
@ -465,7 +465,7 @@ class PlaylistModel(QAbstractTableModel):
return ""
@log_call
# @log_call
def end_reset_model(self, playlist_id: int) -> None:
"""
End model reset if this is our playlist
@ -544,7 +544,7 @@ class PlaylistModel(QAbstractTableModel):
return boldfont
@log_call
# @log_call
def get_duplicate_rows(self) -> list[int]:
"""
Return a list of duplicate rows. If track appears in rows 2, 3 and 4, return [3, 4]
@ -565,7 +565,7 @@ class PlaylistModel(QAbstractTableModel):
return result
@log_call
# @log_call
def _get_new_row_number(self) -> int:
"""
Get row number for new row.
@ -586,7 +586,7 @@ class PlaylistModel(QAbstractTableModel):
return self.playlist_rows[row_number]
@log_call
# @log_call
def get_row_track_id(self, row_number: int) -> Optional[int]:
"""
Return id of track associated with row or None if no track associated
@ -703,7 +703,7 @@ class PlaylistModel(QAbstractTableModel):
]
self.invalidate_row(row_number, roles)
@log_call
# @log_call
def insert_row(self, track_id: Optional[int] = None, note: str = "",) -> None:
"""
Insert a row.
@ -738,7 +738,7 @@ class PlaylistModel(QAbstractTableModel):
list(range(new_row_number, len(self.playlist_rows))), roles_to_invalidate
)
@log_call
# @log_call
def invalidate_row(self, modified_row: int, roles: list[Qt.ItemDataRole]) -> None:
"""
Signal to view to refresh invalidated row
@ -770,7 +770,7 @@ class PlaylistModel(QAbstractTableModel):
return self.playlist_rows[row_number].path == ""
return False
@log_call
# @log_call
def is_played_row(self, row_number: int) -> bool:
"""
Return True if row is an unplayed track row, else False
@ -806,7 +806,7 @@ class PlaylistModel(QAbstractTableModel):
]
self.invalidate_rows(row_numbers, roles)
@log_call
# @log_call
def move_rows(self, from_rows: list[int], to_row_number: int) -> bool:
"""
Move the playlist rows in from_rows to to_row. Return True if successful
@ -856,7 +856,7 @@ class PlaylistModel(QAbstractTableModel):
# self.invalidate_rows(list(row_map.keys()), roles)
return True
@log_call
# @log_call
def move_rows_between_playlists(
self,
from_rows: list[PlaylistRow],
@ -924,7 +924,7 @@ class PlaylistModel(QAbstractTableModel):
super().endInsertRows()
@log_call
# @log_call
def move_track_add_note(
self, new_row_number: int, existing_plr: PlaylistRow, note: str
) -> None:
@ -943,7 +943,7 @@ class PlaylistModel(QAbstractTableModel):
self.move_rows([existing_plr.row_number], new_row_number)
self.signals.resize_rows_signal.emit(self.playlist_id)
@log_call
# @log_call
def obs_scene_change(self, row_number: int) -> None:
"""
Check this row and any preceding headers for OBS scene change command
@ -978,7 +978,7 @@ class PlaylistModel(QAbstractTableModel):
log.warning(f"{self}: OBS connection refused")
return
@log_call
# @log_call
def previous_track_ended(self) -> None:
"""
Notification from musicmuster that the previous track has ended.
@ -1043,7 +1043,7 @@ class PlaylistModel(QAbstractTableModel):
self.playlist_rows[row_number] = PlaylistRow(refreshed_row)
@log_call
# @log_call
def remove_track(self, row_number: int) -> None:
"""
Remove track from row, retaining row as a header row
@ -1074,7 +1074,7 @@ class PlaylistModel(QAbstractTableModel):
self.invalidate_row(row_number, roles)
self.signals.resize_rows_signal.emit(self.playlist_id)
@log_call
# @log_call
def reset_track_sequence_row_numbers(self) -> None:
"""
Signal handler for when row ordering has changed.
@ -1114,7 +1114,7 @@ class PlaylistModel(QAbstractTableModel):
]
self.invalidate_rows(row_numbers, roles)
@log_call
# @log_call
def _reversed_contiguous_row_groups(
self, row_numbers: list[int]
) -> list[list[int]]:
@ -1255,7 +1255,7 @@ class PlaylistModel(QAbstractTableModel):
return True
@log_call
# @log_call
def set_selected_rows(self, playlist_id: int, selected_row_numbers: list[int]) -> None:
"""
Handle signal_playlist_selected_rows to keep track of which rows
@ -1267,7 +1267,7 @@ class PlaylistModel(QAbstractTableModel):
self.selected_rows = [self.playlist_rows[a] for a in selected_row_numbers]
@log_call
# @log_call
def set_next_row(self, playlist_id: int) -> None:
"""
Handle signal_set_next_row
@ -1312,7 +1312,7 @@ class PlaylistModel(QAbstractTableModel):
self.signals.next_track_changed_signal.emit()
self.update_track_times()
@log_call
# @log_call
def setData(
self,
index: QModelIndex,
@ -1449,7 +1449,7 @@ class PlaylistModel(QAbstractTableModel):
return ds.get_last_played_dates(track_id)
@log_call
# @log_call
def update_or_insert(self, track_id: int, row_number: int) -> None:
"""
If the passed track_id exists in this playlist, update the
@ -1473,7 +1473,7 @@ class PlaylistModel(QAbstractTableModel):
else:
self.insert_row(track_id=track_id)
@log_call
# @log_call
def update_track_times(self) -> None:
"""
Update track start/end times in self.playlist_rows

View File

@ -367,7 +367,7 @@ class PlaylistTab(QTableView):
# Deselect edited line
self.clear_selection()
@log_call
# @log_call
def dropEvent(self, event: Optional[QDropEvent]) -> None:
"""
Move dropped rows
@ -723,7 +723,7 @@ class PlaylistTab(QTableView):
cb.clear(mode=cb.Mode.Clipboard)
cb.setText(track_path, mode=cb.Mode.Clipboard)
@log_call
# @log_call
def track_started(self, play_track: PlayTrack) -> None:
"""
Called when track starts playing
@ -816,7 +816,7 @@ class PlaylistTab(QTableView):
else:
return TrackInfo(track_id, selected_row)
@log_call
# @log_call
def get_selected_row(self) -> Optional[int]:
"""
Return selected row number. If no rows or multiple rows selected, return None
@ -828,7 +828,7 @@ class PlaylistTab(QTableView):
else:
return None
@log_call
# @log_call
def get_selected_rows(self) -> list[int]:
"""Return a list of model-selected row numbers sorted by row"""
@ -841,7 +841,7 @@ class PlaylistTab(QTableView):
return sorted(list(set([self.model().mapToSource(a).row() for a in selected_indexes])))
@log_call
# @log_call
def get_top_visible_row(self) -> int:
"""
Get the viewport of the table view
@ -1010,7 +1010,7 @@ class PlaylistTab(QTableView):
# Reset selection mode
self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
@log_call
# @log_call
def source_model_selected_row_number(self) -> Optional[int]:
"""
Return the model row number corresponding to the selected row or None
@ -1021,7 +1021,7 @@ class PlaylistTab(QTableView):
return None
return self.model().mapToSource(selected_index).row()
@log_call
# @log_call
def selected_model_row_numbers(self) -> list[int]:
"""
Return a list of model row numbers corresponding to the selected rows or