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 0000000..581fb2b Binary files /dev/null and b/tests/data/t.zoo differ diff --git a/tests/data/t.zoo.foo b/tests/data/t.zoo.foo new file mode 100644 index 0000000..581fb2b Binary files /dev/null and b/tests/data/t.zoo.foo differ 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)