Commit 3a5f46d2 authored by Chris Lamb's avatar Chris Lamb 👀
Browse files

Factor-out the generation of "foo not available in path" comment messages into...

Factor-out the generation of "foo not available in path" comment messages into the exception that raises them.
parent 85c21007
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -496,13 +496,7 @@ class File(metaclass=abc.ABCMeta):
                if difference is None:
                    return None
                difference.add_comment(
                    "'%s' not available in path. Falling back to binary comparison."
                    % e.command
                )
                package = e.get_package()
                if package:
                    difference.add_comment(
                        "Install '%s' to get a better output." % package
                    e.get_comment("Falling back to binary comparison.")
                )
            except OutputParsingError as e:
                difference = self.compare_bytes(other, source=source)
+12 −0
Original line number Diff line number Diff line
@@ -34,6 +34,18 @@ class RequiredToolNotFound(Exception):
    def get_package(self):
        return get_package_provider(self.command)

    def get_comment(self, infix=''):
        xs = [
            "'{}' not available in path.".format(self.command),
            infix,
        ]

        x = self.get_package()
        if x:
            xs.append("Install '{}' to get a better output.".format(x))

        return " ".join(x for x in xs if x)


class ContainerExtractionError(Exception):
    def __init__(self, pathname, wrapped_exc):