Support DMS (.dms) files.

This commit is contained in:
Bastian Kleineidam 2011-01-24 14:28:29 -06:00
parent 80916bc335
commit e48b95f9f1
12 changed files with 83 additions and 9 deletions

View File

@ -6,6 +6,7 @@
of handling LZIP (.lz) archives. of handling LZIP (.lz) archives.
* Added support for the orange program which is capable of extracting * Added support for the orange program which is capable of extracting
CAB (.cab) archives. CAB (.cab) archives.
* Added support for DMS (.dms) files with the xdms program.
* Support ZIP (.zip) file creation with the 7z and 7za programs. * Support ZIP (.zip) file creation with the 7z and 7za programs.
* Improved MIME type detection for compressed TAR archives. * Improved MIME type detection for compressed TAR archives.
* Fix needed archive programs for several test cases, including * Fix needed archive programs for several test cases, including

View File

@ -30,8 +30,8 @@ by the archive file extension.
.PP .PP
\fBpatool\fP supports 7z (.7z), ACE (.ace), ALZIP (.alz), AR (.a), \fBpatool\fP supports 7z (.7z), ACE (.ace), ALZIP (.alz), AR (.a),
ARC (.arc), ARJ (.arj), ARC (.arc), ARJ (.arj),
BZIP2 (.bz2), CAB (.cab), compress (.Z), CPIO (.cpio), DEB (.deb), GZIP (.gz), BZIP2 (.bz2), CAB (.cab), compress (.Z), CPIO (.cpio), DEB (.deb), DMS (.dms),
LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo), 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 RPM (.rpm), RAR (.rar), RZIP (.rz), TAR (.tar), XZ (.xz), ZIP (.zip, .jar) and
ZOO (.zoo) formats. ZOO (.zoo) formats.
It relies on helper applications to handle those archive formats It relies on helper applications to handle those archive formats

View File

@ -1,6 +1,6 @@
Project: patool Project: patool
Version: 0.12 Version: 0.12
Release-Focus: Minor bugfixes Release-Focus: Minor feature enhancements
Hide: N Hide: N
Website-URL: http://patool.sourceforge.net/ 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 Changelog-URL: http://patool.git.sourceforge.net/git/gitweb.cgi?p=patool/patool;a=blob;f=doc/changelog.txt;hb=HEAD

View File

@ -23,7 +23,7 @@ ArchiveCommands = ('list', 'extract', 'test', 'create')
# Supported archive formats # Supported archive formats
ArchiveFormats = ('7z', 'ace', 'alzip', 'ar', 'arc', 'arj', 'bzip2', 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') 'lzop', 'rar', 'rpm', 'rzip', 'tar', 'xz', 'zip', 'zoo')
# Supported encodings (used with tar for example) # Supported encodings (used with tar for example)
@ -62,6 +62,7 @@ ArchiveMimetypes = {
'application/x-lrzip': 'lrzip', 'application/x-lrzip': 'lrzip',
'application/x-rzip': 'rzip', 'application/x-rzip': 'rzip',
'application/x-zoo': 'zoo', 'application/x-zoo': 'zoo',
'application/x-dms': 'dms',
} }
# List of programs supporting the given encoding # List of programs supporting the given encoding
@ -195,6 +196,11 @@ ArchivePrograms = {
'zoo': { 'zoo': {
None: ('zoo',), None: ('zoo',),
}, },
'dms': {
'extract': ('xdms',),
'list': ('xdms',),
'test': ('xdms',),
},
} }
# List those programs that have different python module names because of # List those programs that have different python module names because of

47
patoolib/programs/xdms.py Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
"""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)

View File

@ -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-lzh', '.lzh', strict=False)
mimedb.add_type('application/x-rzip', '.rz', 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-zoo', '.zoo', strict=False)
mimedb.add_type('application/x-dms', '.dms', strict=False)
class PatoolError (StandardError): class PatoolError (StandardError):
@ -236,6 +237,7 @@ FileText2Mime = {
"LHa ": "application/x-lha", "LHa ": "application/x-lha",
"ARC archive data": "application/x-arc", "ARC archive data": "application/x-arc",
"Zoo archive data": "application/x-zoo", "Zoo archive data": "application/x-zoo",
"DMS archive data": "application/x-dms",
} }
def guess_mime_file_text (file_prog, filename): def guess_mime_file_text (file_prog, filename):

View File

@ -48,7 +48,7 @@ fallback by the archive file extension.
patool supports 7z (.7z), ACE (.ace), ALZIP (.alz), AR (.a), ARC (.arc), patool supports 7z (.7z), ACE (.ace), ALZIP (.alz), AR (.a), ARC (.arc),
ARJ (.arj), BZIP2 (.bz2), CAB (.cab), compress (.Z), CPIO (.cpio), 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), 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 XZ (.xz), ZIP (.zip, .jar) and ZOO (.zoo) formats. It relies on helper
applications to handle those archive formats (for example bzip2 for applications to handle those archive formats (for example bzip2 for

BIN
tests/data/t.dms Normal file

Binary file not shown.

BIN
tests/data/t.dms.foo Normal file

Binary file not shown.

View File

@ -245,7 +245,7 @@ class TestArchives (ArchiveTest):
self.archive_extract('t.cab') self.archive_extract('t.cab')
@needs_program('orange') @needs_program('orange')
def test_cabextract (self): def test_orange (self):
self.program = 'orange' self.program = 'orange'
self.archive_extract('t.cab') self.archive_extract('t.cab')
@ -323,7 +323,7 @@ class TestArchives (ArchiveTest):
self.archive_create('t.txt.lz', singlefile=True) self.archive_create('t.txt.lz', singlefile=True)
@needs_program('pdlzip') @needs_program('pdlzip')
def test_clzip (self): def test_pdlzip (self):
self.program = 'pdlzip' self.program = 'pdlzip'
self.archive_test('t.txt.lz') self.archive_test('t.txt.lz')
self.archive_extract('t.txt.lz') self.archive_extract('t.txt.lz')
@ -378,3 +378,10 @@ class TestArchives (ArchiveTest):
self.program = 'zoo' self.program = 'zoo'
# XXX test failure # XXX test failure
#self.archive_commands('t.zoo', singlefile=True) #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')

View File

@ -274,7 +274,7 @@ class TestArchives (ArchiveTest):
@needs_program('file') @needs_program('file')
@needs_program('orange') @needs_program('orange')
def test_cabextract (self): def test_orange (self):
self.program = 'orange' self.program = 'orange'
self.archive_extract('t.cab.foo') self.archive_extract('t.cab.foo')
@ -365,7 +365,7 @@ class TestArchives (ArchiveTest):
@needs_program('file') @needs_program('file')
@needs_program('pdlzip') @needs_program('pdlzip')
def test_clzip (self): def test_pdlzip (self):
self.program = 'pdlzip' self.program = 'pdlzip'
self.archive_test('t.txt.lz.foo') self.archive_test('t.txt.lz.foo')
self.archive_extract('t.txt.lz.foo') self.archive_extract('t.txt.lz.foo')
@ -425,3 +425,11 @@ class TestArchives (ArchiveTest):
#def test_zoo (self): #def test_zoo (self):
# self.program = 'zoo' # self.program = 'zoo'
# self.archive_commands('t.zoo.foo', format="zoo", singlefile=True) # 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')

View File

@ -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.txt.rz.foo", "application/x-rzip", None)
self.mime_test_file("t.zoo", "application/x-zoo", 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.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('file')
@needs_program('lzip') @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.lrz", "application/x-lrzip", None)
self.mime_test_mimedb("t.rz", "application/x-rzip", 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.zoo", "application/x-zoo", None)
self.mime_test_mimedb("t.dms", "application/x-dms", None)