cpio.py 1.38 KB
Newer Older
1 2
# -*- coding: utf-8 -*-
#
Jérémy Bobbio's avatar
Jérémy Bobbio committed
3
# diffoscope: in-depth comparison of files, archives, and directories
4
#
Reiner Herrmann's avatar
Reiner Herrmann committed
5
# Copyright © 2015 Reiner Herrmann <reiner@reiner-h.de>
6
#             2015 Jérémy Bobbio <lunar@debian.org>
7
#
Jérémy Bobbio's avatar
Jérémy Bobbio committed
8
# diffoscope is free software: you can redistribute it and/or modify
9 10 11 12
# 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.
#
Jérémy Bobbio's avatar
Jérémy Bobbio committed
13
# diffoscope is distributed in the hope that it will be useful,
14 15 16 17 18
# 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
19
# along with diffoscope.  If not, see <https://www.gnu.org/licenses/>.
20

21
import re
Chris Lamb's avatar
Chris Lamb committed
22 23

from diffoscope.difference import Difference
24

25
from .utils.file import File
26
from .utils.libarchive import LibarchiveContainer, list_libarchive
27

28 29

class CpioFile(File):
30
    DESCRIPTION = "cpio archives"
31
    CONTAINER_CLASS = LibarchiveContainer
32
    FILE_TYPE_RE = re.compile(r'\bcpio archive\b')
33

34
    def compare_details(self, other, source=None):
Chris Lamb's avatar
Chris Lamb committed
35 36 37 38 39 40 41
        return [Difference.from_text_readers(
            list_libarchive(self.path),
            list_libarchive(other.path),
            self.path,
            other.path,
            source="file list",
        )]