From 554d273b08db05e2d7f9879d4e32415120bd2a5b Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Sun, 21 Mar 2010 15:39:02 +0100 Subject: [PATCH] Added support for ZOO (.zoo) archives. --- doc/changelog.txt | 1 + doc/patool.1 | 4 ++-- patoolib/__init__.py | 6 +++++- patoolib/programs/zoo.py | 41 +++++++++++++++++++++++++++++++++++++ patoolib/util.py | 2 ++ setup.py | 5 +++-- tests/data/t.zoo | Bin 0 -> 246 bytes tests/data/t.zoo.foo | Bin 0 -> 246 bytes tests/test_archives.py | 5 +++++ tests/test_foo_archives.py | 5 +++++ tests/test_mime.py | 3 +++ 11 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 patoolib/programs/zoo.py create mode 100644 tests/data/t.zoo create mode 100644 tests/data/t.zoo.foo diff --git a/doc/changelog.txt b/doc/changelog.txt index 1bcda6e..94a8792 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -3,6 +3,7 @@ * Do not use the diff -B option when comparing archives. * Improved documentation: explain commands in more detail. * Added support for RZIP (.rz) archives. + * Added support for ZOO (.zoo) archives. 0.8 "Storage" (released 11.3.2010) diff --git a/doc/patool.1 b/doc/patool.1 index 46909ec..ff8877b 100644 --- a/doc/patool.1 +++ b/doc/patool.1 @@ -32,8 +32,8 @@ by the archive file extension. ARC (.arc), ARJ (.arj), BZIP2 (.bz2), CAB (.cab), compress (.Z), CPIO (.cpio), DEB (.deb), GZIP (.gz), LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo), -RPM (.rpm), RAR (.rar), RZIP (.rz), TAR (.tar), XZ (.xz) and ZIP (.zip, .jar) -formats. +RPM (.rpm), RAR (.rar), RZIP (.rz), TAR (.tar), XZ (.xz), ZIP (.zip, .jar) and +ZOO (.zoo) formats. It relies on helper applications to handle those archive formats (for example bzip2 for BZIP2 archives). .SH EXAMPLES diff --git a/patoolib/__init__.py b/patoolib/__init__.py index 042a87f..460cc9c 100644 --- a/patoolib/__init__.py +++ b/patoolib/__init__.py @@ -24,7 +24,7 @@ ArchiveCommands = ('list', 'extract', 'test', 'create') # Supported archive formats ArchiveFormats = ('7z', 'ace', 'alzip', 'ar', 'arc', 'arj', 'bzip2', 'cab', 'compress', 'cpio', 'deb', 'gzip', 'lrzip', 'lzh', 'lzip', 'lzma', - 'lzop', 'rar', 'rpm', 'rzip', 'tar', 'xz', 'zip') + 'lzop', 'rar', 'rpm', 'rzip', 'tar', 'xz', 'zip', 'zoo') # Supported encodings (used with tar for example) # Note that all encodings must also be archive formats @@ -60,6 +60,7 @@ ArchiveMimetypes = { 'application/x-arc': 'arc', 'application/x-lrzip': 'lrzip', 'application/x-rzip': 'rzip', + 'application/x-zoo': 'zoo', } # List of programs supporting the given encoding @@ -190,6 +191,9 @@ ArchivePrograms = { 'test': ('xz',), 'create': ('xz',), }, + 'zoo': { + None: ('zoo',), + }, } # only list those programs that have different python module names diff --git a/patoolib/programs/zoo.py b/patoolib/programs/zoo.py new file mode 100644 index 0000000..20e4354 --- /dev/null +++ b/patoolib/programs/zoo.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2010 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 zoo program.""" +import os + +def extract_zoo (archive, encoding, cmd, **kwargs): + """Extract a ZOO archive.""" + # Since extracted files will be placed in the current directory, + # the cwd argument has to be the output directory. + cmdlist = [cmd, '-extract', os.path.abspath(archive)] + return (cmdlist, {'cwd': kwargs['outdir']}) + + +def list_zoo (archive, encoding, cmd, **kwargs): + """List a ZOO archive.""" + return [cmd, '-list', archive] + + +def test_zoo (archive, encoding, cmd, **kwargs): + """Test a ZOO archive.""" + return [cmd, '-test', archive] + + +def create_zoo (archive, encoding, cmd, *args, **kwargs): + """Create a ZOO archive.""" + cmdlist = [cmd, '-add', archive] + cmdlist.extend(args) + return cmdlist diff --git a/patoolib/util.py b/patoolib/util.py index 51c8745..7c23ad3 100644 --- a/patoolib/util.py +++ b/patoolib/util.py @@ -48,6 +48,7 @@ mimedb.add_type('application/x-lrzip', '.lrz', strict=False) mimedb.add_type('application/x-lha', '.lha', strict=False) mimedb.add_type('application/x-lzh', '.lzh', strict=False) mimedb.add_type('application/x-rzip', '.rz', strict=False) +mimedb.add_type('application/x-zoo', '.zoo', strict=False) class PatoolError (StandardError): @@ -210,6 +211,7 @@ FileText2Mime = { "current ar archive": "application/x-archive", "LHa ": "application/x-lha", "ARC archive data": "application/x-arc", + "Zoo archive data": "application/x-zoo", } def guess_mime_file_text (file_prog, filename): diff --git a/setup.py b/setup.py index 4b74964..1006b1b 100644 --- a/setup.py +++ b/setup.py @@ -50,8 +50,9 @@ patool supports 7z (.7z), ACE (.ace), ALZIP (.alz), AR (.a), ARC (.arc), ARJ (.arj), BZIP2 (.bz2), CAB (.cab), compress (.Z), CPIO (.cpio), DEB (.deb), GZIP (.gz), LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo), RPM (.rpm), RAR (.rar), RZIP (.rz), TAR (.tar), -XZ (.xz) and ZIP (.zip, .jar) formats. It relies on helper applications -to handle those archive formats (for example bzip2 for BZIP2 archives).""", +XZ (.xz), ZIP (.zip, .jar) and ZOO (.zoo) formats. It relies on helper +applications to handle those archive formats (for example bzip2 for +BZIP2 archives).""", author = MyName, author_email = MyEmail, maintainer = MyName, diff --git a/tests/data/t.zoo b/tests/data/t.zoo new file mode 100644 index 0000000000000000000000000000000000000000..581fb2b6e9797dc17dae704918c604b677ffe87d GIT binary patch literal 246 zcma#@_g65|Gc-_eEK1JEEKAjsVqmzl{K#J|1_p*}|NsAIVqgTafPfh!%EV9tWEKK( zsZEgYm6gmO2_S~50kV=3i}Xq=K&pU%i-Dn_3&dE!=l~=gG?g_NOpLf7ChY@?>;~ds b8(BMSCZ*-)qnPBr2&fpVNg#1jz@KISl#eRX literal 0 HcmV?d00001 diff --git a/tests/data/t.zoo.foo b/tests/data/t.zoo.foo new file mode 100644 index 0000000000000000000000000000000000000000..581fb2b6e9797dc17dae704918c604b677ffe87d GIT binary patch literal 246 zcma#@_g65|Gc-_eEK1JEEKAjsVqmzl{K#J|1_p*}|NsAIVqgTafPfh!%EV9tWEKK( zsZEgYm6gmO2_S~50kV=3i}Xq=K&pU%i-Dn_3&dE!=l~=gG?g_NOpLf7ChY@?>;~ds b8(BMSCZ*-)qnPBr2&fpVNg#1jz@KISl#eRX literal 0 HcmV?d00001 diff --git a/tests/test_archives.py b/tests/test_archives.py index ca6c189..ea33791 100644 --- a/tests/test_archives.py +++ b/tests/test_archives.py @@ -318,3 +318,8 @@ class TestArchives (ArchiveTest): self.program = 'rzip' self.archive_extract('t.txt.rz') self.archive_create('t.txt.rz', singlefile=True) + + @needs_program('zoo') + def test_zoo (self): + self.program = 'zoo' + self.archive_commands('t.zoo', singlefile=True) diff --git a/tests/test_foo_archives.py b/tests/test_foo_archives.py index 1fbe234..62dc73e 100644 --- a/tests/test_foo_archives.py +++ b/tests/test_foo_archives.py @@ -362,3 +362,8 @@ class TestArchives (ArchiveTest): self.program = 'rzip' self.archive_extract('t.txt.rz.foo') self.archive_create('t.txt.rz.foo', format="rzip", singlefile=True) + + @needs_program('zoo') + def test_zoo (self): + self.program = 'zoo' + self.archive_commands('t.zoo.foo', format="zoo", singlefile=True) diff --git a/tests/test_mime.py b/tests/test_mime.py index 90d53ca..8cf554b 100644 --- a/tests/test_mime.py +++ b/tests/test_mime.py @@ -120,6 +120,8 @@ class TestMime (unittest.TestCase): #self.mime_test_file("t.txt.lrz.foo", "application/x-lrzip", None) self.mime_test_file("t.txt.rz", "application/x-rzip", None) self.mime_test_file("t.txt.rz.foo", "application/x-rzip", None) + self.mime_test_file("t.zoo", "application/x-zoo", None) + self.mime_test_file("t.zoo.foo", "application/x-zoo", None) def test_mime_mimedb (self): self.mime_test_mimedb("t.7z", "application/x-7z-compressed", None) @@ -157,3 +159,4 @@ class TestMime (unittest.TestCase): self.mime_test_mimedb("t.arc", "application/x-arc", None) self.mime_test_mimedb("t.lrz", "application/x-lrzip", None) self.mime_test_mimedb("t.rz", "application/x-rzip", None) + self.mime_test_mimedb("t.zoo", "application/x-zoo", None)