[meld] dirdiff: Make our canonicalisation helper slightly more normal



commit f31010229f9a46f0e2e1b65433c493018ed9e82f
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Nov 12 05:24:34 2017 +1000

    dirdiff: Make our canonicalisation helper slightly more normal
    
    The actual point here is that mypy loses it over this construction,
    though honestly I don't blame it.

 meld/dirdiff.py |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index 8d27d86..425b97a 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -219,11 +219,10 @@ class CanonicalListing(object):
     def __init__(self, n, canonicalize=None):
         self.items = collections.defaultdict(lambda: [None] * n)
         self.errors = []
-        if canonicalize is not None:
-            self.canonicalize = canonicalize
-            self.add = self.add_canon
+        self.canonicalize = canonicalize
+        self.add = self.add_simple if canonicalize is None else self.add_canon
 
-    def add(self, pane, item):
+    def add_simple(self, pane, item):
         self.items[item][pane] = item
 
     def add_canon(self, pane, item):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]