From 216faeaf0e98ed5942b008211e7099cb6cfbbcec Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Thu, 24 May 2012 23:17:37 +0200 Subject: [PATCH] Add lcab support. --- doc/changelog.txt | 1 + patoolib/__init__.py | 11 ++++++----- patoolib/programs/lcab.py | 25 +++++++++++++++++++++++++ tests/__init__.py | 2 ++ tests/data/t.cab | Bin 79 -> 78 bytes tests/test_archives.py | 6 ++++++ tests/test_foo_archives.py | 6 ++++++ 7 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 patoolib/programs/lcab.py diff --git a/doc/changelog.txt b/doc/changelog.txt index c861b73..1508614 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -5,6 +5,7 @@ * Added support for flac handling FLAC (.flac) files. * Added support for the BSD cpio and tar programs. * Added support for lhasa handling LZH (.lzh, .lha) files. +* Added support for lcap handling CAB (.cab) files. * Generate standalone Windows .exe and Linux .rpm installer. * Initialize the internal MIME database correct on all platforms. * Improved option compatibility for the ar, cpio and tar programs. diff --git a/patoolib/__init__.py b/patoolib/__init__.py index b1349ca..4f2f65c 100644 --- a/patoolib/__init__.py +++ b/patoolib/__init__.py @@ -104,6 +104,12 @@ ArchivePrograms = { 'create': ('pbzip2', 'lbzip2', 'bzip2', 'py_bz2'), 'list': ('py_echo', '7z', '7za'), }, + 'cab': { + 'extract': ('cabextract', '7z', 'orange'), + 'create': ('lcab',), + 'list': ('cabextract', '7z'), + 'test': ('cabextract', '7z'), + }, 'flac': { 'extract': ('flac',), 'test': ('flac',), @@ -156,11 +162,6 @@ ArchivePrograms = { 'list': ('unrar', '7z'), 'test': ('unrar', '7z'), }, - 'cab': { - 'extract': ('cabextract', '7z', 'orange'), - 'list': ('cabextract', '7z'), - 'test': ('cabextract', '7z'), - }, 'arj': { None: ('arj',), 'extract': ('7z',), diff --git a/patoolib/programs/lcab.py b/patoolib/programs/lcab.py new file mode 100644 index 0000000..a4f95c9 --- /dev/null +++ b/patoolib/programs/lcab.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Copyright (C) 2012 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 lcab program.""" + +def create_cab (archive, compression, cmd, *args, **kwargs): + """Create a CAB archive.""" + cmdlist = [cmd, '-r'] + if not kwargs['verbose']: + cmdlist.append('-q') + cmdlist.extend(args) + cmdlist.append(archive) + return cmdlist diff --git a/tests/__init__.py b/tests/__init__.py index 6c8be8a..670e1a0 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -169,6 +169,8 @@ class ArchiveTest (unittest.TestCase): elif self.program in ('rzip', 'shorten'): program = 'py_echo' command = 'list' + elif self.program == 'lcab': + program = 'cabextract' patoolib._handle_archive(archive, command, program=program) finally: os.chdir(basedir) diff --git a/tests/data/t.cab b/tests/data/t.cab index f9a1bbf6cb221486613496b968ca760f4c755549..a24a1fd5964308de14a83719ce888fd7cea79ce4 100644 GIT binary patch delta 31 icmebG59N#0UUZ(*%tG delta 32 kcmebC=kyJBc4Ghn|B0N+jLZ{t#ko0+%o&)0(8P!f09(QYr~m)} diff --git a/tests/test_archives.py b/tests/test_archives.py index 5aa72af..754e266 100644 --- a/tests/test_archives.py +++ b/tests/test_archives.py @@ -339,6 +339,12 @@ class TestArchives (ArchiveTest): self.program = 'orange' self.archive_extract('t.cab') + @needs_program('lcab') + @needs_program('cabextract') + def test_lcab (self): + self.program = 'lcab' + self.archive_create('t.cab') + @needs_program('arj') def test_arj (self): self.program = 'arj' diff --git a/tests/test_foo_archives.py b/tests/test_foo_archives.py index 963ad0c..441b3f2 100644 --- a/tests/test_foo_archives.py +++ b/tests/test_foo_archives.py @@ -375,6 +375,12 @@ class TestArchives (ArchiveTest): self.program = 'orange' self.archive_extract('t.cab.foo') + @needs_program('lcab') + @needs_program('cabextract') + def test_lcab (self): + self.program = 'lcab' + self.archive_create('t.cab.foo', format="cab") + @needs_program('file') @needs_program('arj') def test_arj (self):