[diffoscope] 03/03: Add informative output for container type and file list.
Maria Glukhova
siamezzze-guest at moszumanska.debian.org
Sun Jan 22 19:01:20 CET 2017
This is an automated email from the git hooks/post-receive script.
siamezzze-guest pushed a commit to branch siamezzze/containers
in repository diffoscope.
commit 5a5c341d92e0b70e14ae433e88d3817ea6f57d6e
Author: Maria Glukhova <siamezzze at gmail.com>
Date: Sun Jan 22 19:45:15 2017 +0200
Add informative output for container type and file list.
---
diffoscope/comparators/utils/compare.py | 10 ++++------
diffoscope/comparators/utils/container.py | 9 +++++++++
tests/data/containers_filelist_expected_diff | 6 +++---
tests/data/containers_types_expected_diff | 4 ++--
tests/data/nested_containers_types_expected_diff | 4 ++--
5 files changed, 20 insertions(+), 13 deletions(-)
diff --git a/diffoscope/comparators/utils/compare.py b/diffoscope/comparators/utils/compare.py
index 83ae7a1..0f30187 100644
--- a/diffoscope/comparators/utils/compare.py
+++ b/diffoscope/comparators/utils/compare.py
@@ -33,8 +33,6 @@ from ..missing_file import MissingFile
from .command import Command
from .specialize import specialize
-from .archive import Archive
-from .libarchive import LibarchiveContainer
try:
import tlsh
@@ -69,15 +67,15 @@ def compare_containers(file1, file2, source=None):
container1 = file1.as_container
container2 = file2.as_container
details.extend([Difference.from_text(
- container1.__class__.__name__,
- container2.__class__.__name__,
+ file1.magic_file_type,
+ file2.magic_file_type,
file1.name,
file2.name,
source="container type"
)])
details.extend([Difference.from_text(
- "\n".join(sorted(container1.get_member_names())) + "\n",
- "\n".join(sorted(container2.get_member_names())) + "\n",
+ "\n".join(container1.get_member_names_nested()) + "\n",
+ "\n".join(container2.get_member_names_nested()) + "\n",
file1.name,
file2.name,
source="file list"
diff --git a/diffoscope/comparators/utils/container.py b/diffoscope/comparators/utils/container.py
index 52e2f92..30f145b 100644
--- a/diffoscope/comparators/utils/container.py
+++ b/diffoscope/comparators/utils/container.py
@@ -85,6 +85,15 @@ class Container(object, metaclass=abc.ABCMeta):
for name in self.get_member_names():
yield name, self.get_member(name)
+ def get_member_names_nested(self):
+ member_names = self.get_member_names()
+ nested_container = self.get_nested_container()
+ if nested_container:
+ member_names += \
+ ['[%s] %s' % (nested_container.source.name, member) for member
+ in sorted(nested_container.get_member_names())]
+ return member_names
+
def get_nested_container(self):
return None
diff --git a/tests/data/containers_filelist_expected_diff b/tests/data/containers_filelist_expected_diff
index 68ad9c3..8692ed0 100644
--- a/tests/data/containers_filelist_expected_diff
+++ b/tests/data/containers_filelist_expected_diff
@@ -1,8 +1,8 @@
@@ -1,5 +1,5 @@
-t0/
-t0/t00/
-+t0
-+t0/t00
t0/t00/test2
- t0/test1
++t0/t00
t0/test2.lnk
+ t0/test1
++t0
diff --git a/tests/data/containers_types_expected_diff b/tests/data/containers_types_expected_diff
index a430c2c..f06206d 100644
--- a/tests/data/containers_types_expected_diff
+++ b/tests/data/containers_types_expected_diff
@@ -1,3 +1,3 @@
@@ -1 +1 @@
--TarContainer
-+LibarchiveContainer
+-POSIX tar archive (GNU)
++cpio archive
diff --git a/tests/data/nested_containers_types_expected_diff b/tests/data/nested_containers_types_expected_diff
index 329fc94..ee1acbe 100644
--- a/tests/data/nested_containers_types_expected_diff
+++ b/tests/data/nested_containers_types_expected_diff
@@ -1,3 +1,3 @@
@@ -1 +1 @@
--GzipContainer
-+Bzip2Container
+-gzip compressed data, was "test0.tar", last modified: Sat Jan 21 02:39:53 2017, from Unix
++bzip2 compressed data, block size = 900k
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git
More information about the diffoscope
mailing list