[diffoscope] 03/05: Prevent abstraction-level violation by defining visual diff support on the Presenter classes.

Chris Lamb chris at chris-lamb.co.uk
Sun Apr 30 11:02:25 CEST 2017


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

lamby pushed a commit to branch experimental
in repository diffoscope.

commit 7b6830978f5a76077793a28f30e185d22633829f
Author: Chris Lamb <lamby at debian.org>
Date:   Sun Apr 30 09:18:17 2017 +0100

    Prevent abstraction-level violation by defining visual diff support on the Presenter classes.
    
    Signed-off-by: Chris Lamb <lamby at debian.org>
---
 diffoscope/main.py                 | 7 +++----
 diffoscope/presenters/html/html.py | 4 +++-
 diffoscope/presenters/utils.py     | 2 ++
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/diffoscope/main.py b/diffoscope/main.py
index f7c060d..caa824a 100644
--- a/diffoscope/main.py
+++ b/diffoscope/main.py
@@ -287,10 +287,9 @@ def run_diffoscope(parsed_args):
     Config().excludes = parsed_args.excludes
     presenter_config = configure_presenters(parsed_args)
     # Don't waste time computing visual differences if we won't use them.
-    Config().compute_visual_diffs = any((
-        parsed_args.html_output,
-        parsed_args.html_output_directory,
-    ))
+    Config().compute_visual_diffs = any(
+        x['klass'].supports_visual_diffs for x in presenter_config.values(),
+    )
     set_path()
     set_locale()
     logger.debug('Starting comparison')
diff --git a/diffoscope/presenters/html/html.py b/diffoscope/presenters/html/html.py
index 160d3fb..9a86261 100644
--- a/diffoscope/presenters/html/html.py
+++ b/diffoscope/presenters/html/html.py
@@ -79,6 +79,8 @@ spl_print_func, spl_print_ctrl = None, None
 
 
 class HTMLPresenter(Presenter):
+    supports_visual_diffs = True
+
     @classmethod
     def run(cls, data, difference, parsed_args, has_differences):
         with make_printer(parsed_args.html_output) as fn:
@@ -89,7 +91,7 @@ class HTMLPresenter(Presenter):
             )
 
 
-class HTMLDirectoryPresenter(Presenter):
+class HTMLDirectoryPresenter(HTMLPresenter):
     @classmethod
     def run(cls, data, difference, parsed_args, has_differences):
         output_html_directory(
diff --git a/diffoscope/presenters/utils.py b/diffoscope/presenters/utils.py
index c174f5f..74da0f4 100644
--- a/diffoscope/presenters/utils.py
+++ b/diffoscope/presenters/utils.py
@@ -23,6 +23,8 @@ import contextlib
 
 
 class Presenter(object):
+    supports_visual_diffs = False
+
     def __init__(self):
         self.depth = 0
 

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


More information about the diffoscope mailing list