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.tagger = QtCore.QCoreApplication.instance()
|
||||||
self._is_wayland = self.tagger.is_wayland
|
self._is_wayland = self.tagger.is_wayland
|
||||||
self.selected_objects = []
|
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.toolbar = None
|
||||||
self.player = None
|
self.player = None
|
||||||
self.status_indicators = []
|
self.status_indicators = []
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ class MetadataBox(QtWidgets.QTableWidget):
|
|||||||
self.preserved_tags = PreservedTags()
|
self.preserved_tags = PreservedTags()
|
||||||
self._single_file_album = False
|
self._single_file_album = False
|
||||||
self._single_track_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)
|
self.tagger.clipboard().dataChanged.connect(self._update_clipboard)
|
||||||
|
|
||||||
def _get_file_lookup(self):
|
def _get_file_lookup(self):
|
||||||
|
|||||||
@@ -561,17 +561,17 @@ class IgnoreUpdatesContext:
|
|||||||
updates if it is `False`.
|
updates if it is `False`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, onexit=None):
|
def __init__(self, on_exit=None):
|
||||||
self._entered = 0
|
self._entered = 0
|
||||||
self._onexit = onexit
|
self._on_exit = on_exit
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
self._entered += 1
|
self._entered += 1
|
||||||
|
|
||||||
def __exit__(self, type, value, tb):
|
def __exit__(self, type, value, tb):
|
||||||
self._entered -= 1
|
self._entered -= 1
|
||||||
if self._onexit:
|
if self._on_exit:
|
||||||
self._onexit()
|
self._on_exit()
|
||||||
|
|
||||||
def __bool__(self):
|
def __bool__(self):
|
||||||
return self._entered > 0
|
return self._entered > 0
|
||||||
|
|||||||
@@ -923,12 +923,12 @@ class IgnoreUpdatesContextTest(PicardTestCase):
|
|||||||
self.assertTrue(context)
|
self.assertTrue(context)
|
||||||
self.assertFalse(context)
|
self.assertFalse(context)
|
||||||
|
|
||||||
def test_run_onexit(self):
|
def test_run_on_exit(self):
|
||||||
onexit = Mock()
|
on_exit = Mock()
|
||||||
context = IgnoreUpdatesContext(onexit=onexit)
|
context = IgnoreUpdatesContext(on_exit=on_exit)
|
||||||
with context:
|
with context:
|
||||||
onexit.assert_not_called()
|
on_exit.assert_not_called()
|
||||||
onexit.assert_called_once_with()
|
on_exit.assert_called_once_with()
|
||||||
|
|
||||||
def test_nested_with(self):
|
def test_nested_with(self):
|
||||||
context = IgnoreUpdatesContext()
|
context = IgnoreUpdatesContext()
|
||||||
|
|||||||
Reference in New Issue
Block a user