Added support for ZOO (.zoo) archives.

This commit is contained in:
Bastian Kleineidam 2010-03-21 15:39:02 +01:00
parent 29598b32ea
commit 554d273b08
11 changed files with 67 additions and 5 deletions

View File

@ -3,6 +3,7 @@
* Do not use the diff -B option when comparing archives. * Do not use the diff -B option when comparing archives.
* Improved documentation: explain commands in more detail. * Improved documentation: explain commands in more detail.
* Added support for RZIP (.rz) archives. * Added support for RZIP (.rz) archives.
* Added support for ZOO (.zoo) archives.
0.8 "Storage" (released 11.3.2010) 0.8 "Storage" (released 11.3.2010)

View File

@ -32,8 +32,8 @@ by the archive file extension.
ARC (.arc), ARJ (.arj), ARC (.arc), ARJ (.arj),
BZIP2 (.bz2), CAB (.cab), compress (.Z), CPIO (.cpio), DEB (.deb), GZIP (.gz), BZIP2 (.bz2), CAB (.cab), compress (.Z), CPIO (.cpio), DEB (.deb), GZIP (.gz),
LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo), 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) RPM (.rpm), RAR (.rar), RZIP (.rz), TAR (.tar), XZ (.xz), ZIP (.zip, .jar) and
formats. ZOO (.zoo) formats.
It relies on helper applications to handle those archive formats It relies on helper applications to handle those archive formats
(for example bzip2 for BZIP2 archives). (for example bzip2 for BZIP2 archives).
.SH EXAMPLES .SH EXAMPLES

View File

@ -24,7 +24,7 @@ ArchiveCommands = ('list', 'extract', 'test', 'create')
# Supported archive formats # Supported archive formats
ArchiveFormats = ('7z', 'ace', 'alzip', 'ar', 'arc', 'arj', 'bzip2', ArchiveFormats = ('7z', 'ace', 'alzip', 'ar', 'arc', 'arj', 'bzip2',
'cab', 'compress', 'cpio', 'deb', 'gzip', 'lrzip', 'lzh', 'lzip', 'lzma', '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) # Supported encodings (used with tar for example)
# Note that all encodings must also be archive formats # Note that all encodings must also be archive formats
@ -60,6 +60,7 @@ ArchiveMimetypes = {
'application/x-arc': 'arc', 'application/x-arc': 'arc',
'application/x-lrzip': 'lrzip', 'application/x-lrzip': 'lrzip',
'application/x-rzip': 'rzip', 'application/x-rzip': 'rzip',
'application/x-zoo': 'zoo',
} }
# List of programs supporting the given encoding # List of programs supporting the given encoding
@ -190,6 +191,9 @@ ArchivePrograms = {
'test': ('xz',), 'test': ('xz',),
'create': ('xz',), 'create': ('xz',),
}, },
'zoo': {
None: ('zoo',),
},
} }
# only list those programs that have different python module names # only list those programs that have different python module names

41
patoolib/programs/zoo.py Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
"""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

View File

@ -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-lha', '.lha', strict=False)
mimedb.add_type('application/x-lzh', '.lzh', 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-rzip', '.rz', strict=False)
mimedb.add_type('application/x-zoo', '.zoo', strict=False)
class PatoolError (StandardError): class PatoolError (StandardError):
@ -210,6 +211,7 @@ FileText2Mime = {
"current ar archive": "application/x-archive", "current ar archive": "application/x-archive",
"LHa ": "application/x-lha", "LHa ": "application/x-lha",
"ARC archive data": "application/x-arc", "ARC archive data": "application/x-arc",
"Zoo archive data": "application/x-zoo",
} }
def guess_mime_file_text (file_prog, filename): def guess_mime_file_text (file_prog, filename):

View File

@ -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), ARJ (.arj), BZIP2 (.bz2), CAB (.cab), compress (.Z), CPIO (.cpio),
DEB (.deb), GZIP (.gz), LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz), DEB (.deb), GZIP (.gz), LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz),
LZMA (.lzma), LZOP (.lzo), RPM (.rpm), RAR (.rar), RZIP (.rz), TAR (.tar), LZMA (.lzma), LZOP (.lzo), RPM (.rpm), RAR (.rar), RZIP (.rz), TAR (.tar),
XZ (.xz) and ZIP (.zip, .jar) formats. It relies on helper applications XZ (.xz), ZIP (.zip, .jar) and ZOO (.zoo) formats. It relies on helper
to handle those archive formats (for example bzip2 for BZIP2 archives).""", applications to handle those archive formats (for example bzip2 for
BZIP2 archives).""",
author = MyName, author = MyName,
author_email = MyEmail, author_email = MyEmail,
maintainer = MyName, maintainer = MyName,

BIN
tests/data/t.zoo Normal file

Binary file not shown.

BIN
tests/data/t.zoo.foo Normal file

Binary file not shown.

View File

@ -318,3 +318,8 @@ class TestArchives (ArchiveTest):
self.program = 'rzip' self.program = 'rzip'
self.archive_extract('t.txt.rz') self.archive_extract('t.txt.rz')
self.archive_create('t.txt.rz', singlefile=True) 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)

View File

@ -362,3 +362,8 @@ class TestArchives (ArchiveTest):
self.program = 'rzip' self.program = 'rzip'
self.archive_extract('t.txt.rz.foo') self.archive_extract('t.txt.rz.foo')
self.archive_create('t.txt.rz.foo', format="rzip", singlefile=True) 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)

View File

@ -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.lrz.foo", "application/x-lrzip", None)
self.mime_test_file("t.txt.rz", "application/x-rzip", 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.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): def test_mime_mimedb (self):
self.mime_test_mimedb("t.7z", "application/x-7z-compressed", None) 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.arc", "application/x-arc", None)
self.mime_test_mimedb("t.lrz", "application/x-lrzip", 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.rz", "application/x-rzip", None)
self.mime_test_mimedb("t.zoo", "application/x-zoo", None)