Added support for LRZIP (.lrz) files.

This commit is contained in:
Bastian Kleineidam 2010-03-08 19:58:39 +01:00
parent 2f5addad3f
commit 37fa891535
12 changed files with 93 additions and 15 deletions

View File

@ -1,6 +1,7 @@
0.7 "" (released xx.xx.xxxx)
0.7 "3000 Miles to Graceland" (released 8.3.2010)
* Added support for ALZIP (.alz) archives.
* Added support for LRZIP (.lrz) archives.
* Added support for ARC (.arc) archives.
0.6 "Waking Ned" (released 6.3.2010)

View File

@ -29,8 +29,8 @@ by the archive file extension.
\fBpatool\fP supports 7z (.7z), ACE (.ace), ALZIP (.alz), AR (.a),
ARC (.arc), 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.
LRZIP (.lrz), 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

View File

@ -20,10 +20,11 @@ DESCRIPTION
patool supports 7z (.7z), ACE (.ace), ALZIP (.alz), AR (.a), ARC
(.arc), 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).
(.cpio), DEB (.deb), GZIP (.gz), LRZIP (.lrz), 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 applica
tions to handle those archive formats (for example bzip2 for BZIP2 ar
chives).
EXAMPLES
patool extract archive.zip otherarchive.rar

View File

@ -23,7 +23,7 @@ ArchiveCommands = ('list', 'extract', 'test', 'create')
# Supported archive formats
ArchiveFormats = ('7z', 'ace', 'alzip', 'ar', 'arc', 'arj', 'bzip2',
'cab', 'compress', 'cpio', 'deb', 'gzip', 'lzh', 'lzip', 'lzma',
'cab', 'compress', 'cpio', 'deb', 'gzip', 'lrzip', 'lzh', 'lzip', 'lzma',
'lzop', 'rar', 'rpm', 'tar', 'xz', 'zip')
# Supported encodings (used with tar for example)
@ -58,6 +58,7 @@ ArchiveMimetypes = {
'application/x-lzh': 'lzh',
'application/x-alzip': 'alzip',
'application/x-arc': 'arc',
'application/x-lrzip': 'lrzip',
}
# List of programs supporting the given encoding
@ -120,6 +121,12 @@ ArchivePrograms = {
'test': ('lzip',),
'create': ('lzip',),
},
'lrzip': {
'extract': ('lrzip',),
'list': ('echo',),
'test': ('lrzip',),
'create': ('lrzip',),
},
'compress': {
'extract': ('gzip', '7z', 'uncompress.real'),
'list': ('7z', 'echo',),

View File

@ -37,6 +37,10 @@ def list_lzip (archive, encoding, cmd, **kwargs):
"""List a LZIP archive."""
return stripext(cmd, archive)
def list_lrzip (archive, encoding, cmd, **kwargs):
"""List a LRZIP archive."""
return stripext(cmd, archive)
def stripext (cmd, archive):
"""Echo the name without suffix."""
return [cmd, util.stripext(archive)]

View File

@ -0,0 +1,44 @@
# -*- 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 lrzip program."""
from patoolib import util
def extract_lrzip (archive, encoding, cmd, **kwargs):
"""Extract a LRZIP archive."""
# Since extracted files will be placed in the current directory,
# the cwd argument has to be the output directory.
cmdlist = [cmd, '-d']
if kwargs['verbose']:
cmdlist.append('-v')
outfile = util.get_single_outfile(kwargs['outdir'], archive)
cmdlist.extend(["-o", outfile, archive])
return (cmdlist, {'cwd': kwargs['outdir']})
def test_lrzip (archive, encoding, cmd, **kwargs):
"""Test a LRZIP archive."""
cmdlist = [cmd, '-t']
if kwargs['verbose']:
cmdlist.append('-v')
cmdlist.append(archive)
return cmdlist
def create_lrzip (archive, encoding, cmd, *args, **kwargs):
"""Create a LRZIP archive."""
cmdlist = [cmd, '-o', archive]
if kwargs['verbose']:
cmdlist.append('-v')
cmdlist.extend(args)
return cmdlist

View File

@ -44,6 +44,7 @@ mimedb.add_type('application/x-ace', '.ace', strict=False)
mimedb.add_type('application/x-archive', '.a', strict=True)
mimedb.add_type('application/x-alzip', '.alz', strict=False)
mimedb.add_type('application/x-arc', '.arc', strict=False)
mimedb.add_type('application/x-lrzip', '.lrz', strict=False)
class PatoolError (StandardError):

BIN
tests/data/t.txt.lrz Normal file

Binary file not shown.

BIN
tests/data/t.txt.lrz.foo Normal file

Binary file not shown.

View File

@ -114,6 +114,7 @@ class TestArchives (ArchiveTest):
self.archive_list('t.Z')
self.archive_list('t.lzma')
self.archive_list('t.txt.lz')
self.archive_list('t.txt.lrz')
@needs_program('unzip')
def test_unzip (self):
@ -302,3 +303,10 @@ class TestArchives (ArchiveTest):
self.archive_test('t.arc')
self.archive_list('t.arc')
self.archive_extract('t.arc')
@needs_program('lrzip')
def test_lrzip (self):
self.program = 'lrzip'
self.archive_test('t.txt.lrz')
self.archive_extract('t.txt.lrz')
self.archive_create('t.txt.lrz', singlefile=True)

View File

@ -347,3 +347,11 @@ class TestArchives (ArchiveTest):
self.archive_test('t.arc.foo')
self.archive_list('t.arc.foo')
self.archive_extract('t.arc.foo')
# file(1) does not recognize .alz files
#@needs_program('lrzip')
#def test_lrzip (self):
# self.program = 'lrzip'
# self.archive_test('t.txt.lrz.foo')
# self.archive_extract('t.txt.lrz.foo')
# self.archive_create('t.txt.lrz.foo', format="lrzip", singlefile=True)

View File

@ -111,6 +111,9 @@ class TestMime (unittest.TestCase):
#self.mime_test_mimedb("t.alz.foo", "application/x-alzip", None)
self.mime_test_file("t.arc", "application/x-arc", None)
self.mime_test_file("t.arc.foo", "application/x-arc", None)
# file(1) does not recognize .lrz files
#self.mime_test_mimedb("t.lrz", "application/x-lrzip", None)
#self.mime_test_mimedb("t.lrz.foo", "application/x-lrzip", None)
def test_mime_mimedb (self):
self.mime_test_mimedb("t.7z", "application/x-7z-compressed", None)
@ -146,3 +149,4 @@ class TestMime (unittest.TestCase):
self.mime_test_mimedb("t.lzh", "application/x-lzh", None)
self.mime_test_mimedb("t.alz", "application/x-alzip", None)
self.mime_test_mimedb("t.arc", "application/x-arc", None)
self.mime_test_mimedb("t.lrz", "application/x-lrzip", None)