/usr/lib/python3/dist-packages/diffoscope/comparators/__init__.py is in diffoscope 93ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | # -*- coding: utf-8 -*-
#
# diffoscope: in-depth comparison of files, archives, and directories
#
# Copyright © 2014-2015 Jérémy Bobbio <lunar@debian.org>
# © 2015 Helmut Grohne <helmut@subdivi.de>
# © 2017 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/>.
import logging
import importlib
logger = logging.getLogger(__name__)
class ComparatorManager(object):
COMPARATORS = (
('directory.Directory',),
('missing_file.MissingFile',),
('symlink.Symlink',),
('device.Device',),
('debian.DotChangesFile', 'debian_fallback.DotChangesFile'),
('debian.DotDscFile', 'debian_fallback.DotDscFile'),
('debian.DotBuildinfoFile', 'debian_fallback.DotBuildinfoFile'),
('deb.Md5sumsFile',),
('deb.DebDataTarFile',),
('elf.ElfSection',),
('binwalk.BinwalkFile',),
('ps.PsFile',),
('javascript.JavaScriptFile',),
('json.JSONFile',),
('xml.XMLFile',),
('text.TextFile',),
('bzip2.Bzip2File',),
('cpio.CpioFile',),
('deb.DebFile',),
('dex.DexFile',),
('elf.ElfFile',),
('macho.MachoFile',),
('fsimage.FsImageFile',),
('elf.StaticLibFile',),
('llvm.LlvmBitCodeFile',),
('sqlite.Sqlite3Database',),
('fonts.TtfFile',),
('fontconfig.FontconfigCacheFile',),
('gettext.MoFile',),
('ipk.IpkFile',),
('rust.RustObjectFile',),
('gnumeric.GnumericFile',),
('gzip.GzipFile',),
('haskell.HiFile',),
('icc.IccFile',),
('iso9660.Iso9660File',),
('java.ClassFile',),
('mono.MonoExeFile',),
('pdf.PdfFile',),
('png.PngFile',),
('ppu.PpuFile',),
('rdata.RdbFile',),
('rdata.RdsFile',),
('rpm.RpmFile', 'rpm_fallback.RpmFile'),
('squashfs.SquashfsFile',),
('ar.ArFile',),
('tar.TarFile',),
('xz.XzFile',),
('apk.ApkFile',),
('odt.OdtFile',),
('docx.DocxFile',),
('zip.ZipFile',),
('zip.MozillaZipFile',),
('image.JPEGImageFile',),
('image.ICOImageFile',),
('cbfs.CbfsFile',),
('git.GitIndexFile',),
('android.AndroidBootImgFile',),
('openssh.PublicKeyFile',),
('gif.GifFile',),
('pcap.PcapFile',),
('pgp.PgpFile',),
('dtb.DeviceTreeFile',),
('ogg.OggFile',),
('xsb.XsbFile',),
('berkeley_db.BerkeleyDBFile',),
)
_singleton = {}
def __init__(self):
self.__dict__ = self._singleton
if not self._singleton:
self.reload()
def reload(self):
self.classes = []
for xs in self.COMPARATORS:
for x in xs:
package, klass_name = x.rsplit('.', 1)
try:
mod = importlib.import_module(
'diffoscope.comparators.{}'.format(package)
)
except ImportError:
continue
self.classes.append(getattr(mod, klass_name))
break
else: # noqa
raise ImportError("Could not import {}{}".format(
"any of" if len(xs) > 1 else '',
', '.join(xs)
))
logger.debug("Loaded %d comparator classes", len(self.classes))
def get_descriptions(self):
for x in self.classes:
try:
yield x.DESCRIPTION
except AttributeError:
pass
|