Commit 32ff05e0 authored by Chris Lamb's avatar Chris Lamb 👀
Browse files

Drop passing has_differences around, fixing an issue with generating files called '-'



Signed-off-by: Chris Lamb's avatarChris Lamb <lamby@debian.org>
parent 1e8c1f63
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ class PresenterManager(object):

        # If no output specified, default to printing --text output to stdout
        if not self.config:
            parsed_args.text_output = FORMATS['text']['target'] = '-'
            FORMATS['text']['target'] = '-'
            self.config['text'] = FORMATS['text']

        logger.debug(
@@ -85,16 +85,25 @@ class PresenterManager(object):
        )

    def output(self, difference, parsed_args, has_differences):
        # As a special case, write an empty file instead of an empty diff.
        if not has_differences:
            try:
                target = self.config['text']['target']

                if target != '-':
                    open(target, 'w').close()
            except KeyError:
                pass
            return

        if difference is None:
            return

        for name, data in self.config.items():
            logger.debug("Generating %r output at %r", name, data['target'])

            with profile('output', name):
                data['klass'].run(
                    data,
                    difference,
                    parsed_args,
                    has_differences,
                )
                data['klass'].run(data, difference, parsed_args)

    def compute_visual_diffs(self):
        """
+2 −2
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ class HTMLPresenter(Presenter):
    supports_visual_diffs = True

    @classmethod
    def run(cls, data, difference, parsed_args, has_differences):
    def run(cls, data, difference, parsed_args):
        with make_printer(parsed_args.html_output) as fn:
            output_html(
                difference,
@@ -93,7 +93,7 @@ class HTMLPresenter(Presenter):

class HTMLDirectoryPresenter(HTMLPresenter):
    @classmethod
    def run(cls, data, difference, parsed_args, has_differences):
    def run(cls, data, difference, parsed_args):
        output_html_directory(
            parsed_args.html_output_directory,
            difference,
+2 −7
Original line number Diff line number Diff line
@@ -44,13 +44,8 @@ class TextPresenter(Presenter):
        super().__init__()

    @classmethod
    def run(cls, data, difference, parsed_args, has_differences):
        # As a special case, write an empty file instead of an empty diff.
        if not has_differences:
            open(parsed_args.text_output, 'w').close()
            return

        with make_printer(parsed_args.text_output or '-') as fn:
    def run(cls, data, difference, parsed_args):
        with make_printer(data['target']) as fn:
            color = {
                'auto': fn.output.isatty(),
                'never': False,
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ class Presenter(object):
        self.depth = 0

    @classmethod
    def run(cls, data, difference, parsed_args, has_differences):
    def run(cls, data, difference, parsed_args):
        with make_printer(data['target']) as fn:
            cls(fn).start(difference)