mirror of
https://github.com/fergalmoran/picard.git
synced 2025-12-25 10:48:18 +00:00
IgnoreUpdatesContext: onexit -> on_exit
This commit is contained in:
@@ -163,7 +163,7 @@ class MainWindow(QtWidgets.QMainWindow, PreserveGeometry):
|
||||
self.tagger = QtCore.QCoreApplication.instance()
|
||||
self._is_wayland = self.tagger.is_wayland
|
||||
self.selected_objects = []
|
||||
self.ignore_selection_changes = IgnoreUpdatesContext(self.update_selection)
|
||||
self.ignore_selection_changes = IgnoreUpdatesContext(on_exit=self.update_selection)
|
||||
self.toolbar = None
|
||||
self.player = None
|
||||
self.status_indicators = []
|
||||
|
||||
@@ -276,7 +276,7 @@ class MetadataBox(QtWidgets.QTableWidget):
|
||||
self.preserved_tags = PreservedTags()
|
||||
self._single_file_album = False
|
||||
self._single_track_album = False
|
||||
self.ignore_updates = IgnoreUpdatesContext(onexit=self.update)
|
||||
self.ignore_updates = IgnoreUpdatesContext(on_exit=self.update)
|
||||
self.tagger.clipboard().dataChanged.connect(self._update_clipboard)
|
||||
|
||||
def _get_file_lookup(self):
|
||||
|
||||
@@ -561,17 +561,17 @@ class IgnoreUpdatesContext:
|
||||
updates if it is `False`.
|
||||
"""
|
||||
|
||||
def __init__(self, onexit=None):
|
||||
def __init__(self, on_exit=None):
|
||||
self._entered = 0
|
||||
self._onexit = onexit
|
||||
self._on_exit = on_exit
|
||||
|
||||
def __enter__(self):
|
||||
self._entered += 1
|
||||
|
||||
def __exit__(self, type, value, tb):
|
||||
self._entered -= 1
|
||||
if self._onexit:
|
||||
self._onexit()
|
||||
if self._on_exit:
|
||||
self._on_exit()
|
||||
|
||||
def __bool__(self):
|
||||
return self._entered > 0
|
||||
|
||||
@@ -923,12 +923,12 @@ class IgnoreUpdatesContextTest(PicardTestCase):
|
||||
self.assertTrue(context)
|
||||
self.assertFalse(context)
|
||||
|
||||
def test_run_onexit(self):
|
||||
onexit = Mock()
|
||||
context = IgnoreUpdatesContext(onexit=onexit)
|
||||
def test_run_on_exit(self):
|
||||
on_exit = Mock()
|
||||
context = IgnoreUpdatesContext(on_exit=on_exit)
|
||||
with context:
|
||||
onexit.assert_not_called()
|
||||
onexit.assert_called_once_with()
|
||||
on_exit.assert_not_called()
|
||||
on_exit.assert_called_once_with()
|
||||
|
||||
def test_nested_with(self):
|
||||
context = IgnoreUpdatesContext()
|
||||
|
||||
Reference in New Issue
Block a user