Support archmage CHM files.
This commit is contained in:
parent
9e5b3e5092
commit
eaf3aab677
|
@ -1,7 +1,9 @@
|
||||||
0.18 "" (released xx.xx.xxxx)
|
0.18 "" (released xx.xx.xxxx)
|
||||||
|
|
||||||
* Fixed unadf archive listing.
|
* Fixed unadf archive listing.
|
||||||
* Added support for Python 3.x and depend on Python >= 2.7.
|
* Added support for Python 3.x.
|
||||||
|
* Use importlib to find program modules and depend on Python >= 2.7.
|
||||||
|
* Added support for archmage handling CHM (.chm) archives.
|
||||||
|
|
||||||
|
|
||||||
0.17 "I am Bruce Lee" (released 4.8.2012)
|
0.17 "I am Bruce Lee" (released 4.8.2012)
|
||||||
|
|
|
@ -29,9 +29,8 @@ ArchiveCommands = ('list', 'extract', 'test', 'create')
|
||||||
# Supported archive formats
|
# Supported archive formats
|
||||||
ArchiveFormats = (
|
ArchiveFormats = (
|
||||||
'7z', 'ace', 'adf', 'alzip', 'ape', 'ar', 'arc', 'arj',
|
'7z', 'ace', 'adf', 'alzip', 'ape', 'ar', 'arc', 'arj',
|
||||||
'bzip2', 'cab', 'compress', 'cpio', 'deb', 'dms',
|
'bzip2', 'cab', 'chm', 'compress', 'cpio', 'deb', 'dms',
|
||||||
'flac', 'gzip',
|
'flac', 'gzip', 'lrzip', 'lzh', 'lzip', 'lzma', 'lzop',
|
||||||
'lrzip', 'lzh', 'lzip', 'lzma', 'lzop',
|
|
||||||
'rar', 'rpm', 'rzip', 'shar', 'shn', 'tar', 'xz',
|
'rar', 'rpm', 'rzip', 'shar', 'shn', 'tar', 'xz',
|
||||||
'zip', 'zoo')
|
'zip', 'zoo')
|
||||||
|
|
||||||
|
@ -55,6 +54,7 @@ ArchiveMimetypes = {
|
||||||
'application/x-cab': 'cab',
|
'application/x-cab': 'cab',
|
||||||
'application/vnd.ms-cab-compressed': 'cab',
|
'application/vnd.ms-cab-compressed': 'cab',
|
||||||
'application/x-arj': 'arj',
|
'application/x-arj': 'arj',
|
||||||
|
'application/x-chm': 'chm',
|
||||||
'application/x-cpio': 'cpio',
|
'application/x-cpio': 'cpio',
|
||||||
'application/x-redhat-package-manager': 'rpm',
|
'application/x-redhat-package-manager': 'rpm',
|
||||||
'application/x-rpm': 'rpm',
|
'application/x-rpm': 'rpm',
|
||||||
|
@ -125,6 +125,10 @@ ArchivePrograms = {
|
||||||
'list': ('cabextract', '7z'),
|
'list': ('cabextract', '7z'),
|
||||||
'test': ('cabextract', '7z'),
|
'test': ('cabextract', '7z'),
|
||||||
},
|
},
|
||||||
|
'chm': {
|
||||||
|
'extract': ('archmage',),
|
||||||
|
'test': ('archmage',),
|
||||||
|
},
|
||||||
'flac': {
|
'flac': {
|
||||||
'extract': ('flac',),
|
'extract': ('flac',),
|
||||||
'test': ('flac',),
|
'test': ('flac',),
|
||||||
|
@ -629,5 +633,5 @@ def diff (archive1, archive2, verbose=False):
|
||||||
|
|
||||||
|
|
||||||
def repack (archive1, archive2, verbose=False):
|
def repack (archive1, archive2, verbose=False):
|
||||||
"""Repacke archive to different file and/or format."""
|
"""Repack archive to different file and/or format."""
|
||||||
return handle_archive(archive1, 'repack', archive2, verbose=verbose)
|
return handle_archive(archive1, 'repack', archive2, verbose=verbose)
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
# -*- 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 <http://www.gnu.org/licenses/>.
|
||||||
|
"""Archive commands for the archmage program."""
|
||||||
|
import os
|
||||||
|
from .. import util
|
||||||
|
|
||||||
|
|
||||||
|
def extract_chm (archive, compression, cmd, **kwargs):
|
||||||
|
"""Extract a CHM archive."""
|
||||||
|
# archmage can only extract in non-existing directories
|
||||||
|
# so a nice dirname is created
|
||||||
|
name = util.get_single_outfile("", archive)
|
||||||
|
outdir = os.path.join(kwargs['outdir'], name)
|
||||||
|
return [cmd, '-x', os.path.abspath(archive), outdir]
|
||||||
|
|
||||||
|
|
||||||
|
def test_chm (archive, compression, cmd, **kwargs):
|
||||||
|
"""Test a CHM archive."""
|
||||||
|
return [cmd, '-d', os.path.abspath(archive)]
|
|
@ -70,6 +70,7 @@ def add_mimedb_data(mimedb):
|
||||||
add_mimetype(mimedb, 'audio/x-ape', '.ape')
|
add_mimetype(mimedb, 'audio/x-ape', '.ape')
|
||||||
add_mimetype(mimedb, 'audio/x-shn', '.shn')
|
add_mimetype(mimedb, 'audio/x-shn', '.shn')
|
||||||
add_mimetype(mimedb, 'audio/flac', '.flac')
|
add_mimetype(mimedb, 'audio/flac', '.flac')
|
||||||
|
add_mimetype(mimedb, 'application/x-chm', '.chm')
|
||||||
|
|
||||||
|
|
||||||
def add_mimetype(mimedb, mimetype, extension):
|
def add_mimetype(mimedb, mimetype, extension):
|
||||||
|
@ -274,6 +275,7 @@ FileText2Mime = {
|
||||||
"DMS archive data": "application/x-dms",
|
"DMS archive data": "application/x-dms",
|
||||||
"Monkey's Audio": "audio/x-ape",
|
"Monkey's Audio": "audio/x-ape",
|
||||||
"FLAC audio bitstream data": "audio/flac",
|
"FLAC audio bitstream data": "audio/flac",
|
||||||
|
"MS Windows HtmlHelp Data": "application/x-chm",
|
||||||
}
|
}
|
||||||
|
|
||||||
def guess_mime_file_text (file_prog, filename):
|
def guess_mime_file_text (file_prog, filename):
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
# -*- 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 <http://www.gnu.org/licenses/>.
|
||||||
|
from . import ArchiveTest
|
||||||
|
from .. import needs_program
|
||||||
|
|
||||||
|
class TestArchmage (ArchiveTest):
|
||||||
|
|
||||||
|
program = 'archmage'
|
||||||
|
|
||||||
|
@needs_program(program)
|
||||||
|
def test_archmage (self):
|
||||||
|
self.archive_extract('t.chm', check=None)
|
||||||
|
self.archive_test('t.chm')
|
||||||
|
|
||||||
|
@needs_program('file')
|
||||||
|
@needs_program(program)
|
||||||
|
def test_archmage_file (self):
|
||||||
|
self.archive_extract('t.chm.foo', check=None)
|
||||||
|
self.archive_test('t.chm.foo')
|
Binary file not shown.
Binary file not shown.
|
@ -125,6 +125,8 @@ class TestMime (unittest.TestCase):
|
||||||
self.mime_test_file("t.flac.foo", "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", "application/x-adf", None)
|
||||||
self.mime_test_file("t.adf.foo", "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)
|
||||||
|
|
||||||
@needs_program('file')
|
@needs_program('file')
|
||||||
@needs_program('lzip')
|
@needs_program('lzip')
|
||||||
|
@ -197,3 +199,4 @@ class TestMime (unittest.TestCase):
|
||||||
self.mime_test_mimedb("t.shn", "audio/x-shn", 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.flac", "audio/flac", None)
|
||||||
self.mime_test_mimedb("t.adf", "application/x-adf", None)
|
self.mime_test_mimedb("t.adf", "application/x-adf", None)
|
||||||
|
self.mime_test_mimedb("t.chm", "application/x-chm", None)
|
||||||
|
|
Loading…
Reference in New Issue