Commit 48af8e61 authored by Chris Lamb's avatar Chris Lamb 💬

Move external tool definitions out of misleading "exceptions" module.

parent fc78bf07
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>. # along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
from .tools import get_current_os from .tools import get_current_os
from .external_tools import EXTERNAL_TOOLS
class OutputParsingError(Exception): class OutputParsingError(Exception):
...@@ -27,206 +28,12 @@ class OutputParsingError(Exception): ...@@ -27,206 +28,12 @@ class OutputParsingError(Exception):
self.object_class = object.__class__ self.object_class = object.__class__
class RequiredToolNotFound(Exception): class RequiredToolNotFound(Exception):
PROVIDERS = {
'apktool': {
'debian': 'apktool',
},
'bzip2': {
'debian': 'bzip2',
'arch': 'bzip2',
},
'cbfstool': {
},
'cd-iccdump': {
'debian': 'colord',
'arch': 'colord',
'FreeBSD': 'colord',
},
'cmp': {
'debian': 'diffutils',
'arch': 'diffutils',
},
'cpio': {
'debian': 'cpio',
'arch': 'cpio',
},
'diff': {
'debian': 'diffutils',
'arch': 'diffutils',
},
'enjarify': {
'debian': 'enjarify',
'arch': 'enjarify',
},
'file': {
'debian': 'file',
'arch': 'file',
},
'find': {
'debian': 'findutils',
'arch': 'findutils',
},
'getfacl': {
'debian': 'acl',
'arch': 'acl',
},
'ghc': {
'debian': 'ghc',
'arch': 'ghc',
'FreeBSD': 'ghc',
},
'gpg': {
'debian': 'gnupg',
'arch': 'gnupg',
'FreeBSD': 'gnupg',
},
'gzip': {
'debian': 'gzip',
'arch': 'gzip',
},
'identify': {
'debian': 'imagemagick',
'arch': 'imagemagick',
},
'img2txt': {
'debian': 'caca-utils',
'arch': 'libcaca',
'FreeBSD': 'libcaca',
},
'isoinfo': {
'debian': 'genisoimage',
'arch': 'cdrkit',
'FreeBSD': 'cdrtools',
},
'javap': {
'debian': 'default-jdk-headless | default-jdk | java-sdk',
'arch': 'java-environment',
},
'js-beautify': {
'debian': 'jsbeautifier',
},
'llvm-bcanalyzer': {
'debian': 'llvm',
'arch': 'llvm',
},
'llvm-config': {
'debian': 'llvm',
'arch': 'llvm',
},
'llvm-dis': {
'debian': 'llvm',
'arch': 'llvm',
},
'ls': {
'debian': 'coreutils',
'arch': 'coreutils',
},
'lsattr': {
'debian': 'e2fsprogs',
'arch': 'e2fsprogs',
'FreeBSD': 'e2fsprogs',
},
'msgunfmt': {
'debian': 'gettext',
'arch': 'gettext',
'FreeBSD': 'gettext-tools',
},
'convert': {
'debian': 'imagemagick',
'arch': 'imagemagick',
},
'nm': {
'debian': 'binutils-multiarch',
'arch': 'binutils',
},
'objdump': {
'debian': 'binutils-multiarch',
'arch': 'binutils',
},
'pdftk': {
'debian': 'pdftk',
'FreeBSD': 'pdftk',
},
'pdftotext': {
'debian': 'poppler-utils',
'arch': 'poppler',
'FreeBSD': 'poppler-utils',
},
'pedump': {
'debian': 'mono-utils',
'arch': 'mono-tools',
'FreeBSD': 'mono',
},
'ppudump': {
'debian': 'fp-utils',
'arch': 'fpc',
'FreeBSD': 'fpc',
},
'ps2ascii': {
'debian': 'ghostscript',
'arch': 'ghostscript',
'FreeBSD': 'ghostscript9-base',
},
'readelf': {
'debian': 'binutils-multiarch',
'arch': 'binutils',
},
'rpm2cpio': {
'debian': 'rpm2cpio',
'arch': 'rpmextract',
'FreeBSD': 'rpm2cpio',
},
'showttf': {
'debian': 'fontforge-extras',
},
'sng': {
'debian': 'sng',
},
'ssh-keygen': {
'debian': 'openssh-client',
'arch': 'openssh',
},
'stat': {
'debian': 'coreutils',
'arch': 'coreutils',
},
'sqlite3': {
'debian': 'sqlite3',
'arch': 'sqlite',
'FreeBSD': 'sqlite3',
},
'tar': {
'debian': 'tar',
'arch': 'tar',
},
'unsquashfs': {
'debian': 'squashfs-tools',
'arch': 'squashfs-tools',
'FreeBSD': 'squashfs-tools',
},
'xxd': {
'debian': 'xxd | vim-common',
'arch': 'vim',
'FreeBSD': 'vim | vim-lite',
},
'xz': {
'debian': 'xz-utils',
'arch': 'xz',
},
'zipinfo': {
'debian': 'unzip',
'arch': 'unzip',
'FreeBSD': 'unzip',
},
}
def __init__(self, command): def __init__(self, command):
self.command = command self.command = command
def get_package(self): def get_package(self):
try: try:
providers = RequiredToolNotFound.PROVIDERS[self.command] providers = EXTERNAL_TOOLS[self.command]
except KeyError: except KeyError:
return None return None
......
# -*- coding: utf-8 -*-
#
# diffoscope: in-depth comparison of files, archives, and directories
#
# Copyright © 2016 Chris Lamb <lamby@debian.org>
#
# diffoscope is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# diffoscope is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
EXTERNAL_TOOLS = {
'apktool': {
'debian': 'apktool',
},
'bzip2': {
'debian': 'bzip2',
'arch': 'bzip2',
},
'cbfstool': {
},
'cd-iccdump': {
'debian': 'colord',
'arch': 'colord',
'FreeBSD': 'colord',
},
'cmp': {
'debian': 'diffutils',
'arch': 'diffutils',
},
'cpio': {
'debian': 'cpio',
'arch': 'cpio',
},
'diff': {
'debian': 'diffutils',
'arch': 'diffutils',
},
'enjarify': {
'debian': 'enjarify',
'arch': 'enjarify',
},
'file': {
'debian': 'file',
'arch': 'file',
},
'find': {
'debian': 'findutils',
'arch': 'findutils',
},
'getfacl': {
'debian': 'acl',
'arch': 'acl',
},
'ghc': {
'debian': 'ghc',
'arch': 'ghc',
'FreeBSD': 'ghc',
},
'gpg': {
'debian': 'gnupg',
'arch': 'gnupg',
'FreeBSD': 'gnupg',
},
'gzip': {
'debian': 'gzip',
'arch': 'gzip',
},
'identify': {
'debian': 'imagemagick',
'arch': 'imagemagick',
},
'img2txt': {
'debian': 'caca-utils',
'arch': 'libcaca',
'FreeBSD': 'libcaca',
},
'isoinfo': {
'debian': 'genisoimage',
'arch': 'cdrkit',
'FreeBSD': 'cdrtools',
},
'javap': {
'debian': 'default-jdk-headless | default-jdk | java-sdk',
'arch': 'java-environment',
},
'js-beautify': {
'debian': 'jsbeautifier',
},
'llvm-bcanalyzer': {
'debian': 'llvm',
'arch': 'llvm',
},
'llvm-config': {
'debian': 'llvm',
'arch': 'llvm',
},
'llvm-dis': {
'debian': 'llvm',
'arch': 'llvm',
},
'ls': {
'debian': 'coreutils',
'arch': 'coreutils',
},
'lsattr': {
'debian': 'e2fsprogs',
'arch': 'e2fsprogs',
'FreeBSD': 'e2fsprogs',
},
'msgunfmt': {
'debian': 'gettext',
'arch': 'gettext',
'FreeBSD': 'gettext-tools',
},
'convert': {
'debian': 'imagemagick',
'arch': 'imagemagick',
},
'nm': {
'debian': 'binutils-multiarch',
'arch': 'binutils',
},
'objdump': {
'debian': 'binutils-multiarch',
'arch': 'binutils',
},
'pdftk': {
'debian': 'pdftk',
'FreeBSD': 'pdftk',
},
'pdftotext': {
'debian': 'poppler-utils',
'arch': 'poppler',
'FreeBSD': 'poppler-utils',
},
'pedump': {
'debian': 'mono-utils',
'arch': 'mono-tools',
'FreeBSD': 'mono',
},
'ppudump': {
'debian': 'fp-utils',
'arch': 'fpc',
'FreeBSD': 'fpc',
},
'ps2ascii': {
'debian': 'ghostscript',
'arch': 'ghostscript',
'FreeBSD': 'ghostscript9-base',
},
'readelf': {
'debian': 'binutils-multiarch',
'arch': 'binutils',
},
'rpm2cpio': {
'debian': 'rpm2cpio',
'arch': 'rpmextract',
'FreeBSD': 'rpm2cpio',
},
'showttf': {
'debian': 'fontforge-extras',
},
'sng': {
'debian': 'sng',
},
'ssh-keygen': {
'debian': 'openssh-client',
'arch': 'openssh',
},
'stat': {
'debian': 'coreutils',
'arch': 'coreutils',
},
'sqlite3': {
'debian': 'sqlite3',
'arch': 'sqlite',
'FreeBSD': 'sqlite3',
},
'tar': {
'debian': 'tar',
'arch': 'tar',
},
'unsquashfs': {
'debian': 'squashfs-tools',
'arch': 'squashfs-tools',
'FreeBSD': 'squashfs-tools',
},
'xxd': {
'debian': 'xxd | vim-common',
'arch': 'vim',
'FreeBSD': 'vim | vim-lite',
},
'xz': {
'debian': 'xz-utils',
'arch': 'xz',
},
'zipinfo': {
'debian': 'unzip',
'arch': 'unzip',
'FreeBSD': 'unzip',
},
}
...@@ -27,7 +27,6 @@ import argparse ...@@ -27,7 +27,6 @@ import argparse
import traceback import traceback
from . import VERSION from . import VERSION
from .exc import RequiredToolNotFound
from .tools import tool_required, OS_NAMES, get_current_os from .tools import tool_required, OS_NAMES, get_current_os
from .config import Config from .config import Config
from .locale import set_locale from .locale import set_locale
...@@ -36,6 +35,7 @@ from .progress import ProgressManager, Progress ...@@ -36,6 +35,7 @@ from .progress import ProgressManager, Progress
from .profiling import ProfileManager, profile from .profiling import ProfileManager, profile
from .tempfiles import clean_all_temp_files from .tempfiles import clean_all_temp_files
from .difference import Difference from .difference import Difference
from .external_tools import EXTERNAL_TOOLS
from .presenters.html import JQUERY_SYSTEM_LOCATIONS from .presenters.html import JQUERY_SYSTEM_LOCATIONS
from .presenters.utils import output_all from .presenters.utils import output_all
from .comparators.utils.compare import compare_root_paths from .comparators.utils.compare import compare_root_paths
...@@ -199,7 +199,7 @@ class ListToolsAction(argparse.Action): ...@@ -199,7 +199,7 @@ class ListToolsAction(argparse.Action):
for os in os_list: for os in os_list:
print("Available-in-{}-packages: ".format(OS_NAMES.get(os, os)), end='') print("Available-in-{}-packages: ".format(OS_NAMES.get(os, os)), end='')
print(', '.join(sorted(filter(None, { print(', '.join(sorted(filter(None, {
RequiredToolNotFound.PROVIDERS.get(k, {}).get(os, None) EXTERNAL_TOOLS.get(k, {}).get(os, None)
for k in tool_required.all for k in tool_required.all
})))) }))))
sys.exit(0) sys.exit(0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment