diff --git a/doc/changelog.txt b/doc/changelog.txt index fe54617..d3beb1d 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -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) diff --git a/doc/patool.1 b/doc/patool.1 index 3d048cb..db98a9e 100644 --- a/doc/patool.1 +++ b/doc/patool.1 @@ -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 diff --git a/doc/patool.txt b/doc/patool.txt index 6de9d28..4964e1c 100644 --- a/doc/patool.txt +++ b/doc/patool.txt @@ -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 @@ -35,19 +36,19 @@ COMMANDS Several commands and options are available. extract - Extract files from an archive. This is the default command if no com‐ + Extract files from an archive. This is the default command if no com‐ mand was given. - Often one wants to extract all files in an archive to a single subdi‐ - rectory. However, some archives contain multiple files in their root + Often one wants to extract all files in an archive to a single subdi‐ + rectory. However, some archives contain multiple files in their root directories. The patool program overcomes this problem by first extracting files to a unique (temporary) directory, and then moving its - contents back if possible. This also prevents local files from being + contents back if possible. This also prevents local files from being overwritten by mistake. - All extracted files are checked that they are readable by the current + All extracted files are checked that they are readable by the current user. -v, --verbose - Be verbose when extracting (if the helper application supports + Be verbose when extracting (if the helper application supports it). --help Show help for this command. @@ -61,7 +62,7 @@ COMMANDS --help Show help for this command. create - Create an archive from given files. At least on of the given files to + Create an archive from given files. At least on of the given files to add to the archive has to exist. -v, --verbose diff --git a/patoolib/__init__.py b/patoolib/__init__.py index cd56bfe..e9ccbab 100644 --- a/patoolib/__init__.py +++ b/patoolib/__init__.py @@ -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',), diff --git a/patoolib/programs/echo.py b/patoolib/programs/echo.py index adbbd38..997d4ca 100644 --- a/patoolib/programs/echo.py +++ b/patoolib/programs/echo.py @@ -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)] diff --git a/patoolib/programs/lrzip.py b/patoolib/programs/lrzip.py new file mode 100644 index 0000000..1abe287 --- /dev/null +++ b/patoolib/programs/lrzip.py @@ -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 . +"""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 diff --git a/patoolib/util.py b/patoolib/util.py index ef86f12..43fd951 100644 --- a/patoolib/util.py +++ b/patoolib/util.py @@ -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): diff --git a/tests/data/t.txt.lrz b/tests/data/t.txt.lrz new file mode 100644 index 0000000..6ae1d1a Binary files /dev/null and b/tests/data/t.txt.lrz differ diff --git a/tests/data/t.txt.lrz.foo b/tests/data/t.txt.lrz.foo new file mode 100644 index 0000000..6ae1d1a Binary files /dev/null and b/tests/data/t.txt.lrz.foo differ diff --git a/tests/test_archives.py b/tests/test_archives.py index 5e97034..bb72507 100644 --- a/tests/test_archives.py +++ b/tests/test_archives.py @@ -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) diff --git a/tests/test_foo_archives.py b/tests/test_foo_archives.py index a2dccb6..4d85307 100644 --- a/tests/test_foo_archives.py +++ b/tests/test_foo_archives.py @@ -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) diff --git a/tests/test_mime.py b/tests/test_mime.py index afc5d69..602c7d4 100644 --- a/tests/test_mime.py +++ b/tests/test_mime.py @@ -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)