[diffoscope] 01/02: main: switch some logic around to be easier to edit later

Ximin Luo infinity0 at debian.org
Tue Sep 27 11:28:16 CEST 2016


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

infinity0 pushed a commit to branch master
in repository diffoscope.

commit 8f0164143f41bbf5ea29c878666f27550f02ec68
Author: Ximin Luo <infinity0 at debian.org>
Date:   Tue Sep 27 10:03:00 2016 +0200

    main: switch some logic around to be easier to edit later
---
 diffoscope/main.py | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/diffoscope/main.py b/diffoscope/main.py
index fd476d9..8b63b79 100644
--- a/diffoscope/main.py
+++ b/diffoscope/main.py
@@ -231,23 +231,24 @@ def run_diffoscope(parsed_args):
     if parsed_args.debug:
         logger.setLevel(logging.DEBUG)
     set_locale()
+    # no output desired? print text to stdout
+    if not any((parsed_args.text_output, parsed_args.html_output, parsed_args.html_output_directory)):
+        parsed_args.text_output = "-"
     logger.debug('Starting comparison')
     ProgressManager().setup(parsed_args)
     difference = diffoscope.comparators.compare_root_paths(
         parsed_args.path1, parsed_args.path2)
     ProgressManager().finish()
     if difference:
-        # no output desired? print text
-        if not any((parsed_args.text_output, parsed_args.html_output, parsed_args.html_output_directory)):
-            parsed_args.text_output = "-"
+        if parsed_args.text_output:
+            with make_printer(parsed_args.text_output or '-') as print_func:
+                output_text(difference, print_func=print_func)
         if parsed_args.html_output:
             with make_printer(parsed_args.html_output) as print_func:
                 output_html(difference, css_url=parsed_args.css_url, print_func=print_func)
         if parsed_args.html_output_directory:
-            output_html_directory(parsed_args.html_output_directory, difference, css_url=parsed_args.css_url, jquery_url=parsed_args.jquery_url)
-        if parsed_args.text_output:
-            with make_printer(parsed_args.text_output or '-') as print_func:
-                output_text(difference, print_func=print_func)
+            output_html_directory(parsed_args.html_output_directory, difference,
+                css_url=parsed_args.css_url, jquery_url=parsed_args.jquery_url)
         return 1
     if parsed_args.always_write_text and parsed_args.text_output:
         open(parsed_args.text_output, 'w').close()

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


More information about the diffoscope mailing list