diff --git a/rpmlint/pkg.py b/rpmlint/pkg.py index cb5f93fe1..4ecfc12d1 100644 --- a/rpmlint/pkg.py +++ b/rpmlint/pkg.py @@ -355,9 +355,19 @@ def parse_deps(line): def get_magic(path): + # python-magic & libmagic compatibility code + # https://github.com/ahupp/python-magic/blob/master/COMPAT.md + detect_magic = None + if hasattr(magic, 'from_file'): + # python-magic module + detect_magic = magic.from_file + else: + # libmagic python bindings + detect_magic = lambda x: magic.detect_from_filename(x).name + try: - return magic.detect_from_filename(path).name - except ValueError: + return detect_magic(path) + except (ValueError, FileNotFoundError): return ''