[diffoscope] 01/02: main.py: Rewrite if/elif/elif as a dictionary lookup.

Chris Lamb chris at chris-lamb.co.uk
Sat Dec 3 11:44:59 CET 2016


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

lamby pushed a commit to branch master
in repository diffoscope.

commit e8dbcb18974dc8b60915e1c5a8da8ecea09f264d
Author: Chris Lamb <lamby at debian.org>
Date:   Sat Dec 3 09:39:19 2016 +0000

    main.py: Rewrite if/elif/elif as a dictionary lookup.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 diffoscope/main.py | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/diffoscope/main.py b/diffoscope/main.py
index c0a7a46..a8256da 100644
--- a/diffoscope/main.py
+++ b/diffoscope/main.py
@@ -258,13 +258,11 @@ def run_diffoscope(parsed_args):
                 open(parsed_args.text_output, 'w').close()
             else:
                 with make_printer(parsed_args.text_output or '-') as print_func:
-                    text_color = parsed_args.text_color
-                    if text_color == 'auto':
-                        color = print_func.output.isatty()
-                    elif text_color == 'always':
-                        color = True
-                    elif text_color == 'never':
-                        color = False
+                    color = {
+                        'auto': print_func.output.isatty(),
+                        'never': False,
+                        'always': True,
+                    }[parsed_args.text_color]
                     output_text(difference, print_func=print_func, color=color)
         if parsed_args.html_output:
             with make_printer(parsed_args.html_output) as print_func:

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


More information about the diffoscope mailing list