Add ISO image support.

This commit is contained in:
Bastian Kleineidam 2013-02-27 19:38:07 +01:00
parent 2a6c3303d5
commit b8425504c4
16 changed files with 285 additions and 156 deletions

View File

@ -12,11 +12,11 @@ The archive format is determined by the file(1) program and as
a fallback by the archive file extension.
patool supports 7z (.7z), ACE (.ace), ADF (.adf), ALZIP (.alz),
APE (.ape), AR (.a), ARC (.arc), ARJ (.arj), BZIP2 (.bz2), CAB
(.cab), compress (.Z), CPIO (.cpio), DEB (.deb), DMS (.dms),
FLAC (.flac), GZIP (.gz), LRZIP (.lrz), LZH (.lha, .lzh), LZIP
(.lz), LZMA (.lzma), LZOP (.lzo), RPM (.rpm), RAR (.rar), RZIP
(.rz), SHN (.shn), TAR (.tar), XZ (.xz), ZIP (.zip, .jar) and
APE (.ape), AR (.a), ARC (.arc), ARJ (.arj), BZIP2 (.bz2),
CAB (.cab), compress (.Z), CPIO (.cpio), DEB (.deb), DMS (.dms),
FLAC (.flac), GZIP (.gz), ISO (.iso), LRZIP (.lrz), LZH (.lha, .lzh),
LZIP (.lz), LZMA (.lzma), LZOP (.lzo), RPM (.rpm), RAR (.rar),
RZIP (.rz), SHN (.shn), 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 BZIP2 archives).

View File

@ -1,6 +1,7 @@
1.0 "" (released xx.xx.2013)
* Add support for searching in archive contents.
* Add support for ISO image handling.
* Allow multiple --verbose options to increase program output.
* Fixed Python lzma archive handling.
* Fixed lzop, lrzip and rzip archive handling.

View File

@ -27,7 +27,7 @@ by the archive file extension.
\fBpatool\fP supports 7z (.7z), ACE (.ace), ADF (.adf), ALZIP (.alz),
APE (.ape), AR (.a), ARC (.arc), ARJ (.arj),
BZIP2 (.bz2), CAB (.cab), compress (.Z), CPIO (.cpio), DEB (.deb), DMS (.dms),
FLAC (.flac), GZIP (.gz), LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz),
FLAC (.flac), GZIP (.gz), ISO (.iso), LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz),
LZMA (.lzma), LZOP (.lzo), RPM (.rpm), RAR (.rar), RZIP (.rz), SHN (.shn),
TAR (.tar), XZ (.xz), ZIP (.zip, .jar) and ZOO (.zoo) formats.
It relies on helper applications to handle those archive formats

View File

@ -23,14 +23,15 @@ DESCRIPTION
patool supports 7z (.7z), ACE (.ace), ADF (.adf), ALZIP (.alz),
APE (.ape), AR (.a), ARC (.arc), ARJ (.arj), BZIP2 (.bz2), CAB
(.cab), compress (.Z), CPIO (.cpio), DEB (.deb), DMS (.dms),
FLAC (.flac), GZIP (.gz), LRZIP (.lrz), LZH (.lha, .lzh), LZIP
(.lz), LZMA (.lzma), LZOP (.lzo), RPM (.rpm), RAR (.rar), RZIP
(.rz), SHN (.shn), 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 BZIP2 archives).
FLAC (.flac), GZIP (.gz), ISO (.iso), LRZIP (.lrz), LZH (.lha,
.lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo), RPM (.rpm), RAR
(.rar), RZIP (.rz), SHN (.shn), 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 BZIP2 archives).
The archive formats TAR, ZIP, BZIP2 and GZIP are supported
natively and do not require helper applications to be
The archive formats TAR, ZIP, BZIP2 and GZIP are supported
natively and do not require helper applications to be
installed.
EXAMPLES
@ -44,7 +45,7 @@ EXAMPLES
GLOBAL OPTIONS
-v, --verbose
Display more info about what patool does, and display
Display more info about what patool does, and display
the output of helper applications. Can be given multiple
times to increase the output even more.
@ -55,7 +56,7 @@ COMMANDS
· The original archive will never be removed.
· Files outside the outut directory will never be created.
· Files outside the outut directory will never be created.
This relies on archive program options to prevent unpacking
of files with an absolute path name (eg. --no-abso
lute-filenames for cpio(1)).
@ -65,22 +66,22 @@ COMMANDS
extract
patool extract [--outdir directory] <archive>...
Extract files from given archives. The original archives will
Extract files from given archives. The original archives will
never be removed and are left as is.
--outdir directory
Extract to the given output directory. Default is to
Extract to the given output directory. Default is to
extract to the current working directory.
If the archive contains exactly one file or directory, the ar
chive contents are extracted directly to the output directory.
If the archive contains exactly one file or directory, the ar
chive contents are extracted directly to the output directory.
Else the files are extracted in a newly created subdirectory of
the output directory. The new directory is named after the ar
the output directory. The new directory is named after the ar
chive filename without the extension.
This prevents cluttering the output directory with a lot of
This prevents cluttering the output directory with a lot of
files from the extracted archive.
All extracted files are ensured that they are readable by the
All extracted files are ensured that they are readable by the
current user.
list
@ -91,15 +92,15 @@ COMMANDS
create
patool create <archive> <file-or-directory>...
Create an archive from given files. All of the given files to
add to the archive must be readable by the current user. The
format of the archive to create is determined by the archive
Create an archive from given files. All of the given files to
add to the archive must be readable by the current user. The
format of the archive to create is determined by the archive
file extension.
test
patool test <archive>...
Test the given archives. If the helper application does not
Test the given archives. If the helper application does not
support testing, the archive contents are listed instead.
diff
@ -111,24 +112,24 @@ COMMANDS
search
patool search <pattern> <archive>
Search in archive contents for given pattern using the grep(1)
program. The grep options used are -r; additional options can
Search in archive contents for given pattern using the grep(1)
program. The grep options used are -r; additional options can
be supplied with the GREP_OPTIONS environment variable.
repack
patool repack <archive> <archive_new>
Repackage archive to a different format. The target archive
Repackage archive to a different format. The target archive
format is determined by the file extension of archive_new.
formats
patool formats
Show all supported archive formats (ie. which helper applica
Show all supported archive formats (ie. which helper applica
tions are available).
HELP OPTION
Specifying the help option displays help for patool itself, or
Specifying the help option displays help for patool itself, or
a command.
For example:
patool --help - display help for patool

View File

@ -33,7 +33,7 @@ ArchiveCommands = ('list', 'extract', 'test', 'create')
ArchiveFormats = (
'7z', 'ace', 'adf', 'alzip', 'ape', 'ar', 'arc', 'arj',
'bzip2', 'cab', 'chm', 'compress', 'cpio', 'deb', 'dms',
'flac', 'gzip', 'lrzip', 'lzh', 'lzip', 'lzma', 'lzop',
'flac', 'gzip', 'iso', 'lrzip', 'lzh', 'lzip', 'lzma', 'lzop',
'rar', 'rpm', 'rzip', 'shar', 'shn', 'tar', 'xz',
'zip', 'zoo')
@ -43,40 +43,41 @@ ArchiveCompressions = ('bzip2', 'compress', 'gzip', 'lzip', 'lzma', 'xz')
# Map MIME types to archive format
ArchiveMimetypes = {
'application/x-adf': 'adf',
'application/x-bzip2': 'bzip2',
'application/x-tar': 'tar',
'application/x-gzip': 'gzip',
'application/zip': 'zip',
'application/x-zip-compressed': 'zip',
'application/java-archive': 'zip',
'application/x-7z-compressed': '7z',
'application/x-compress': 'compress',
'application/x-rar': 'rar',
'application/rar': 'rar',
'application/x-cab': 'cab',
'application/vnd.ms-cab-compressed': 'cab',
'application/x-7z-compressed': '7z',
'application/x-ace': 'ace',
'application/x-adf': 'adf',
'application/x-alzip': 'alzip',
'application/x-archive': 'ar',
'application/x-arc': 'arc',
'application/x-arj': 'arj',
'application/x-bzip2': 'bzip2',
'application/x-cab': 'cab',
'application/x-chm': 'chm',
'application/x-compress': 'compress',
'application/x-cpio': 'cpio',
'application/x-redhat-package-manager': 'rpm',
'application/x-rpm': 'rpm',
'application/x-debian-package': 'deb',
'application/x-dms': 'dms',
'application/x-gzip': 'gzip',
'application/x-iso9660-image': 'iso',
'application/x-lzop': 'lzop',
'application/x-lzma': 'lzma',
'application/x-xz': 'xz',
'application/x-lzip': 'lzip',
'application/x-ace': 'ace',
'application/x-archive': 'ar',
'application/x-lha': 'lzh',
'application/x-lzh': 'lzh',
'application/x-alzip': 'alzip',
'application/x-arc': 'arc',
'application/x-lrzip': 'lrzip',
'application/x-lzh': 'lzh',
'application/x-rar': 'rar',
'application/x-redhat-package-manager': 'rpm',
'application/x-rpm': 'rpm',
'application/x-rzip': 'rzip',
'application/x-zoo': 'zoo',
'application/x-dms': 'dms',
'application/x-shar': 'shar',
'application/x-tar': 'tar',
'application/x-xz': 'xz',
'application/x-zip-compressed': 'zip',
'application/x-zoo': 'zoo',
'application/zip': 'zip',
'audio/x-ape': 'ape',
'audio/x-shn': 'shn',
'audio/flac': 'flac',
@ -160,6 +161,12 @@ ArchivePrograms = {
'extract': ('py_gzip',),
'create': ('py_gzip',),
},
'iso': {
'extract': ('7z',),
'list': ('7z', 'isoinfo'),
'test': ('7z',),
'create': ('genisoimage',),
},
'lzh': {
None: ('lha',),
'extract': ('lhasa',),

View File

@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2013 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 genisoimage program."""
def create_iso (archive, compression, cmd, verbosity, filenames):
"""Create an ISO archive."""
# Use Joliet (-J) and Rock-Ridge (-r) format.
cmdlist = [cmd, '-r', '-J']
if verbosity > 1:
cmdlist.append('-v')
if verbosity > 2:
cmdlist.append('-v')
cmdlist.extend(['-o', archive])
cmdlist.extend(filenames)
return cmdlist

View File

@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2013 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 isoinfo program."""
def list_iso (archive, compression, cmd, verbosity):
"""List an ISO archive."""
# Use Joliet (-J) and Rock-Ridge (-R) options.
return [cmd, '-l', '-R', '-J', '-i', archive]

View File

@ -29,6 +29,7 @@ extract_bzip2 = \
extract_cpio = \
extract_rpm = \
extract_deb = \
extract_iso = \
extract_7z
def list_7z (archive, compression, cmd, verbosity):
@ -45,6 +46,7 @@ list_bzip2 = \
list_cpio = \
list_rpm = \
list_deb = \
list_iso = \
list_7z
@ -62,6 +64,7 @@ test_bzip2 = \
test_cpio = \
test_rpm = \
test_deb = \
test_iso = \
test_7z

View File

@ -285,7 +285,7 @@ fallback by the archive file extension.
patool supports 7z (.7z), ACE (.ace), ADF (.adf), ALZIP (.alz), APE (.ape),
AR (.a), ARC (.arc), ARJ (.arj), BZIP2 (.bz2),
CAB (.cab), compress (.Z), CPIO (.cpio),
DEB (.deb), DMS (.dms), FLAC (.flac), GZIP (.gz), LRZIP (.lrz),
DEB (.deb), DMS (.dms), FLAC (.flac), GZIP (.gz), ISO (.iso), LRZIP (.lrz),
LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo), RPM (.rpm),
RAR (.rar), RZIP (.rz), SHN (.shn), TAR (.tar), XZ (.xz), ZIP (.zip, .jar)
and ZOO (.zoo) formats.

View File

@ -180,6 +180,8 @@ class ArchiveTest (unittest.TestCase):
command = patoolib.list_archive
elif self.program == 'lcab':
program = 'cabextract'
elif self.program == 'genisoimage':
program = '7z'
elif self.program == 'shar':
return
command(archive, program=program)
@ -200,6 +202,8 @@ class ArchiveTest (unittest.TestCase):
program = 'cabextract'
elif self.program == 'shar':
program = 'unshar'
elif self.program == 'genisoimage':
program = '7z'
tmpdir = patoolib.util.tmpdir(dir=basedir)
try:
olddir = patoolib.util.chdir(tmpdir)

View File

@ -33,6 +33,7 @@ class Test7z (ArchiveTest):
self.archive_list('t.cpio')
self.archive_list('t.rpm')
self.archive_list('t.deb')
self.archive_list('t.iso')
self.archive_extract('t.txt.gz', check=Content.Singlefile)
self.archive_extract('t.txt.bz2', check=Content.Singlefile)
self.archive_extract('t.jar', check=None)
@ -42,6 +43,7 @@ class Test7z (ArchiveTest):
self.archive_extract('t.cpio')
self.archive_extract('t.rpm', check=None)
self.archive_extract('t.deb', check=None)
self.archive_extract('t.iso')
self.archive_test('t.txt.gz')
self.archive_test('t.txt.bz2')
self.archive_test('t.jar')
@ -51,6 +53,7 @@ class Test7z (ArchiveTest):
self.archive_test('t.cpio')
self.archive_test('t.rpm')
self.archive_test('t.deb')
self.archive_test('t.iso')
@needs_codec(program, 'rar')
def test_7z_rar (self):
@ -73,6 +76,7 @@ class Test7z (ArchiveTest):
self.archive_list('t.cpio.foo')
self.archive_list('t.rpm.foo')
self.archive_list('t.deb.foo')
self.archive_list('t.iso.foo')
self.archive_extract('t.txt.gz.foo', check=None)
self.archive_extract('t.txt.bz2.foo', check=Content.Singlefile)
self.archive_extract('t.jar.foo', check=None)
@ -82,6 +86,7 @@ class Test7z (ArchiveTest):
self.archive_extract('t.cpio.foo')
self.archive_extract('t.rpm.foo', check=None)
self.archive_extract('t.deb.foo', check=None)
self.archive_extract('t.iso.foo')
self.archive_test('t.txt.gz.foo')
self.archive_test('t.txt.bz2.foo')
self.archive_test('t.jar.foo')
@ -91,6 +96,7 @@ class Test7z (ArchiveTest):
self.archive_test('t.cpio.foo')
self.archive_test('t.rpm.foo')
self.archive_test('t.deb.foo')
self.archive_test('t.iso.foo')
@needs_program('file')
@needs_codec(program, 'rar')

View File

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2013 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/>.
from . import ArchiveTest
from .. import needs_program
class TestGenisoimage(ArchiveTest):
program = 'genisoimage'
# needs 7z for testing
@needs_program('7z')
@needs_program(program)
def test_genisoimage(self):
self.archive_create('t.iso')

View File

@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2013 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/>.
from . import ArchiveTest
from .. import needs_program
class TestIsoinfo(ArchiveTest):
program = 'isoinfo'
@needs_program(program)
def test_isoinfo(self):
self.archive_list('t.iso')
@needs_program(program)
def test_isoinfo_file(self):
self.archive_list('t.iso.foo')

BIN
tests/data/t.iso Normal file

Binary file not shown.

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

Binary file not shown.

View File

@ -33,47 +33,47 @@ class TestMime (unittest.TestCase):
self.assertEqual(file_mime, mime, fail_msg % ("MIME type", filename, mime, file_mime))
self.assertEqual(file_encoding, encoding, fail_msg % ("Encoding", filename, encoding, file_encoding))
def mime_test_file (self, filename, mime, encoding):
def mime_test_file (self, filename, mime, encoding=None):
"""Test that file has given mime and encoding as determined by
file(1)."""
self.mime_test(patoolib.util.guess_mime_file, filename, mime, encoding)
def mime_test_mimedb (self, filename, mime, encoding):
def mime_test_mimedb (self, filename, mime, encoding=None):
"""Test that file has given mime and encoding as determined by the
mimetypes module."""
self.mime_test(patoolib.util.guess_mime_mimedb, filename, mime, encoding)
@needs_program('file')
def test_mime_file (self):
self.mime_test_file("t .7z", "application/x-7z-compressed", None)
self.mime_test_file("t.7z.foo", "application/x-7z-compressed", None)
self.mime_test_file("t.arj", "application/x-arj", None)
self.mime_test_file("t.arj.foo", "application/x-arj", None)
self.mime_test_file("t.txt.bz2", "application/x-bzip2", None)
self.mime_test_file("t.txt.bz2.foo", "application/x-bzip2", None)
self.mime_test_file("t.cab", "application/vnd.ms-cab-compressed", None)
self.mime_test_file("t.cab.foo", "application/vnd.ms-cab-compressed", None)
self.mime_test_file("t.cpio", "application/x-cpio", None)
self.mime_test_file("t.cpio.foo", "application/x-cpio", None)
self.mime_test_file("t.deb", "application/x-debian-package", None)
self.mime_test_file("t.deb.foo", "application/x-debian-package", None)
self.mime_test_file("t.txt.gz", "application/x-gzip", None)
self.mime_test_file("t.txt.gz.foo", "application/x-gzip", None)
self.mime_test_file("t.jar", "application/zip", None)
self.mime_test_file("t.jar.foo", "application/zip", None)
self.mime_test_file("t .7z", "application/x-7z-compressed")
self.mime_test_file("t.7z.foo", "application/x-7z-compressed")
self.mime_test_file("t.arj", "application/x-arj")
self.mime_test_file("t.arj.foo", "application/x-arj")
self.mime_test_file("t.txt.bz2", "application/x-bzip2")
self.mime_test_file("t.txt.bz2.foo", "application/x-bzip2")
self.mime_test_file("t.cab", "application/vnd.ms-cab-compressed")
self.mime_test_file("t.cab.foo", "application/vnd.ms-cab-compressed")
self.mime_test_file("t.cpio", "application/x-cpio")
self.mime_test_file("t.cpio.foo", "application/x-cpio")
self.mime_test_file("t.deb", "application/x-debian-package")
self.mime_test_file("t.deb.foo", "application/x-debian-package")
self.mime_test_file("t.txt.gz", "application/x-gzip")
self.mime_test_file("t.txt.gz.foo", "application/x-gzip")
self.mime_test_file("t.jar", "application/zip")
self.mime_test_file("t.jar.foo", "application/zip")
# file(1) does not recognize .lzma files
#self.mime_test_file("t.lzma", "application/x-lzma", None)
#self.mime_test_file("t.lzma.foo", "application/x-lzma", None)
self.mime_test_file("t.txt.lz", "application/x-lzip", None)
self.mime_test_file("t.txt.lz.foo", "application/x-lzip", None)
self.mime_test_file("t.txt.lzo", "application/x-lzop", None)
self.mime_test_file("t.txt.lzo.foo", "application/x-lzop", None)
self.mime_test_file("t.rar", "application/x-rar", None)
self.mime_test_file("t.rar.foo", "application/x-rar", None)
self.mime_test_file("t.rpm", "application/x-rpm", None)
self.mime_test_file("t.rpm.foo", "application/x-rpm", None)
self.mime_test_file("t.tar", "application/x-tar", None)
self.mime_test_file("t.tar.foo", "application/x-tar", None)
#self.mime_test_file("t.lzma", "application/x-lzma")
#self.mime_test_file("t.lzma.foo", "application/x-lzma")
self.mime_test_file("t.txt.lz", "application/x-lzip")
self.mime_test_file("t.txt.lz.foo", "application/x-lzip")
self.mime_test_file("t.txt.lzo", "application/x-lzop")
self.mime_test_file("t.txt.lzo.foo", "application/x-lzop")
self.mime_test_file("t.rar", "application/x-rar")
self.mime_test_file("t.rar.foo", "application/x-rar")
self.mime_test_file("t.rpm", "application/x-rpm")
self.mime_test_file("t.rpm.foo", "application/x-rpm")
self.mime_test_file("t.tar", "application/x-tar")
self.mime_test_file("t.tar.foo", "application/x-tar")
self.mime_test_file("t.tar.lz", "application/x-tar", "lzip")
self.mime_test_file("t.tar.bz2", "application/x-tar", "bzip2")
self.mime_test_file("t.tbz2", "application/x-tar", "bzip2")
@ -85,48 +85,49 @@ class TestMime (unittest.TestCase):
# file(1) does not recognize .lzma files
#self.mime_test_file("t.tar.lzma", "application/x-tar", "lzma")
#self.mime_test_file("t.tar.lzma.foo", "application/x-tar", "lzma")
self.mime_test_file("t.txt.gz", "application/x-gzip", None)
self.mime_test_file("t.txt.gz.foo", "application/x-gzip", None)
self.mime_test_file("t.txt.xz", "application/x-xz", None)
self.mime_test_file("t.txt.xz.foo", "application/x-xz", None)
self.mime_test_file("t.txt.Z", "application/x-compress", None)
self.mime_test_file("t.txt.Z.foo", "application/x-compress", None)
self.mime_test_file("t.jar", "application/zip", None)
self.mime_test_file("t.jar.foo", "application/zip", None)
self.mime_test_file("t.zip", "application/zip", None)
self.mime_test_file("t.zip.foo", "application/zip", None)
self.mime_test_file("t.ace", "application/x-ace", None)
self.mime_test_file("t.ace.foo", "application/x-ace", None)
self.mime_test_file("t.txt.a", "application/x-archive", None)
self.mime_test_file("t.txt.a.foo", "application/x-archive", None)
self.mime_test_file("t.lha", "application/x-lha", None)
self.mime_test_file("t.lzh", "application/x-lha", None)
self.mime_test_file("t.lha.foo", "application/x-lha", None)
self.mime_test_file("t.txt.gz", "application/x-gzip")
self.mime_test_file("t.txt.gz.foo", "application/x-gzip")
self.mime_test_file("t.txt.xz", "application/x-xz")
self.mime_test_file("t.txt.xz.foo", "application/x-xz")
self.mime_test_file("t.txt.Z", "application/x-compress")
self.mime_test_file("t.txt.Z.foo", "application/x-compress")
self.mime_test_file("t.jar", "application/zip")
self.mime_test_file("t.jar.foo", "application/zip")
self.mime_test_file("t.zip", "application/zip")
self.mime_test_file("t.zip.foo", "application/zip")
self.mime_test_file("t.ace", "application/x-ace")
self.mime_test_file("t.ace.foo", "application/x-ace")
self.mime_test_file("t.txt.a", "application/x-archive")
self.mime_test_file("t.txt.a.foo", "application/x-archive")
self.mime_test_file("t.lha", "application/x-lha")
self.mime_test_file("t.lzh", "application/x-lha")
self.mime_test_file("t.lha.foo", "application/x-lha")
# file(1) does not recognize .alz files
#self.mime_test_file("t.alz", "application/x-alzip", None)
#self.mime_test_file("t.alz.foo", "application/x-alzip", None)
self.mime_test_file("t.arc", "application/x-arc", None)
self.mime_test_file("t.arc.foo", "application/x-arc", None)
#self.mime_test_file("t.alz", "application/x-alzip")
#self.mime_test_file("t.alz.foo", "application/x-alzip")
self.mime_test_file("t.arc", "application/x-arc")
self.mime_test_file("t.arc.foo", "application/x-arc")
# file(1) does not recognize .lrz files
#self.mime_test_file("t.txt.lrz", "application/x-lrzip", None)
#self.mime_test_file("t.txt.lrz.foo", "application/x-lrzip", None)
self.mime_test_file("t.txt.rz", "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.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)
self.mime_test_file("t.ape", "audio/x-ape", None)
self.mime_test_file("t.ape.foo", "audio/x-ape", None)
#self.mime_test_file("t.txt.lrz", "application/x-lrzip")
#self.mime_test_file("t.txt.lrz.foo", "application/x-lrzip")
self.mime_test_file("t.txt.rz", "application/x-rzip")
self.mime_test_file("t.txt.rz.foo", "application/x-rzip")
self.mime_test_file("t.zoo", "application/x-zoo")
self.mime_test_file("t.zoo.foo", "application/x-zoo")
self.mime_test_file("t.dms", "application/x-dms")
self.mime_test_file("t.dms.foo", "application/x-dms")
self.mime_test_file("t.ape", "audio/x-ape")
self.mime_test_file("t.ape.foo", "audio/x-ape")
# file(1) does not recognize .shn files
#self.mime_test_file("t.shn", "audio/x-shn", None)
#self.mime_test_file("t.shn.foo", "audio/x-shn", None)
self.mime_test_file("t.flac", "audio/flac", None)
self.mime_test_file("t.flac.foo", "audio/flac", None)
self.mime_test_file("t.adf", "application/x-adf", None)
self.mime_test_file("t.adf.foo", "application/x-adf", None)
self.mime_test_file("t.chm", "application/x-chm", None)
self.mime_test_file("t.chm.foo", "application/x-chm", None)
#self.mime_test_file("t.shn", "audio/x-shn")
#self.mime_test_file("t.shn.foo", "audio/x-shn")
self.mime_test_file("t.flac", "audio/flac")
self.mime_test_file("t.flac.foo", "audio/flac")
self.mime_test_file("t.adf", "application/x-adf")
self.mime_test_file("t.adf.foo", "application/x-adf")
self.mime_test_file("t.chm", "application/x-chm")
self.mime_test_file("t.chm.foo", "application/x-chm")
self.mime_test_file("t.iso", "application/x-iso9660-image")
@needs_program('file')
@needs_program('lzip')
@ -157,20 +158,20 @@ class TestMime (unittest.TestCase):
self.mime_test_file("t.tar.Z.foo", "application/x-tar", "compress")
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)
self.mime_test_mimedb("t .bz2", "application/x-bzip2", None)
self.mime_test_mimedb("t.cab", "application/x-cab", None)
self.mime_test_mimedb("t.cpio", "application/x-cpio", None)
self.mime_test_mimedb("t.deb", "application/x-debian-package", None)
self.mime_test_mimedb("t.gz", "application/x-gzip", None)
self.mime_test_mimedb("t.jar", "application/java-archive", None)
self.mime_test_mimedb("t.lzma", "application/x-lzma", None)
self.mime_test_mimedb("t.txt.lz", "application/x-lzip", None)
self.mime_test_mimedb("t.lzo", "application/x-lzop", None)
self.mime_test_mimedb("t.rar", ("application/rar", "application/x-rar"), None)
self.mime_test_mimedb("t.rpm", ("application/x-redhat-package-manager", "application/x-rpm"), None)
self.mime_test_mimedb("t.tar", "application/x-tar", None)
self.mime_test_mimedb("t .7z", "application/x-7z-compressed")
self.mime_test_mimedb("t.arj", "application/x-arj")
self.mime_test_mimedb("t .bz2", "application/x-bzip2")
self.mime_test_mimedb("t.cab", "application/x-cab")
self.mime_test_mimedb("t.cpio", "application/x-cpio")
self.mime_test_mimedb("t.deb", "application/x-debian-package")
self.mime_test_mimedb("t.gz", "application/x-gzip")
self.mime_test_mimedb("t.jar", "application/java-archive")
self.mime_test_mimedb("t.lzma", "application/x-lzma")
self.mime_test_mimedb("t.txt.lz", "application/x-lzip")
self.mime_test_mimedb("t.lzo", "application/x-lzop")
self.mime_test_mimedb("t.rar", ("application/rar", "application/x-rar"))
self.mime_test_mimedb("t.rpm", ("application/x-redhat-package-manager", "application/x-rpm"))
self.mime_test_mimedb("t.tar", "application/x-tar")
self.mime_test_mimedb("t.tar.bz2", "application/x-tar", "bzip2")
self.mime_test_mimedb("t.tar.gz", "application/x-tar", "gzip")
self.mime_test_mimedb("t.tar.lzma", "application/x-tar", "lzma")
@ -180,23 +181,24 @@ class TestMime (unittest.TestCase):
self.mime_test_mimedb("t.taz", "application/x-tar", "gzip")
self.mime_test_mimedb("t.tbz2", "application/x-tar", "bzip2")
self.mime_test_mimedb("t.tgz", "application/x-tar", "gzip")
self.mime_test_mimedb("t.txt.gz", "application/x-gzip", None)
self.mime_test_mimedb("t .xz", "application/x-xz", None)
self.mime_test_mimedb("t.Z", "application/x-compress", None)
self.mime_test_mimedb("t.zip", ("application/zip", "application/x-zip-compressed"), None)
self.mime_test_mimedb("t.ace", "application/x-ace", None)
self.mime_test_mimedb("t.a", "application/x-archive", None)
self.mime_test_mimedb("t.lha", "application/x-lha", None)
self.mime_test_mimedb("t.lzh", "application/x-lzh", None)
self.mime_test_mimedb("t.alz", "application/x-alzip", None)
self.mime_test_mimedb("t.arc", "application/x-arc", 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.zoo", "application/x-zoo", None)
self.mime_test_mimedb("t.dms", "application/x-dms", None)
self.mime_test_mimedb("t.shar", "application/x-shar", None)
self.mime_test_mimedb("t.ape", "audio/x-ape", None)
self.mime_test_mimedb("t.shn", "audio/x-shn", None)
self.mime_test_mimedb("t.flac", "audio/flac", None)
self.mime_test_mimedb("t.adf", "application/x-adf", None)
self.mime_test_mimedb("t.chm", "application/x-chm", None)
self.mime_test_mimedb("t.txt.gz", "application/x-gzip")
self.mime_test_mimedb("t .xz", "application/x-xz")
self.mime_test_mimedb("t.Z", "application/x-compress")
self.mime_test_mimedb("t.zip", ("application/zip", "application/x-zip-compressed"))
self.mime_test_mimedb("t.ace", "application/x-ace")
self.mime_test_mimedb("t.a", "application/x-archive")
self.mime_test_mimedb("t.lha", "application/x-lha")
self.mime_test_mimedb("t.lzh", "application/x-lzh")
self.mime_test_mimedb("t.alz", "application/x-alzip")
self.mime_test_mimedb("t.arc", "application/x-arc")
self.mime_test_mimedb("t.lrz", "application/x-lrzip")
self.mime_test_mimedb("t.rz", "application/x-rzip")
self.mime_test_mimedb("t.zoo", "application/x-zoo")
self.mime_test_mimedb("t.dms", "application/x-dms")
self.mime_test_mimedb("t.shar", "application/x-shar")
self.mime_test_mimedb("t.ape", "audio/x-ape")
self.mime_test_mimedb("t.shn", "audio/x-shn")
self.mime_test_mimedb("t.flac", "audio/flac")
self.mime_test_mimedb("t.adf", "application/x-adf")
self.mime_test_mimedb("t.chm", "application/x-chm")
self.mime_test_mimedb("t.iso", "application/x-iso9660-image")