[diffoscope] 03/05: comparators.utils.container: Tidy formatting.

Chris Lamb chris at chris-lamb.co.uk
Tue Feb 7 23:50:39 CET 2017


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository diffoscope.

commit d8898e88f5115134939f6fc97700a45b2977b69f
Author: Chris Lamb <lamby at debian.org>
Date:   Wed Feb 8 11:41:34 2017 +1300

    comparators.utils.container: Tidy formatting.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 diffoscope/comparators/utils/container.py | 33 +++++++++++++++++++++++--------
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/diffoscope/comparators/utils/container.py b/diffoscope/comparators/utils/container.py
index 3cd6650..fa63645 100644
--- a/diffoscope/comparators/utils/container.py
+++ b/diffoscope/comparators/utils/container.py
@@ -40,8 +40,8 @@ class Container(object, metaclass=abc.ABCMeta):
             new = super(Container, MissingContainer).__new__(MissingContainer)
             new.__init__(source)
             return new
-        else:
-            return super(Container, cls).__new__(cls)
+
+        return super(Container, cls).__new__(cls)
 
     def __init__(self, source):
         self._source = source
@@ -51,24 +51,35 @@ class Container(object, metaclass=abc.ABCMeta):
         return self._source
 
     def get_members(self):
-        """Returns a dictionary. The key is what is used to match when comparing containers."""
+        """
+        Returns a dictionary. The key is what is used to match when comparing
+        containers.
+        """
+
         return collections.OrderedDict(self.get_all_members())
 
     def lookup_file(self, *names):
-        """Try to fetch a specific file by digging in containers."""
+        """
+        Try to fetch a specific file by digging in containers.
+        """
+
         from .specialize import specialize
+
         name, remainings = names[0], names[1:]
         try:
             file = self.get_member(name)
         except KeyError:
             return None
-        logger.debug('lookup_file(%s) -> %s', names, file)
+
+        logger.debug("lookup_file(%s) -> %s", names, file)
         specialize(file)
         if not remainings:
             return file
+
         container = file.as_container
         if not container:
             return None
+
         return container.lookup_file(*remainings)
 
     @abc.abstractmethod
@@ -80,8 +91,8 @@ class Container(object, metaclass=abc.ABCMeta):
         raise NotImplementedError()
 
     def get_all_members(self):
-        # If your get_member implementation is O(n) then this will be O(n^2) cost
-        # In such cases it is HIGHLY RECOMMENDED to override this as well
+        # If your get_member implementation is O(n) then this will be O(n^2)
+        # cost. In such cases it is HIGHLY RECOMMENDED to override this as well
         for name in self.get_member_names():
             yield name, self.get_member(name)
 
@@ -99,15 +110,18 @@ class Container(object, metaclass=abc.ABCMeta):
                     p.step(msg=my_member.progress_name)
                 else:
                     my_reminders[my_member_name] = my_member
+
             my_members = my_reminders
             for my_name, other_name, score in perform_fuzzy_matching(my_members, other_members):
                 comment = 'Files similar despite different names (difference score: %d)' % score
                 yield my_members.pop(my_name), other_members.pop(other_name), comment
                 p.step(2, msg=my_name)
+
             if Config().new_file:
                 for my_member in my_members.values():
                     yield my_member, MissingFile('/dev/null', my_member), NO_COMMENT
                     p.step(msg=my_member)
+
                 for other_member in other_members.values():
                     yield MissingFile('/dev/null', other_member), other_member, NO_COMMENT
                     p.step(msg=other_member)
@@ -115,7 +129,10 @@ class Container(object, metaclass=abc.ABCMeta):
     def compare(self, other, source=None):
         from .compare import compare_commented_files
 
-        return itertools.starmap(compare_commented_files, self.comparisons(other))
+        return itertools.starmap(
+            compare_commented_files,
+            self.comparisons(other),
+        )
 
 
 class MissingContainer(Container):

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list