Commit b3a20511 authored by Chris Lamb's avatar Chris Lamb 💬

diffoscope/comparators: use relative package imports.

Signed-off-by: Chris Lamb's avatarChris Lamb <lamby@debian.org>
parent 5b8bc25d
......@@ -22,8 +22,9 @@ import os.path
import subprocess
from diffoscope import logger, tool_required, get_temporary_directory
from diffoscope.comparators.binary import File
from diffoscope.comparators.utils import Archive, get_compressed_content_name
from .binary import File
from .utils import Archive, get_compressed_content_name
class ApkContainer(Archive):
@property
......
......@@ -22,9 +22,10 @@ import re
from diffoscope import logger, tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Command
from diffoscope.comparators.binary import File
from diffoscope.comparators.libarchive import LibarchiveContainer, \
from .utils import Command
from .binary import File
from .libarchive import LibarchiveContainer, \
list_libarchive
......
......@@ -54,11 +54,11 @@ def hexdump_fallback(path):
def compare_binary_files(file1, file2, source=None):
import diffoscope.comparators.utils
from diffoscope.comparators.utils import Xxd
try:
return Difference.from_command(
diffoscope.comparators.utils.Xxd, file1.path, file2.path,
Xxd, file1.path, file2.path,
source=[file1.name, file2.name], has_internal_linenos=True)
except RequiredToolNotFound:
hexdump1 = hexdump_fallback(file1.path)
......
......@@ -23,8 +23,9 @@ import subprocess
import collections
from diffoscope import logger, tool_required
from diffoscope.comparators.utils import Archive, get_compressed_content_name
from diffoscope.comparators.binary import File
from .utils import Archive, get_compressed_content_name
from .binary import File
class Bzip2Container(Archive):
......
......@@ -25,8 +25,9 @@ import subprocess
from diffoscope import logger, tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Archive, Command
from diffoscope.comparators.binary import File
from .utils import Archive, Command
from .binary import File
class CbfsListing(Command):
......
......@@ -22,9 +22,10 @@ import re
from diffoscope import tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Command
from diffoscope.comparators.binary import File
from diffoscope.comparators.libarchive import LibarchiveContainer, list_libarchive
from .utils import Command
from .binary import File
from .libarchive import LibarchiveContainer, list_libarchive
class CpioContent(Command):
......
......@@ -21,12 +21,12 @@ import re
from diffoscope import logger
from diffoscope.difference import Difference
from diffoscope.comparators.tar import TarContainer
from diffoscope.comparators.utils import ArchiveMember
from diffoscope.comparators.binary import File
from diffoscope.comparators.libarchive import LibarchiveContainer, list_libarchive
import diffoscope.comparators
from . import specialize
from .tar import TarContainer
from .utils import ArchiveMember
from .binary import File
from .libarchive import LibarchiveContainer, list_libarchive
try:
from debian import deb822
......@@ -43,7 +43,7 @@ def get_build_id_map(container):
# too many irrelevant files
if not member_name.endswith('.deb'):
continue
diffoscope.comparators.specialize(member)
specialize(member)
if isinstance(member, DebFile) and member.control:
build_ids = member.control.get('Build-Ids', None)
if build_ids:
......@@ -59,21 +59,21 @@ class DebContainer(LibarchiveContainer):
def data_tar(self):
for name, member in self.get_members().items():
if DebContainer.RE_DATA_TAR.match(name):
diffoscope.comparators.specialize(member)
specialize(member)
if name.endswith('.tar'):
return member
else:
return diffoscope.comparators.specialize(member.as_container.get_member('content'))
return specialize(member.as_container.get_member('content'))
@property
def control_tar(self):
for name, member in self.get_members().items():
if DebContainer.RE_CONTROL_TAR.match(name):
diffoscope.comparators.specialize(member)
specialize(member)
if name.endswith('.tar'):
return member
else:
return diffoscope.comparators.specialize(member.as_container.get_member('content'))
return specialize(member.as_container.get_member('content'))
class DebFile(File):
......
......@@ -28,8 +28,9 @@ from debian.deb822 import Dsc
from diffoscope import logger
from diffoscope.changes import Changes
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Container
from diffoscope.comparators.binary import File
from .utils import Container
from .binary import File
DOT_CHANGES_FIELDS = [
......
......@@ -19,7 +19,7 @@
import re
from diffoscope.comparators.text import TextFile
from .text import TextFile
class DotChangesFile(TextFile):
......
......@@ -21,8 +21,9 @@ import os
from diffoscope import get_named_temporary_file
from diffoscope.difference import Difference
from diffoscope.comparators.utils import format_device
from diffoscope.comparators.binary import File, FilesystemFile
from .utils import format_device
from .binary import File, FilesystemFile
class Device(File):
......
......@@ -23,8 +23,9 @@ import subprocess
import collections
from diffoscope import logger, tool_required
from diffoscope.comparators.binary import File
from diffoscope.comparators.utils import Archive, get_compressed_content_name
from .binary import File
from .utils import Archive, get_compressed_content_name
class DexContainer(Archive):
......
......@@ -25,8 +25,9 @@ from diffoscope import logger, tool_required
from diffoscope.exc import RequiredToolNotFound
from diffoscope.progress import Progress
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Container, Command
from diffoscope.comparators.binary import FilesystemFile
from .utils import Container, Command
from .binary import FilesystemFile
from .compare import compare_files
......
......@@ -25,10 +25,11 @@ import collections
from diffoscope import tool_required, logger, get_named_temporary_file
from diffoscope.exc import OutputParsingError
from diffoscope.difference import Difference
from diffoscope.comparators.deb import DebFile, get_build_id_map
from diffoscope.comparators.utils import Command, Container
from diffoscope.comparators.binary import File
from diffoscope.comparators.libarchive import list_libarchive
from .deb import DebFile, get_build_id_map
from .utils import Command, Container
from .binary import File
from .libarchive import list_libarchive
class Readelf(Command):
......
......@@ -21,8 +21,9 @@ import re
from diffoscope import tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Command
from diffoscope.comparators.binary import File
from .utils import Command
from .binary import File
class Showttf(Command):
......
......@@ -23,8 +23,9 @@ import collections
from diffoscope import logger
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Archive
from diffoscope.comparators.binary import File
from .utils import Archive
from .binary import File
try:
import guestfs
......
......@@ -23,8 +23,9 @@ import re
from diffoscope import logger
from diffoscope import tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Command
from diffoscope.comparators.binary import File
from .utils import Command
from .binary import File
class Msgunfmt(Command):
......
......@@ -23,7 +23,8 @@ import struct
import binascii
from diffoscope.difference import Difference
from diffoscope.comparators.binary import File
from .binary import File
class GitIndexFile(File):
......
......@@ -24,7 +24,8 @@ import collections
from diffoscope import logger, tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Archive, get_compressed_content_name
from .utils import Archive, get_compressed_content_name
class GzipContainer(Archive):
......
......@@ -25,8 +25,9 @@ import subprocess
from diffoscope import tool_required, logger
from diffoscope.profiling import profile
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Command
from diffoscope.comparators.binary import File
from .utils import Command
from .binary import File
class ShowIface(Command):
......
......@@ -21,8 +21,9 @@ import re
from diffoscope import tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Command
from diffoscope.comparators.binary import File
from .utils import Command
from .binary import File
class Iccdump(Command):
......
......@@ -21,11 +21,13 @@ import re
from diffoscope import tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Command
from diffoscope.comparators.binary import File
from .utils import Command
from .binary import File
re_ansi_escapes = re.compile(r'\x1b[^m]*m')
class Img2Txt(Command):
@tool_required('img2txt')
def cmdline(self):
......
......@@ -20,7 +20,7 @@
import re
from diffoscope.comparators.gzip import GzipFile
from .gzip import GzipFile
class IpkFile(GzipFile):
......
......@@ -22,9 +22,10 @@ import subprocess
from diffoscope import tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Command
from diffoscope.comparators.binary import File
from diffoscope.comparators.libarchive import LibarchiveContainer
from .utils import Command
from .binary import File
from .libarchive import LibarchiveContainer
@tool_required('isoinfo')
......
......@@ -23,8 +23,9 @@ import os.path
from diffoscope import tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Command
from diffoscope.comparators.binary import File
from .utils import Command
from .binary import File
class Javap(Command):
......
......@@ -21,8 +21,9 @@ import re
from diffoscope import tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Command
from diffoscope.comparators.binary import File
from .utils import Command
from .binary import File
class JavaScriptBeautify(Command):
......
......@@ -17,12 +17,13 @@
# You should have received a copy of the GNU General Public License
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
from collections import OrderedDict
import re
import json
import collections
from diffoscope.difference import Difference
from diffoscope.comparators.binary import File
from .binary import File
class JSONFile(File):
......@@ -35,7 +36,7 @@ class JSONFile(File):
with open(file.path) as f:
try:
file.parsed = json.load(f, object_pairs_hook=OrderedDict)
file.parsed = json.load(f, object_pairs_hook=collections.OrderedDict)
except json.JSONDecodeError:
return False
......
......@@ -24,10 +24,11 @@ import ctypes
import libarchive
from diffoscope import logger, get_temporary_directory
from diffoscope.comparators.utils import Archive, ArchiveMember
from diffoscope.comparators.device import Device
from diffoscope.comparators.symlink import Symlink
from diffoscope.comparators.directory import Directory
from .utils import Archive, ArchiveMember
from .device import Device
from .symlink import Symlink
from .directory import Directory
# Monkeypatch libarchive-c (<< 2.2)
......
......@@ -20,8 +20,9 @@
from diffoscope import tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Command
from diffoscope.comparators.binary import File
from .utils import Command
from .binary import File
class LlvmBcAnalyzer(Command):
......
......@@ -23,8 +23,9 @@ import subprocess
from diffoscope import tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Command
from diffoscope.comparators.binary import File
from .utils import Command
from .binary import File
class Otool(Command):
......
......@@ -22,8 +22,9 @@ import re
from diffoscope import tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Command
from diffoscope.comparators.binary import File
from .utils import Command
from .binary import File
class Pedump(Command):
......
......@@ -21,8 +21,9 @@ import re
from diffoscope import tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Command
from diffoscope.comparators.binary import File
from .utils import Command
from .binary import File
class SSHKeyList(Command):
......
......@@ -21,8 +21,9 @@ import re
from diffoscope import tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Command
from diffoscope.comparators.binary import File
from .utils import Command
from .binary import File
class Pdftotext(Command):
......
......@@ -22,8 +22,9 @@ import functools
from diffoscope import tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Command
from diffoscope.comparators.binary import File
from .utils import Command
from .binary import File
class Sng(Command):
......
......@@ -26,8 +26,9 @@ import subprocess
from diffoscope import tool_required, logger
from diffoscope.profiling import profile
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Command
from diffoscope.comparators.binary import File
from .utils import Command
from .binary import File
class Ppudump(Command):
......
......@@ -22,8 +22,9 @@ import re
from diffoscope import tool_required, logger
from diffoscope.exc import RequiredToolNotFound
from diffoscope.difference import Difference
from diffoscope.comparators.text import TextFile
from diffoscope.comparators.utils import Command
from .text import TextFile
from .utils import Command
class Pstotext(Command):
......
......@@ -26,8 +26,9 @@ import subprocess
from diffoscope import logger, tool_required, get_temporary_directory
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Archive
from diffoscope.comparators.rpm_fallback import AbstractRpmFile
from .utils import Archive
from .rpm_fallback import AbstractRpmFile
def convert_header_field(io, header):
......
......@@ -19,7 +19,7 @@
import re
from diffoscope.comparators.binary import File
from .binary import File
class AbstractRpmFile(File):
......
......@@ -24,8 +24,8 @@ import collections
from diffoscope import logger, tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Archive, get_compressed_content_name
from .utils import Archive, get_compressed_content_name
RLIB_BYTECODE_OBJECT_V1_DATASIZE_OFFSET = 15
RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET = 23
......
......@@ -19,8 +19,9 @@
from diffoscope import tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.binary import File
from diffoscope.comparators.utils import Command
from .utils import Command
from .binary import File
class Sqlite3Dump(Command):
......
......@@ -25,11 +25,12 @@ import collections
from diffoscope import logger, tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Archive, ArchiveMember, Command
from diffoscope.comparators.binary import File
from diffoscope.comparators.device import Device
from diffoscope.comparators.symlink import Symlink
from diffoscope.comparators.directory import Directory
from .utils import Archive, ArchiveMember, Command
from .binary import File
from .device import Device
from .symlink import Symlink
from .directory import Directory
class SquashfsSuperblock(Command):
......
......@@ -21,8 +21,9 @@ import os
from diffoscope import logger, get_named_temporary_file
from diffoscope.difference import Difference
from diffoscope.comparators.binary import File
from diffoscope.comparators.utils import format_symlink
from .binary import File
from .utils import format_symlink
class Symlink(File):
......
......@@ -20,9 +20,9 @@
import re
from diffoscope.difference import Difference
from diffoscope.comparators.binary import File
from diffoscope.comparators.libarchive import LibarchiveContainer, \
list_libarchive
from .binary import File
from .libarchive import LibarchiveContainer, list_libarchive
class TarContainer(LibarchiveContainer):
pass
......
......@@ -21,7 +21,8 @@ import re
import codecs
from diffoscope.difference import Difference
from diffoscope.comparators.binary import File
from .binary import File
def order_only_difference(unified_diff):
......
......@@ -31,8 +31,9 @@ from diffoscope import logger, tool_required, get_temporary_directory
from diffoscope.config import Config
from diffoscope.progress import Progress
from diffoscope.profiling import profile
from diffoscope.comparators.binary import File, NonExistingFile
from . import specialize, perform_fuzzy_matching
from .binary import File, NonExistingFile
from .compare import compare_commented_files
class Command(object, metaclass=abc.ABCMeta):
......@@ -182,7 +183,7 @@ class Container(object, metaclass=abc.ABCMeta):
except KeyError:
return None
logger.debug('lookup_file(%s) -> %s', names, file)
diffoscope.comparators.specialize(file)
specialize(file)
if not remainings:
return file
container = file.as_container
......
......@@ -23,8 +23,9 @@ import subprocess
import collections
from diffoscope import logger, tool_required
from diffoscope.comparators.utils import Archive, get_compressed_content_name
from diffoscope.comparators.binary import File
from .utils import Archive, get_compressed_content_name
from .binary import File
class XzContainer(Archive):
......
......@@ -26,9 +26,10 @@ import contextlib
from diffoscope import tool_required
from diffoscope.difference import Difference
from diffoscope.comparators.utils import Archive, ArchiveMember, Command
from diffoscope.comparators.binary import File
from diffoscope.comparators.directory import Directory
from .utils import Archive, ArchiveMember, Command
from .binary import File
from .directory import Directory
class Zipinfo(Command):
......
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