diff --git a/doc/changelog.txt b/doc/changelog.txt index 08cf343..c061924 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -6,6 +6,7 @@ of handling LZIP (.lz) archives. * Added support for the orange program which is capable of extracting CAB (.cab) archives. + * Added support for DMS (.dms) files with the xdms program. * Support ZIP (.zip) file creation with the 7z and 7za programs. * Improved MIME type detection for compressed TAR archives. * Fix needed archive programs for several test cases, including diff --git a/doc/patool.1 b/doc/patool.1 index ff8877b..6eee495 100644 --- a/doc/patool.1 +++ b/doc/patool.1 @@ -30,8 +30,8 @@ by the archive file extension. .PP \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), -LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo), +BZIP2 (.bz2), CAB (.cab), compress (.Z), CPIO (.cpio), DEB (.deb), DMS (.dms), +GZIP (.gz), LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo), RPM (.rpm), RAR (.rar), RZIP (.rz), TAR (.tar), XZ (.xz), ZIP (.zip, .jar) and ZOO (.zoo) formats. It relies on helper applications to handle those archive formats diff --git a/patool.freshmeat b/patool.freshmeat index f137772..5461e0b 100644 --- a/patool.freshmeat +++ b/patool.freshmeat @@ -1,6 +1,6 @@ Project: patool Version: 0.12 -Release-Focus: Minor bugfixes +Release-Focus: Minor feature enhancements Hide: N Website-URL: http://patool.sourceforge.net/ Changelog-URL: http://patool.git.sourceforge.net/git/gitweb.cgi?p=patool/patool;a=blob;f=doc/changelog.txt;hb=HEAD diff --git a/patoolib/__init__.py b/patoolib/__init__.py index 111774c..caf06f4 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', 'lrzip', 'lzh', 'lzip', 'lzma', + 'cab', 'compress', 'cpio', 'deb', 'dms', 'gzip', 'lrzip', 'lzh', 'lzip', 'lzma', 'lzop', 'rar', 'rpm', 'rzip', 'tar', 'xz', 'zip', 'zoo') # Supported encodings (used with tar for example) @@ -62,6 +62,7 @@ ArchiveMimetypes = { 'application/x-lrzip': 'lrzip', 'application/x-rzip': 'rzip', 'application/x-zoo': 'zoo', + 'application/x-dms': 'dms', } # List of programs supporting the given encoding @@ -195,6 +196,11 @@ ArchivePrograms = { 'zoo': { None: ('zoo',), }, + 'dms': { + 'extract': ('xdms',), + 'list': ('xdms',), + 'test': ('xdms',), + }, } # List those programs that have different python module names because of diff --git a/patoolib/programs/xdms.py b/patoolib/programs/xdms.py new file mode 100644 index 0000000..fe0c36a --- /dev/null +++ b/patoolib/programs/xdms.py @@ -0,0 +1,47 @@ +# -*- 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 xdms program.""" +from patoolib import util + + +def extract_dms (archive, encoding, cmd, **kwargs): + """Extract a DMS archive.""" + check_archive_ext(archive) + cmdlist = [cmd, '-d', kwargs['outdir']] + if kwargs['verbose']: + cmdlist.append('-v') + cmdlist.extend(['u', archive]) + return cmdlist + + +def list_dms (archive, encoding, cmd, **kwargs): + """List a DMS archive.""" + check_archive_ext(archive) + return [cmd, 'v', archive] + + +def test_dms (archive, encoding, cmd, **kwargs): + """Test a DMS archive.""" + check_archive_ext(archive) + return [cmd, 't', archive] + + +def check_archive_ext (archive): + """xdms(1) cannot handle files with extensions other than '.dms'.""" + if not archive.lower().endswith(".dms"): + rest = archive[-4:] + msg = "xdms(1) archive file must end with `.dms', not `%s'" % rest + raise util.PatoolError(msg) diff --git a/patoolib/util.py b/patoolib/util.py index 0179a4b..61774ca 100644 --- a/patoolib/util.py +++ b/patoolib/util.py @@ -49,6 +49,7 @@ mimedb.add_type('application/x-lha', '.lha', strict=False) mimedb.add_type('application/x-lzh', '.lzh', strict=False) mimedb.add_type('application/x-rzip', '.rz', strict=False) mimedb.add_type('application/x-zoo', '.zoo', strict=False) +mimedb.add_type('application/x-dms', '.dms', strict=False) class PatoolError (StandardError): @@ -236,6 +237,7 @@ FileText2Mime = { "LHa ": "application/x-lha", "ARC archive data": "application/x-arc", "Zoo archive data": "application/x-zoo", + "DMS archive data": "application/x-dms", } def guess_mime_file_text (file_prog, filename): diff --git a/setup.py b/setup.py index d840470..22a6072 100644 --- a/setup.py +++ b/setup.py @@ -48,7 +48,7 @@ fallback by the archive file extension. 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), LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz), +DEB (.deb), DMS (.dms), GZIP (.gz), LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo), RPM (.rpm), RAR (.rar), RZIP (.rz), TAR (.tar), XZ (.xz), ZIP (.zip, .jar) and ZOO (.zoo) formats. It relies on helper applications to handle those archive formats (for example bzip2 for diff --git a/tests/data/t.dms b/tests/data/t.dms new file mode 100644 index 0000000..65eca30 Binary files /dev/null and b/tests/data/t.dms differ diff --git a/tests/data/t.dms.foo b/tests/data/t.dms.foo new file mode 100644 index 0000000..65eca30 Binary files /dev/null and b/tests/data/t.dms.foo differ diff --git a/tests/test_archives.py b/tests/test_archives.py index eae64f8..65a0351 100644 --- a/tests/test_archives.py +++ b/tests/test_archives.py @@ -245,7 +245,7 @@ class TestArchives (ArchiveTest): self.archive_extract('t.cab') @needs_program('orange') - def test_cabextract (self): + def test_orange (self): self.program = 'orange' self.archive_extract('t.cab') @@ -323,7 +323,7 @@ class TestArchives (ArchiveTest): self.archive_create('t.txt.lz', singlefile=True) @needs_program('pdlzip') - def test_clzip (self): + def test_pdlzip (self): self.program = 'pdlzip' self.archive_test('t.txt.lz') self.archive_extract('t.txt.lz') @@ -378,3 +378,10 @@ class TestArchives (ArchiveTest): self.program = 'zoo' # XXX test failure #self.archive_commands('t.zoo', singlefile=True) + + @needs_program('xdms') + def test_xdms (self): + self.program = 'xdms' + self.archive_test('t.dms') + self.archive_extract('t.dms') + self.archive_list('t.dms') diff --git a/tests/test_foo_archives.py b/tests/test_foo_archives.py index 3905943..d047fef 100644 --- a/tests/test_foo_archives.py +++ b/tests/test_foo_archives.py @@ -274,7 +274,7 @@ class TestArchives (ArchiveTest): @needs_program('file') @needs_program('orange') - def test_cabextract (self): + def test_orange (self): self.program = 'orange' self.archive_extract('t.cab.foo') @@ -365,7 +365,7 @@ class TestArchives (ArchiveTest): @needs_program('file') @needs_program('pdlzip') - def test_clzip (self): + def test_pdlzip (self): self.program = 'pdlzip' self.archive_test('t.txt.lz.foo') self.archive_extract('t.txt.lz.foo') @@ -425,3 +425,11 @@ class TestArchives (ArchiveTest): #def test_zoo (self): # self.program = 'zoo' # self.archive_commands('t.zoo.foo', format="zoo", singlefile=True) + + # xdms(1) cannot handle files without '.dms' extension + #@needs_program('xdms') + #def test_xdms (self): + # self.program = 'xdms' + # self.archive_extract('t.dms.foo') + # self.archive_test('t.dms.foo') + # self.archive_list('t.dms.foo') diff --git a/tests/test_mime.py b/tests/test_mime.py index e9db4a6..9163be7 100644 --- a/tests/test_mime.py +++ b/tests/test_mime.py @@ -114,6 +114,8 @@ class TestMime (unittest.TestCase): self.mime_test_file("t.txt.rz.foo", "application/x-rzip", None) self.mime_test_file("t.zoo", "application/x-zoo", None) self.mime_test_file("t.zoo.foo", "application/x-zoo", None) + self.mime_test_file("t.dms", "application/x-dms", None) + self.mime_test_file("t.dms.foo", "application/x-dms", None) @needs_program('file') @needs_program('lzip') @@ -180,3 +182,4 @@ class TestMime (unittest.TestCase): self.mime_test_mimedb("t.lrz", "application/x-lrzip", None) self.mime_test_mimedb("t.rz", "application/x-rzip", None) self.mime_test_mimedb("t.zoo", "application/x-zoo", None) + self.mime_test_mimedb("t.dms", "application/x-dms", None)