[meld: 7/8] dirdiff: Re-jig comparison option usage
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld: 7/8] dirdiff: Re-jig comparison option usage
- Date: Sun, 30 Jan 2022 21:55:06 +0000 (UTC)
commit fb3b03b088f6e9d1654d0b174a43d6717d581c6f
Author: Kai Willadsen <kai willadsen gmail com>
Date: Mon Jan 31 07:23:33 2022 +1000
dirdiff: Re-jig comparison option usage
The main change here is making comparison options not be an attribute,
but rather just recreate it when doing our scan. The reason here is that
it's nicer to not have duplicate state on the class, and it's somewhat
better to have the action state be explicit.
This change also fixes a linting error that was breaking CI.
meld/dirdiff.py | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 67de2187..971dd61f 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -265,9 +265,14 @@ class DirDiffTreeStore(tree.DiffTreeStore):
class ComparisonOptions:
- def __init__(self):
- self.ignore_case = False
- self.normalize_encoding = False
+ def __init__(
+ self,
+ *,
+ ignore_case: bool = False,
+ normalize_encoding: bool = False,
+ ):
+ self.ignore_case = ignore_case
+ self.normalize_encoding = normalize_encoding
class CanonicalListing:
@@ -495,8 +500,6 @@ class DirDiff(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
"text-filters-changed", self.on_text_filters_changed)
]
- self.compare = ComparisonOptions()
-
# Handle overview map visibility binding. Because of how we use
# grid packing, we need two revealers here instead of the more
# obvious one.
@@ -830,9 +833,12 @@ class DirDiff(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
shadowed_entries = []
invalid_filenames = []
- # TODO: Map this to a GObject prop instead?
- self.compare.ignore_case = self.get_action_state('folder-ignore-case')
- self.compare.normalize_encoding = self.get_action_state('folder-normalize-encoding')
+ # TODO: Map these action states to GObject props instead?
+ comparison_options = ComparisonOptions(
+ ignore_case=self.get_action_state('folder-ignore-case'),
+ normalize_encoding=self.get_action_state(
+ 'folder-normalize-encoding'),
+ )
while len(todo):
todo.sort() # depth first
@@ -850,8 +856,8 @@ class DirDiff(Gtk.VBox, tree.TreeviewCommon, MeldDoc):
differences = False
encoding_errors = []
- dirs = CanonicalListing(self.num_panes, self.compare)
- files = CanonicalListing(self.num_panes, self.compare)
+ dirs = CanonicalListing(self.num_panes, comparison_options)
+ files = CanonicalListing(self.num_panes, comparison_options)
for pane, root in enumerate(roots):
if not os.path.isdir(root):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]