[diffoscope] 01/03: Move external tool definitions out of misleading "exceptions" module.

Chris Lamb chris at chris-lamb.co.uk
Mon Jan 16 06:38:57 CET 2017


This is an automated email from the git hooks/post-receive script.

lamby pushed a commit to branch master
in repository diffoscope.

commit 48af8e61ef10b8f5a467463d685971b76149bbae
Author: Chris Lamb <lamby at debian.org>
Date:   Mon Jan 16 14:57:42 2017 +1100

    Move external tool definitions out of misleading "exceptions" module.
---
 diffoscope/exc.py            | 197 +---------------------------------------
 diffoscope/external_tools.py | 211 +++++++++++++++++++++++++++++++++++++++++++
 diffoscope/main.py           |   4 +-
 3 files changed, 215 insertions(+), 197 deletions(-)

diff --git a/diffoscope/exc.py b/diffoscope/exc.py
index 5a8e483..f9aa2ec 100644
--- a/diffoscope/exc.py
+++ b/diffoscope/exc.py
@@ -19,6 +19,7 @@
 # along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
 
 from .tools import get_current_os
+from .external_tools import EXTERNAL_TOOLS
 
 
 class OutputParsingError(Exception):
@@ -27,206 +28,12 @@ class OutputParsingError(Exception):
         self.object_class = object.__class__
 
 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):
         self.command = command
 
     def get_package(self):
-
         try:
-            providers = RequiredToolNotFound.PROVIDERS[self.command]
+            providers = EXTERNAL_TOOLS[self.command]
         except KeyError:
             return None
 
diff --git a/diffoscope/external_tools.py b/diffoscope/external_tools.py
new file mode 100644
index 0000000..fbdbf9f
--- /dev/null
+++ b/diffoscope/external_tools.py
@@ -0,0 +1,211 @@
+# -*- coding: utf-8 -*-
+#
+# diffoscope: in-depth comparison of files, archives, and directories
+#
+# Copyright © 2016 Chris Lamb <lamby at 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',
+    },
+}
diff --git a/diffoscope/main.py b/diffoscope/main.py
index c1b9c2e..c374d8d 100644
--- a/diffoscope/main.py
+++ b/diffoscope/main.py
@@ -27,7 +27,6 @@ import argparse
 import traceback
 
 from . import VERSION
-from .exc import RequiredToolNotFound
 from .tools import tool_required, OS_NAMES, get_current_os
 from .config import Config
 from .locale import set_locale
@@ -36,6 +35,7 @@ from .progress import ProgressManager, Progress
 from .profiling import ProfileManager, profile
 from .tempfiles import clean_all_temp_files
 from .difference import Difference
+from .external_tools import EXTERNAL_TOOLS
 from .presenters.html import JQUERY_SYSTEM_LOCATIONS
 from .presenters.utils import output_all
 from .comparators.utils.compare import compare_root_paths
@@ -199,7 +199,7 @@ class ListToolsAction(argparse.Action):
         for os in os_list:
             print("Available-in-{}-packages: ".format(OS_NAMES.get(os, os)), end='')
             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
             }))))
         sys.exit(0)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list