[diffoscope] 04/05: comparators/{directory/utils}.py: Expand and step the global progress state when we see and make progress through a container type.

Chris Lamb chris at chris-lamb.co.uk
Mon Sep 26 18:57:55 CEST 2016


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

lamby pushed a commit to branch master
in repository diffoscope.

commit 5e8b841867c1ede59181af503713be39df798cec
Author: Chris Lamb <lamby at debian.org>
Date:   Mon Sep 26 18:52:11 2016 +0200

    comparators/{directory/utils}.py: Expand and step the global progress state when we see and make progress through a container type.
---
 diffoscope/comparators/directory.py | 4 +++-
 diffoscope/comparators/utils.py     | 6 +++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/diffoscope/comparators/directory.py b/diffoscope/comparators/directory.py
index 892c033..3fa7051 100644
--- a/diffoscope/comparators/directory.py
+++ b/diffoscope/comparators/directory.py
@@ -25,6 +25,7 @@ import diffoscope.comparators
 
 from diffoscope import logger, tool_required
 from diffoscope.exc import RequiredToolNotFound
+from diffoscope.progress import Progress
 from diffoscope.difference import Difference
 from diffoscope.comparators.utils import Container, Command
 from diffoscope.comparators.binary import FilesystemFile
@@ -152,7 +153,7 @@ class FilesystemDirectory(object):
         my_names = my_container.get_member_names()
         other_names = other_container.get_member_names()
         to_compare = set(my_names).intersection(other_names)
-        if True:
+        with Progress(len(to_compare)) as p:
             for name in sorted(to_compare):
                 my_file = my_container.get_member(name)
                 other_file = other_container.get_member(name)
@@ -164,6 +165,7 @@ class FilesystemDirectory(object):
                 if inner_difference:
                     inner_difference.add_details(meta_differences)
                     differences.append(inner_difference)
+                p.step()
         if not differences:
             return None
         difference = Difference(None, self.path, other.path, source)
diff --git a/diffoscope/comparators/utils.py b/diffoscope/comparators/utils.py
index 773f113..1529dae 100644
--- a/diffoscope/comparators/utils.py
+++ b/diffoscope/comparators/utils.py
@@ -31,6 +31,7 @@ import diffoscope.comparators
 
 from diffoscope import logger, tool_required, get_temporary_directory
 from diffoscope.config import Config
+from diffoscope.progress import Progress
 from diffoscope.comparators.binary import File, NonExistingFile
 
 
@@ -202,24 +203,27 @@ class Container(object, metaclass=abc.ABCMeta):
         my_reminders = collections.OrderedDict()
         other_members = other.get_members()
 
-        if True:
+        with Progress(max(len(my_members), len(other_members))) as p:
             # keep it sorted like my members
             while my_members:
                 my_member_name, my_member = my_members.popitem(last=False)
                 if my_member_name in other_members:
                     yield my_member, other_members.pop(my_member_name), NO_COMMENT
+                    p.step()
                 else:
                     my_reminders[my_member_name] = my_member
             my_members = my_reminders
             for my_name, other_name, score in diffoscope.comparators.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)
             if Config.general.new_file:
                 for my_member in my_members.values():
                     yield my_member, NonExistingFile('/dev/null', my_member), NO_COMMENT
                     p.step()
                 for other_member in other_members.values():
                     yield NonExistingFile('/dev/null', other_member), other_member, NO_COMMENT
+                    p.step()
 
     def compare(self, other, source=None):
         return itertools.starmap(diffoscope.comparators.compare_commented_files, self.comparisons(other))

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


More information about the diffoscope mailing list