diff --git a/doc/changelog.txt b/doc/changelog.txt index 7762226..2105d9f 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -1,6 +1,6 @@ 0.7 "" (released xx.xx.xxxx) - * + * Added support for ALZIP (.alz) archives. 0.6 "Waking Ned" (released 6.3.2010) diff --git a/doc/patool.1 b/doc/patool.1 index 7615314..12b62e8 100644 --- a/doc/patool.1 +++ b/doc/patool.1 @@ -26,11 +26,10 @@ files without having to remember a myriad of programs and options. The archive format is determined by the file(1) program and as a fallback by the archive file extension. .PP -\fBpatool\fP supports 7z (.7z), ACE (.ace), AR (.a), ZIP (.zip, .jar), -GZIP (.gz), compress (.Z), -BZIP2 (.bz2), TAR (.tar), ARJ (.arj), CAB (.cab), CPIO (.cpio), -RPM (.rpm), DEB (.deb), LZH (.lha, .lzh), LZIP (.lz), LZOP (.lzo), -LZMA (.lzma), RAR (.rar) and XZ (.xz) formats. +\fBpatool\fP supports 7z (.7z), ACE (.ace), ALZIP (.alz), AR (.a), ARJ (.arj), +BZIP2 (.bz2), CAB (.cab), compress (.Z), CPIO (.cpio), DEB (.deb), GZIP (.gz), +LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo), RPM (.rpm), +RAR (.rar), 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). .SH EXAMPLES diff --git a/doc/patool.txt b/doc/patool.txt index eb24bd9..daa5fed 100644 --- a/doc/patool.txt +++ b/doc/patool.txt @@ -18,12 +18,12 @@ DESCRIPTION The archive format is determined by the file(1) program and as a fall‐ back by the archive file extension. - patool supports 7z (.7z), ACE (.ace), AR (.a), ZIP (.zip, .jar), GZIP - (.gz), compress (.Z), BZIP2 (.bz2), TAR (.tar), ARJ (.arj), CAB (.cab), - CPIO (.cpio), RPM (.rpm), DEB (.deb), LZIP (.lz), LZOP (.lzo), LZMA - (.lzma), RAR (.rar) and XZ (.xz) formats. It relies on helper applica‐ - tions to handle those archive formats (for example bzip2 for BZIP2 ar‐ - chives). + patool supports 7z (.7z), ACE (.ace), ALZIP (.alz), AR (.a), ARJ + (.arj), BZIP2 (.bz2), CAB (.cab), compress (.Z), CPIO (.cpio), DEB + (.deb), GZIP (.gz), LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP + (.lzo), RPM (.rpm), RAR (.rar), TAR (.tar), XZ (.xz) and ZIP (.zip, + .jar) formats. It relies on helper applications to handle those ar‐ + chive formats (for example bzip2 for BZIP2 archives). EXAMPLES patool extract archive.zip otherarchive.rar diff --git a/patoolib/__init__.py b/patoolib/__init__.py index 2401be5..8b64ce8 100644 --- a/patoolib/__init__.py +++ b/patoolib/__init__.py @@ -24,7 +24,7 @@ ArchiveCommands = ('list', 'extract', 'test', 'create') # Supported archive formats ArchiveFormats = ('gzip', 'bzip2', 'tar', 'zip', 'compress', '7z', 'rar', 'cab', 'arj', 'cpio', 'rpm', 'deb', 'lzop', 'lzma', 'xz', 'lzip', 'ace', - 'ar', 'lzh') + 'ar', 'lzh', 'alzip') # Supported encodings (used with tar for example) # Note that all encodings must also be archive formats @@ -56,6 +56,7 @@ ArchiveMimetypes = { 'application/x-archive': 'ar', 'application/x-lha': 'lzh', 'application/x-lzh': 'lzh', + 'application/x-alzip': 'alzip', } # List of programs supporting the given encoding @@ -77,6 +78,11 @@ ArchivePrograms = { 'test': ('unace',), 'list': ('unace',), }, + 'alzip': { + 'extract': ('unalz',), + 'test': ('unalz',), + 'list': ('unalz',), + }, 'ar': { None: ('ar',), }, diff --git a/patoolib/programs/unalz.py b/patoolib/programs/unalz.py new file mode 100644 index 0000000..dbdcd6a --- /dev/null +++ b/patoolib/programs/unalz.py @@ -0,0 +1,27 @@ +# -*- 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 unalz program.""" + +def extract_alzip (archive, encoding, cmd, **kwargs): + """Extract a ALZIP archive.""" + return [cmd, '-d', kwargs['outdir'], archive] + + +def list_alzip (archive, encoding, cmd, **kwargs): + """List a ALZIP archive.""" + return [cmd, '-l', archive] + +test_alzip = list_alzip diff --git a/patoolib/util.py b/patoolib/util.py index ae106f0..ca68f02 100644 --- a/patoolib/util.py +++ b/patoolib/util.py @@ -42,6 +42,7 @@ mimedb.add_type('application/x-debian-package', '.deb', strict=False) mimedb.add_type('application/x-ace', '.ace', strict=False) # Since .a is already a common type, strict=True must be used. mimedb.add_type('application/x-archive', '.a', strict=True) +mimedb.add_type('application/x-alzip', '.alz', strict=False) class PatoolError (StandardError): diff --git a/tests/data/t.alz b/tests/data/t.alz new file mode 100644 index 0000000..5a8dd1a Binary files /dev/null and b/tests/data/t.alz differ diff --git a/tests/data/t.alz.foo b/tests/data/t.alz.foo new file mode 100644 index 0000000..5a8dd1a Binary files /dev/null and b/tests/data/t.alz.foo differ diff --git a/tests/test_archives.py b/tests/test_archives.py index 3d7ba97..7205fff 100644 --- a/tests/test_archives.py +++ b/tests/test_archives.py @@ -272,6 +272,13 @@ class TestArchives (ArchiveTest): self.archive_extract('t.txt.lz') self.archive_create('t.txt.lz', singlefile=True) + @needs_program('unalz') + def test_unalz (self): + self.program = 'unalz' + self.archive_test('t.alz') + self.archive_list('t.alz') + self.archive_extract('t.alz') + @needs_program('xz') def test_xz (self): self.program = 'xz' diff --git a/tests/test_foo_archives.py b/tests/test_foo_archives.py index 4171193..a1dad4d 100644 --- a/tests/test_foo_archives.py +++ b/tests/test_foo_archives.py @@ -326,3 +326,12 @@ class TestArchives (ArchiveTest): def test_lha (self): self.program = 'lha' self.archive_commands('t.lha.foo', format="lzh") + + # file(1) does not recognize .alz files + #@needs_program('file') + #@needs_program('unalz') + #def test_unalz (self): + # self.program = 'unalz' + # self.archive_test('t.alz.foo') + # self.archive_list('t.alz.foo') + # self.archive_extract('t.alz.foo') diff --git a/tests/test_mime.py b/tests/test_mime.py index 127ad1b..fec6161 100644 --- a/tests/test_mime.py +++ b/tests/test_mime.py @@ -106,6 +106,9 @@ class TestMime (unittest.TestCase): self.mime_test_file("t.lha", "application/x-lha", None) self.mime_test_file("t.lzh", "application/x-lha", None) self.mime_test_file("t.lha.foo", "application/x-lha", None) + # file(1) does not recognize .alz files + #self.mime_test_mimedb("t.alz", "application/x-alzip", None) + #self.mime_test_mimedb("t.alz.foo", "application/x-alzip", None) def test_mime_mimedb (self): @@ -140,3 +143,4 @@ class TestMime (unittest.TestCase): self.mime_test_mimedb("t.a", "application/x-archive", None) self.mime_test_mimedb("t.lha", "application/x-lha", None) self.mime_test_mimedb("t.lzh", "application/x-lzh", None) + self.mime_test_mimedb("t.alz", "application/x-alzip", None)