diff --git a/doc/changelog.txt b/doc/changelog.txt index 1ad3d0d..8fd280a 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -1,3 +1,7 @@ +0.11 "" (released 4.10.2010) + + * Added support for the standalone 7za program. + 0.10 "Matchpoint" (released 10.4.2010) * Correct shell quoting of commandline arguments. Now files with diff --git a/patoolib/__init__.py b/patoolib/__init__.py index 2e2707c..0383998 100644 --- a/patoolib/__init__.py +++ b/patoolib/__init__.py @@ -97,22 +97,22 @@ ArchivePrograms = { 'list': ('nomarch',), }, 'bzip2': { - 'extract': ('pbzip2', 'bzip2', '7z'), - 'test': ('pbzip2', 'bzip2', '7z'), - 'create': ('pbzip2', 'bzip2', '7z'), - 'list': ('7z', 'echo',), + 'extract': ('pbzip2', 'bzip2', '7z', '7za'), + 'test': ('pbzip2', 'bzip2', '7z', '7za'), + 'create': ('pbzip2', 'bzip2', '7z', '7za'), + 'list': ('7z', '7za', 'echo',), }, 'tar': { None: ('tar', 'star',), }, 'zip': { - 'extract': ('unzip', '7z'), - 'list': ('unzip', '7z'), - 'test': ('unzip', '7z'), + 'extract': ('unzip', '7z', '7za'), + 'list': ('unzip', '7z', '7za'), + 'test': ('unzip', '7z', '7za'), 'create': ('zip',), }, 'gzip': { - None: ('gzip', '7z'), + None: ('gzip', '7z', '7za'), }, 'lzh': { None: ('lha',), @@ -130,13 +130,13 @@ ArchivePrograms = { 'create': ('lrzip',), }, 'compress': { - 'extract': ('gzip', '7z', 'uncompress.real'), - 'list': ('7z', 'echo',), - 'test': ('gzip', '7z'), + 'extract': ('gzip', '7z', '7za', 'uncompress.real'), + 'list': ('7z', '7za', 'echo',), + 'test': ('gzip', '7z', '7za'), 'create': ('compress',), }, '7z': { - None: ('7z',), + None: ('7z', '7za'), }, 'rar': { None: ('rar',), @@ -163,7 +163,7 @@ ArchivePrograms = { }, 'rpm': { 'extract': ('rpm2cpio', '7z'), - 'list': ('rpm', '7z'), + 'list': ('rpm', '7z', '7za'), 'test': ('rpm', '7z'), }, 'deb': { @@ -196,9 +196,11 @@ ArchivePrograms = { }, } -# only list those programs that have different python module names +# List those programs that have different python module names because of +# Python module naming restrictions. ProgramModules = { '7z': 'p7zip', + '7za': 'p7azip', 'uncompress.real': 'uncompress', 'dpkg-deb': 'dpkg', } diff --git a/patoolib/programs/p7azip.py b/patoolib/programs/p7azip.py new file mode 100644 index 0000000..19db07b --- /dev/null +++ b/patoolib/programs/p7azip.py @@ -0,0 +1,84 @@ +# -*- 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 7za program. + +From the man page: +7za is a stand-alone executable. 7za handles less archive formats than 7z, +but does not need any others. +""" + +def extract_7z (archive, encoding, cmd, **kwargs): + """Extract a 7z archive.""" + cmdlist = [cmd, 'x'] + if not kwargs['verbose']: + cmdlist.append('-bd') + cmdlist.extend(['-o%s' % kwargs['outdir'], '--', archive]) + return cmdlist + +extract_bzip2 = \ + extract_gzip = \ + extract_zip = \ + extract_compress = \ + extract_rar = \ + extract_cab = \ + extract_7z + +def list_7z (archive, encoding, cmd, **kwargs): + """List a 7z archive.""" + cmdlist = [cmd, 'l'] + if not kwargs['verbose']: + cmdlist.append('-bd') + cmdlist.append('--') + cmdlist.append(archive) + return cmdlist + +list_bzip2 = \ + list_gzip = \ + list_zip = \ + list_compress = \ + list_rar = \ + list_cab = \ + list_rpm = \ + list_7z + + +def test_7z (archive, encoding, cmd, **kwargs): + """Test a 7z archive.""" + cmdlist = [cmd, 't'] + if not kwargs['verbose']: + cmdlist.append('-bd') + cmdlist.append('--') + cmdlist.append(archive) + return cmdlist + +test_bzip2 = \ + test_gzip = \ + test_zip = \ + test_compress = \ + test_rar = \ + test_cab = \ + test_7z + + +def create_7z (archive, encoding, cmd, *args, **kwargs): + """Create a 7z archive.""" + cmdlist = [cmd, 'a'] + if not kwargs['verbose']: + cmdlist.append('-bd') + cmdlist.append('--') + cmdlist.append(archive) + cmdlist.extend(args) + return cmdlist diff --git a/setup.py b/setup.py index 34595a0..7eeb778 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ import os from distutils.core import setup AppName = "patool" -AppVersion = "0.10" +AppVersion = "0.11" MyName = "Bastian Kleineidam" MyEmail = "calvin@users.sourceforge.net" diff --git a/tests/test_archives.py b/tests/test_archives.py index 26b6a85..99c2abc 100644 --- a/tests/test_archives.py +++ b/tests/test_archives.py @@ -192,6 +192,42 @@ class TestArchives (ArchiveTest): self.archive_extract('t.rar') self.archive_test('t.rar') + @needs_program('7za') + def test_p7azip (self): + # unsupported actions of the 7za standalone program are commented out + self.program = '7za' + self.archive_commands('t .7z') + self.archive_list('t.gz') + self.archive_list('t .bz2') + self.archive_list('t.zip') + self.archive_list('t.jar') + self.archive_list('t.Z') + self.archive_list('t.cab') + #self.archive_list('t.arj') + #self.archive_list('t.cpio') + self.archive_list('t.rpm') + #self.archive_list('t.deb') + self.archive_extract('t.gz') + self.archive_extract('t .bz2') + self.archive_extract('t.zip') + self.archive_extract('t.jar') + self.archive_extract('t.Z') + self.archive_extract('t.cab') + #self.archive_extract('t.arj') + #self.archive_extract('t.cpio') + #self.archive_extract('t.rpm') + #self.archive_extract('t.deb') + self.archive_test('t.gz') + self.archive_test('t .bz2') + self.archive_test('t.zip') + self.archive_test('t.jar') + self.archive_test('t.Z') + self.archive_test('t.cab') + #self.archive_test('t.arj') + #self.archive_test('t.cpio') + #self.archive_test('t.rpm') + #self.archive_test('t.deb') + @needs_program('unrar') def test_unrar (self): self.program = 'unrar' diff --git a/tests/test_foo_archives.py b/tests/test_foo_archives.py index 62dc73e..a36790a 100644 --- a/tests/test_foo_archives.py +++ b/tests/test_foo_archives.py @@ -208,6 +208,42 @@ class TestArchives (ArchiveTest): self.archive_test('t.rpm.foo') self.archive_test('t.deb.foo') + @needs_program('file') + @needs_program('7za') + def test_p7zip_file (self): + self.program = '7za' + self.archive_commands('t.7z.foo', format="7z") + self.archive_list('t.gz.foo') + self.archive_list('t.bz2.foo') + self.archive_list('t.zip.foo') + self.archive_list('t.jar.foo') + self.archive_list('t.Z.foo') + self.archive_list('t.cab.foo') + #self.archive_list('t.arj.foo') + #self.archive_list('t.cpio.foo') + self.archive_list('t.rpm.foo') + #self.archive_list('t.deb.foo') + self.archive_extract('t.gz.foo') + self.archive_extract('t.bz2.foo') + self.archive_extract('t.zip.foo') + self.archive_extract('t.jar.foo') + self.archive_extract('t.Z.foo') + self.archive_extract('t.cab.foo') + #self.archive_extract('t.arj.foo') + #self.archive_extract('t.cpio.foo') + #self.archive_extract('t.rpm.foo') + #self.archive_extract('t.deb.foo') + self.archive_test('t.gz.foo') + self.archive_test('t.bz2.foo') + self.archive_test('t.zip.foo') + self.archive_test('t.jar.foo') + self.archive_test('t.Z.foo') + self.archive_test('t.cab.foo') + #self.archive_test('t.arj.foo') + #self.archive_test('t.cpio.foo') + #self.archive_test('t.rpm.foo') + #self.archive_test('t.deb.foo') + @needs_program('file') @needs_codec('7z', 'rar') def test_p7zip_rar (self):