Commit 7b683097 authored by Chris Lamb's avatar Chris Lamb 👀
Browse files

Prevent abstraction-level violation by defining visual diff support on the Presenter classes.



Signed-off-by: Chris Lamb's avatarChris Lamb <lamby@debian.org>
parent 3e8c0c9d
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -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')
+3 −1
Original line number Diff line number Diff line
@@ -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(
+2 −0
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import contextlib


class Presenter(object):
    supports_visual_diffs = False

    def __init__(self):
        self.depth = 0