From 85f592b8ea3db01b2450849cbabc3e87da57ece9 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Mon, 17 Jan 2011 13:11:02 -0600 Subject: [PATCH] Added support for clzip. --- doc/changelog.txt | 2 ++ patoolib/__init__.py | 10 +++++----- patoolib/programs/clzip.py | 23 +++++++++++++++++++++++ tests/test_archives.py | 10 ++++++++++ tests/test_foo_archives.py | 11 +++++++++++ tests/test_mime.py | 8 ++++++-- 6 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 patoolib/programs/clzip.py diff --git a/doc/changelog.txt b/doc/changelog.txt index 27ac54b..228ae19 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -2,6 +2,8 @@ * Fix command argument order when extracting cpio archives. * Added correct cpio MIME type on Debian systems. + * Added support for the clzip program which is like lzip capable + of handling LZIP (.lz) archives. 0.12 "Galaxy Quest" (released 20.11.2010) diff --git a/patoolib/__init__.py b/patoolib/__init__.py index f9d79dc..bf88706 100644 --- a/patoolib/__init__.py +++ b/patoolib/__init__.py @@ -72,7 +72,7 @@ EncodingPrograms = { 'compress': ('compress',), 'lzma': ('lzma',), 'xz': ('xz',), - 'lzip': ('lzip',), + 'lzip': ('lzip', 'clzip'), } # List of programs supporting the given archive format and command. @@ -119,10 +119,10 @@ ArchivePrograms = { None: ('lha',), }, 'lzip': { - 'extract': ('lzip',), - 'list': ('echo',), - 'test': ('lzip',), - 'create': ('lzip',), + 'extract': ('lzip', 'clzip'), + 'list': ('echo', 'clzip'), + 'test': ('lzip', 'clzip'), + 'create': ('lzip', 'clzip'), }, 'lrzip': { 'extract': ('lrzip',), diff --git a/patoolib/programs/clzip.py b/patoolib/programs/clzip.py new file mode 100644 index 0000000..e9a8c8d --- /dev/null +++ b/patoolib/programs/clzip.py @@ -0,0 +1,23 @@ +# -*- 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 clzip program.""" +from patoolib.programs import extract_singlefile_standard, \ + test_singlefile_standard, create_singlefile_standard + + +extract_lzip = extract_singlefile_standard +test_lzip = test_singlefile_standard +create_lzip = create_singlefile_standard diff --git a/tests/test_archives.py b/tests/test_archives.py index 1f65a9d..eef501d 100644 --- a/tests/test_archives.py +++ b/tests/test_archives.py @@ -45,6 +45,9 @@ class TestArchives (ArchiveTest): self.program = 'tar' self.archive_commands('t.tar.lzma') + # XXX even though clzip would support extracting .lz files, the + # file(1) --uncompress command does not use it for achive detection + @needs_program('lzip') @needs_codec('tar', 'lzip') def test_tar_lzip (self): self.program = 'tar' @@ -311,6 +314,13 @@ class TestArchives (ArchiveTest): self.archive_extract('t.txt.lz') self.archive_create('t.txt.lz', singlefile=True) + @needs_program('clzip') + def test_clzip (self): + self.program = 'clzip' + self.archive_test('t.txt.lz') + self.archive_extract('t.txt.lz') + self.archive_create('t.txt.lz', singlefile=True) + @needs_program('unalz') def test_unalz (self): self.program = 'unalz' diff --git a/tests/test_foo_archives.py b/tests/test_foo_archives.py index 804535a..5041ab6 100644 --- a/tests/test_foo_archives.py +++ b/tests/test_foo_archives.py @@ -51,6 +51,9 @@ class TestArchives (ArchiveTest): # self.program = 'tar' # self.archive_commands('t.tar.lzma.foo', format="tar", encoding="lzma") + # XXX even though clzip would support extracting .lz files, the + # file(1) --uncompress command does not use it for achive detection + @needs_program('lzip') @needs_program('file') @needs_codec('tar', 'lzip') def test_tar_lzip (self): @@ -350,6 +353,14 @@ class TestArchives (ArchiveTest): self.archive_extract('t.txt.lz.foo') self.archive_create('t.txt.lz.foo', format="lzip", singlefile=True) + @needs_program('file') + @needs_program('clzip') + def test_clzip (self): + self.program = 'clzip' + self.archive_test('t.txt.lz.foo') + self.archive_extract('t.txt.lz.foo') + self.archive_create('t.txt.lz.foo', format="lzip", singlefile=True) + @needs_program('file') @needs_program('xz') def test_xz (self): diff --git a/tests/test_mime.py b/tests/test_mime.py index 8af452a..d38d7b1 100644 --- a/tests/test_mime.py +++ b/tests/test_mime.py @@ -83,8 +83,6 @@ class TestMime (unittest.TestCase): #self.mime_test_file("t.tar.lzma.foo", "application/x-tar", "lzma") self.mime_test_file("t.tar.xz", "application/x-tar", "xz") self.mime_test_file("t.tar.xz.foo", "application/x-tar", "xz") - self.mime_test_file("t.tar.lz", "application/x-tar", "lzip") - self.mime_test_file("t.tar.lz.foo", "application/x-tar", "lzip") self.mime_test_file("t.tar.Z", "application/x-tar", "compress") self.mime_test_file("t.tar.Z.foo", "application/x-tar", "compress") self.mime_test_file("t.taz", "application/x-tar", "gzip") @@ -123,6 +121,12 @@ class TestMime (unittest.TestCase): self.mime_test_file("t.zoo", "application/x-zoo", None) self.mime_test_file("t.zoo.foo", "application/x-zoo", None) + @needs_program('file') + @needs_program('lzip') + def test_mime_file_lzip (self): + self.mime_test_file("t.tar.lz", "application/x-tar", "lzip") + self.mime_test_file("t.tar.lz.foo", "application/x-tar", "lzip") + def test_mime_mimedb (self): self.mime_test_mimedb("t .7z", "application/x-7z-compressed", None) self.mime_test_mimedb("t.arj", "application/x-arj", None)