[diffoscope] 03/05: diffoscope.progress: Rewrite "show progressbar" logic to be clearer.

Chris Lamb chris at chris-lamb.co.uk
Tue Mar 14 18:59:51 CET 2017


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

lamby pushed a commit to branch experimental
in repository diffoscope.

commit 129cce96da6a30a4deb9f59ce8642fe9d76f96b7
Author: Chris Lamb <lamby at debian.org>
Date:   Tue Mar 14 11:32:22 2017 +0100

    diffoscope.progress: Rewrite "show progressbar" logic to be clearer.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 diffoscope/progress.py | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/diffoscope/progress.py b/diffoscope/progress.py
index 220ac96..8ec3fdc 100644
--- a/diffoscope/progress.py
+++ b/diffoscope/progress.py
@@ -40,10 +40,18 @@ class ProgressManager(object):
         self.observers = []
 
     def setup(self, parsed_args):
-        # Show progress bar if user explicitly asked for it, otherwise show if
-        # STDOUT is a tty.
-        if parsed_args.progress or \
-                (parsed_args.progress is None and sys.stdout.isatty()):
+        def show_progressbar():
+            # Show progress bar if user explicitly asked for it
+            if parsed_args.progress:
+                return True
+
+            # ... otherwise show it if STDOUT is a tty
+            if parsed_args.progress is None:
+                return sys.stdout.isatty()
+
+            return False
+
+        if show_progressbar():
             try:
                 self.register(ProgressBar())
             except ImportError:

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


More information about the diffoscope mailing list