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 f9a1bbf..a24a1fd 100644 Binary files a/tests/data/t.cab and b/tests/data/t.cab differ 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):