Added support for the standalone 7za archiver in addition to 7z.

This commit is contained in:
Bastian Kleineidam 2010-10-04 19:21:01 +02:00
parent 23c9c09da8
commit 09c59ab3f0
6 changed files with 177 additions and 15 deletions

View File

@ -1,3 +1,7 @@
0.11 "" (released 4.10.2010)
* Added support for the standalone 7za program.
0.10 "Matchpoint" (released 10.4.2010) 0.10 "Matchpoint" (released 10.4.2010)
* Correct shell quoting of commandline arguments. Now files with * Correct shell quoting of commandline arguments. Now files with

View File

@ -97,22 +97,22 @@ ArchivePrograms = {
'list': ('nomarch',), 'list': ('nomarch',),
}, },
'bzip2': { 'bzip2': {
'extract': ('pbzip2', 'bzip2', '7z'), 'extract': ('pbzip2', 'bzip2', '7z', '7za'),
'test': ('pbzip2', 'bzip2', '7z'), 'test': ('pbzip2', 'bzip2', '7z', '7za'),
'create': ('pbzip2', 'bzip2', '7z'), 'create': ('pbzip2', 'bzip2', '7z', '7za'),
'list': ('7z', 'echo',), 'list': ('7z', '7za', 'echo',),
}, },
'tar': { 'tar': {
None: ('tar', 'star',), None: ('tar', 'star',),
}, },
'zip': { 'zip': {
'extract': ('unzip', '7z'), 'extract': ('unzip', '7z', '7za'),
'list': ('unzip', '7z'), 'list': ('unzip', '7z', '7za'),
'test': ('unzip', '7z'), 'test': ('unzip', '7z', '7za'),
'create': ('zip',), 'create': ('zip',),
}, },
'gzip': { 'gzip': {
None: ('gzip', '7z'), None: ('gzip', '7z', '7za'),
}, },
'lzh': { 'lzh': {
None: ('lha',), None: ('lha',),
@ -130,13 +130,13 @@ ArchivePrograms = {
'create': ('lrzip',), 'create': ('lrzip',),
}, },
'compress': { 'compress': {
'extract': ('gzip', '7z', 'uncompress.real'), 'extract': ('gzip', '7z', '7za', 'uncompress.real'),
'list': ('7z', 'echo',), 'list': ('7z', '7za', 'echo',),
'test': ('gzip', '7z'), 'test': ('gzip', '7z', '7za'),
'create': ('compress',), 'create': ('compress',),
}, },
'7z': { '7z': {
None: ('7z',), None: ('7z', '7za'),
}, },
'rar': { 'rar': {
None: ('rar',), None: ('rar',),
@ -163,7 +163,7 @@ ArchivePrograms = {
}, },
'rpm': { 'rpm': {
'extract': ('rpm2cpio', '7z'), 'extract': ('rpm2cpio', '7z'),
'list': ('rpm', '7z'), 'list': ('rpm', '7z', '7za'),
'test': ('rpm', '7z'), 'test': ('rpm', '7z'),
}, },
'deb': { '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 = { ProgramModules = {
'7z': 'p7zip', '7z': 'p7zip',
'7za': 'p7azip',
'uncompress.real': 'uncompress', 'uncompress.real': 'uncompress',
'dpkg-deb': 'dpkg', 'dpkg-deb': 'dpkg',
} }

View File

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

View File

@ -25,7 +25,7 @@ import os
from distutils.core import setup from distutils.core import setup
AppName = "patool" AppName = "patool"
AppVersion = "0.10" AppVersion = "0.11"
MyName = "Bastian Kleineidam" MyName = "Bastian Kleineidam"
MyEmail = "calvin@users.sourceforge.net" MyEmail = "calvin@users.sourceforge.net"

View File

@ -192,6 +192,42 @@ class TestArchives (ArchiveTest):
self.archive_extract('t.rar') self.archive_extract('t.rar')
self.archive_test('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') @needs_program('unrar')
def test_unrar (self): def test_unrar (self):
self.program = 'unrar' self.program = 'unrar'

View File

@ -208,6 +208,42 @@ class TestArchives (ArchiveTest):
self.archive_test('t.rpm.foo') self.archive_test('t.rpm.foo')
self.archive_test('t.deb.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_program('file')
@needs_codec('7z', 'rar') @needs_codec('7z', 'rar')
def test_p7zip_rar (self): def test_p7zip_rar (self):