From 3b5a9f79add498edaf7dc2fdad395ae812601c82 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Mon, 22 Sep 2014 23:15:12 +0200 Subject: [PATCH] Support zpaq files. --- patoolib/__init__.py | 6 +++++- patoolib/programs/zpaq.py | 39 ++++++++++++++++++++++++++++++++++++ patoolib/util.py | 2 ++ tests/archives/test_zpaq.py | 32 +++++++++++++++++++++++++++++ tests/data/t.zpaq | Bin 0 -> 159 bytes tests/data/t.zpaq.foo | Bin 0 -> 159 bytes tests/test_mime.py | 3 +++ 7 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 patoolib/programs/zpaq.py create mode 100644 tests/archives/test_zpaq.py create mode 100644 tests/data/t.zpaq create mode 100644 tests/data/t.zpaq.foo diff --git a/patoolib/__init__.py b/patoolib/__init__.py index 70a8115..e4f0b8a 100644 --- a/patoolib/__init__.py +++ b/patoolib/__init__.py @@ -36,7 +36,7 @@ ArchiveFormats = ( 'bzip2', 'cab', 'chm', 'compress', 'cpio', 'deb', 'dms', 'flac', 'gzip', 'iso', 'lrzip', 'lzh', 'lzip', 'lzma', 'lzop', 'rar', 'rpm', 'rzip', 'shar', 'shn', 'tar', 'xz', - 'zip', 'zoo') + 'zip', 'zoo', 'zpaq') # Supported compressions (used with tar for example) # Note that all compressions must also be archive formats @@ -80,6 +80,7 @@ ArchiveMimetypes = { 'application/x-zip-compressed': 'zip', 'application/x-zoo': 'zoo', 'application/zip': 'zip', + 'application/zpaq': 'zpaq', 'audio/x-ape': 'ape', 'audio/x-shn': 'shn', 'audio/flac': 'flac', @@ -253,6 +254,9 @@ ArchivePrograms = { 'zoo': { None: ('zoo',), }, + 'zpaq': { + None: ('zpaq',), + }, 'dms': { 'extract': ('xdms',), 'list': ('xdms',), diff --git a/patoolib/programs/zpaq.py b/patoolib/programs/zpaq.py new file mode 100644 index 0000000..99be870 --- /dev/null +++ b/patoolib/programs/zpaq.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2014 Bastian Kleineidam +# +# This program 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. +# +# This program 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 this program. If not, see . +"""Archive commands for the zpaq program.""" +import os + +def extract_zpaq(archive, compression, cmd, verbosity, outdir): + """Extract a ZPAQ archive.""" + cmdlist = [cmd, 'x', os.path.abspath(archive)] + return (cmdlist, {'cwd': outdir}) + + +def list_zpaq(archive, compression, cmd, verbosity): + """List a ZPAQ archive.""" + return [cmd, 'l', archive] + + +def create_zpaq(archive, compression, cmd, verbosity, filenames): + """Create a ZPAQ archive.""" + cmdlist = [cmd, 'c', archive] + cmdlist.extend(filenames) + return cmdlist + + +def test_zpaq(archive, compression, cmd, verbosity): + """Test a ZPAQ archive.""" + return [cmd, 'l', archive] diff --git a/patoolib/util.py b/patoolib/util.py index 4f91d6f..d1e29c7 100644 --- a/patoolib/util.py +++ b/patoolib/util.py @@ -131,6 +131,7 @@ def add_mimedb_data(mimedb): add_mimetype(mimedb, 'application/x-iso9660-image', '.iso') add_mimetype(mimedb, 'application/zip', '.epub') add_mimetype(mimedb, 'application/zip', '.apk') + add_mimetype(mimedb, 'application/zpaq', '.zpaq') def add_mimetype(mimedb, mimetype, extension): @@ -353,6 +354,7 @@ FileText2Mime = { "Monkey's Audio": "audio/x-ape", "FLAC audio bitstream data": "audio/flac", "MS Windows HtmlHelp Data": "application/x-chm", + "ZPAQ stream": "application/zpaq", } def guess_mime_file_text (file_prog, filename): diff --git a/tests/archives/test_zpaq.py b/tests/archives/test_zpaq.py new file mode 100644 index 0000000..471623b --- /dev/null +++ b/tests/archives/test_zpaq.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2010-2014 Bastian Kleineidam +# +# This program 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. +# +# This program 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 this program. If not, see . +from . import ArchiveTest, Content +from .. import needs_program + +class TestZpaq(ArchiveTest): + + program = 'zpaq' + + @needs_program(program) + def test_zpaq(self): + self.archive_commands('t.zpaq', check=Content.Multifile) + + @needs_program('file') + @needs_program(program) + def test_zpaq_file(self): + self.archive_extract('t.zpaq.foo', check=Content.Multifile) + self.archive_test('t.zpaq.foo') + self.archive_list('t.zpaq.foo') diff --git a/tests/data/t.zpaq b/tests/data/t.zpaq new file mode 100644 index 0000000000000000000000000000000000000000..5e8c5b7fef3e2a94b8a15ec2336cd4a358618522 GIT binary patch literal 159 zcmb;l2xMe*WngAzVBlb8<=|!D5M<;KV&V{D<`8CK5tCpSU|^T{&mfrL#S+hGUBD%Y zfw`;;Bwf#Q6j(4YmgtpKlrR`EF#NaA{8lrM0SNw1I)85S-0+(sZ@Wb