[meld] dirdiff: Refactor error row adding for cleaner defaults
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] dirdiff: Refactor error row adding for cleaner defaults
- Date: Wed, 12 Sep 2018 11:56:01 +0000 (UTC)
commit 321dc2ff944f3d8ab27362b8586952f4d8ce59c4
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Sep 2 10:30:08 2018 +1000
dirdiff: Refactor error row adding for cleaner defaults
The only reason these defaults aren't in the base `tree` module is that
vcview doesn't have the columns. I've tried using column defaults
elsewhere, but `GtkTreeStore` always seems to want to set column values
to a zero/null-esque empty state, so setting it to -1 by default doesn't
seem to be easily doable.
meld/dirdiff.py | 26 +++++++++++---------------
1 file changed, 11 insertions(+), 15 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index bf7e083e..e4d9ce79 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -245,6 +245,14 @@ class DirDiffTreeStore(tree.DiffTreeStore):
def __init__(self, ntree):
super().__init__(ntree, [str, str, int, float, int])
+ def add_error(self, parent, msg, pane):
+ defaults = {
+ COL_TIME: -1.0,
+ COL_SIZE: -1,
+ COL_PERMS: -1
+ }
+ super().add_error(parent, msg, pane, defaults)
+
class CanonicalListing:
"""Multi-pane lists with canonicalised matching and error detection"""
@@ -759,11 +767,7 @@ class DirDiff(MeldDoc, Component):
try:
entries = os.listdir(root)
except OSError as err:
- self.model.add_error(it, err.strerror, pane, {
- COL_TIME: -1.0,
- COL_SIZE: -1,
- COL_PERMS: -1
- })
+ self.model.add_error(it, err.strerror, pane)
differences = True
continue
@@ -786,11 +790,7 @@ class DirDiff(MeldDoc, Component):
# Covers certain unreadable symlink cases; see bgo#585895
except OSError as err:
error_string = e + err.strerror
- self.model.add_error(it, error_string, pane, {
- COL_TIME: -1.0,
- COL_SIZE: -1,
- COL_PERMS: -1
- })
+ self.model.add_error(it, error_string, pane)
continue
if stat.S_ISLNK(s.st_mode):
@@ -811,11 +811,7 @@ class DirDiff(MeldDoc, Component):
error_string = e + ": Dangling symlink"
else:
error_string = e + err.strerror
- self.model.add_error(it, error_string, pane, {
- COL_TIME: -1.0,
- COL_SIZE: -1,
- COL_PERMS: -1
- })
+ self.model.add_error(it, error_string, pane)
differences = True
elif stat.S_ISREG(s.st_mode):
files.add(pane, e)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]