Xz supports all archive commands.
This commit is contained in:
parent
89aea6aa43
commit
ba6d138615
|
@ -1,3 +1,11 @@
|
|||
0.14 "" (released xx.xx.2011)
|
||||
|
||||
* Handle CRX (.crx) files as ZIP archives. They have garbage at
|
||||
the beginning of the file, but some unzip programs can cope with
|
||||
that.
|
||||
* The xz program supports listing of XZ archives. Adjust the
|
||||
configuration accordingly.
|
||||
|
||||
0.13 "Megamind" (released 25.1.2011)
|
||||
|
||||
* Fix command argument order when extracting cpio archives.
|
||||
|
|
|
@ -188,10 +188,7 @@ ArchivePrograms = {
|
|||
'create': ('rzip',),
|
||||
},
|
||||
'xz': {
|
||||
'extract': ('xz',),
|
||||
'list': ('echo',),
|
||||
'test': ('xz',),
|
||||
'create': ('xz',),
|
||||
None: ('xz',),
|
||||
},
|
||||
'zoo': {
|
||||
None: ('zoo',),
|
||||
|
@ -415,12 +412,7 @@ def _handle_archive (archive, command, *args, **kwargs):
|
|||
if command == 'create' and os.path.exists(archive):
|
||||
raise util.PatoolError("archive `%s' already exists" % archive)
|
||||
program = config['program']
|
||||
# get python module for given archive program
|
||||
key = util.stripext(os.path.basename(program).lower())
|
||||
module = ProgramModules.get(key, key)
|
||||
# import archive handler (eg. patoolib.programs.star.extract_tar())
|
||||
exec "from patoolib.programs.%s import %s_%s as func" % (module, command, format)
|
||||
get_archive_cmdlist = locals()['func']
|
||||
get_archive_cmdlist = get_archive_cmdlist_func(program, command, format)
|
||||
# prepare keyword arguments for command list
|
||||
cmd_kwargs = dict(verbose=config['verbose'])
|
||||
origarchive = None
|
||||
|
@ -456,6 +448,20 @@ def _handle_archive (archive, command, *args, **kwargs):
|
|||
pass
|
||||
|
||||
|
||||
def get_archive_cmdlist_func (program, command, format):
|
||||
# get python module for given archive program
|
||||
key = util.stripext(os.path.basename(program).lower())
|
||||
module = ProgramModules.get(key, key)
|
||||
# import archive handler function (eg. patoolib.programs.star.extract_tar)
|
||||
args = (module, command, format)
|
||||
import_cmd = "from patoolib.programs.%s import %s_%s as func" % args
|
||||
try:
|
||||
exec import_cmd
|
||||
except ImportError:
|
||||
raise util.PatoolError('ImportError executing %r' % import_cmd)
|
||||
return locals()['func']
|
||||
|
||||
|
||||
def handle_archive (archive, command, *args, **kwargs):
|
||||
"""Handle archive file command; with nice error reporting."""
|
||||
try:
|
||||
|
|
|
@ -339,9 +339,7 @@ class TestArchives (ArchiveTest):
|
|||
@needs_program('xz')
|
||||
def test_xz (self):
|
||||
self.program = 'xz'
|
||||
self.archive_test('t .xz')
|
||||
self.archive_extract('t .xz')
|
||||
self.archive_create('t .xz', singlefile=True)
|
||||
self.archive_commands('t .xz', singlefile=True)
|
||||
|
||||
@needs_program('lha')
|
||||
def test_lha (self):
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2010-2011 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/>.
|
||||
from tests import ArchiveTest, needs_os, needs_program, needs_codec
|
||||
|
||||
class TestArchives (ArchiveTest):
|
||||
|
||||
@needs_codec('tar', 'lzma')
|
||||
def test_tar_lzma (self):
|
||||
self.program = 'tar'
|
||||
archive = 't.tar.lzma'
|
||||
self.archive_commands(archive)
|
||||
|
Loading…
Reference in New Issue