......@@ -21,7 +21,10 @@ import re
import glob
import logging
from diffoscope.tools import python_module_missing
from diffoscope.tools import (
python_module_missing,
get_comment_for_missing_python_module,
)
from diffoscope.tempfiles import get_temporary_directory
from .utils.file import File
......@@ -70,10 +73,11 @@ class BinwalkFile(File):
@classmethod
def recognizes(cls, file):
if binwalk is None:
if not super().recognizes(file):
return False
if not super().recognizes(file):
if binwalk is None:
file.add_comment(get_comment_for_missing_python_module("binwalk"))
return False
# RPM files are .cpio, but let's always leave it to the RPM comparator.
......
......@@ -24,7 +24,7 @@ import os.path
from diffoscope.difference import Difference
from diffoscope.tools import python_module_missing
from diffoscope.profiling import profile
from diffoscope.tools import get_package_provider
from diffoscope.tools import get_comment_for_missing_python_module
from .utils.file import File
from .utils.archive import Archive
......@@ -129,9 +129,5 @@ class FsImageFile(File):
)
)
if not guestfs:
pkg = get_package_provider("guestfs")
infix = f" from the '{pkg}' package " if pkg else " "
self.add_comment(
f"Installing the 'guestfs' Python module{infix}may produce a better output."
)
self.add_comment(get_comment_for_missing_python_module("guestfs"))
return differences
......@@ -191,4 +191,11 @@ def python_module_missing(name):
python_module_missing.modules.add(name)
def get_comment_for_missing_python_module(name):
pkg = get_package_provider(name)
infix = f" from the '{pkg}' package " if pkg else " "
return f"Installing the '{name}' Python module{infix}may produce a better output."
python_module_missing.modules = set()