diff --git a/doc/changelog.txt b/doc/changelog.txt
index 579e0cf..7643e9e 100644
--- a/doc/changelog.txt
+++ b/doc/changelog.txt
@@ -1,7 +1,9 @@
0.18 "" (released xx.xx.xxxx)
* 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)
diff --git a/patoolib/__init__.py b/patoolib/__init__.py
index 1ba29f4..92ffd3c 100644
--- a/patoolib/__init__.py
+++ b/patoolib/__init__.py
@@ -29,9 +29,8 @@ ArchiveCommands = ('list', 'extract', 'test', 'create')
# Supported archive formats
ArchiveFormats = (
'7z', 'ace', 'adf', 'alzip', 'ape', 'ar', 'arc', 'arj',
- 'bzip2', 'cab', 'compress', 'cpio', 'deb', 'dms',
- 'flac', 'gzip',
- 'lrzip', 'lzh', 'lzip', 'lzma', 'lzop',
+ 'bzip2', 'cab', 'chm', 'compress', 'cpio', 'deb', 'dms',
+ 'flac', 'gzip', 'lrzip', 'lzh', 'lzip', 'lzma', 'lzop',
'rar', 'rpm', 'rzip', 'shar', 'shn', 'tar', 'xz',
'zip', 'zoo')
@@ -55,6 +54,7 @@ ArchiveMimetypes = {
'application/x-cab': 'cab',
'application/vnd.ms-cab-compressed': 'cab',
'application/x-arj': 'arj',
+ 'application/x-chm': 'chm',
'application/x-cpio': 'cpio',
'application/x-redhat-package-manager': 'rpm',
'application/x-rpm': 'rpm',
@@ -125,6 +125,10 @@ ArchivePrograms = {
'list': ('cabextract', '7z'),
'test': ('cabextract', '7z'),
},
+ 'chm': {
+ 'extract': ('archmage',),
+ 'test': ('archmage',),
+ },
'flac': {
'extract': ('flac',),
'test': ('flac',),
@@ -629,5 +633,5 @@ def diff (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)
diff --git a/patoolib/programs/archmage.py b/patoolib/programs/archmage.py
new file mode 100644
index 0000000..04fec1f
--- /dev/null
+++ b/patoolib/programs/archmage.py
@@ -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 .
+"""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)]
diff --git a/patoolib/util.py b/patoolib/util.py
index 66269c6..1d07a56 100644
--- a/patoolib/util.py
+++ b/patoolib/util.py
@@ -70,6 +70,7 @@ def add_mimedb_data(mimedb):
add_mimetype(mimedb, 'audio/x-ape', '.ape')
add_mimetype(mimedb, 'audio/x-shn', '.shn')
add_mimetype(mimedb, 'audio/flac', '.flac')
+ add_mimetype(mimedb, 'application/x-chm', '.chm')
def add_mimetype(mimedb, mimetype, extension):
@@ -274,6 +275,7 @@ FileText2Mime = {
"DMS archive data": "application/x-dms",
"Monkey's Audio": "audio/x-ape",
"FLAC audio bitstream data": "audio/flac",
+ "MS Windows HtmlHelp Data": "application/x-chm",
}
def guess_mime_file_text (file_prog, filename):
diff --git a/tests/archives/test_archmage.py b/tests/archives/test_archmage.py
new file mode 100644
index 0000000..2674aa7
--- /dev/null
+++ b/tests/archives/test_archmage.py
@@ -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 .
+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')
diff --git a/tests/data/t.chm b/tests/data/t.chm
new file mode 100644
index 0000000..9a328d8
Binary files /dev/null and b/tests/data/t.chm differ
diff --git a/tests/data/t.chm.foo b/tests/data/t.chm.foo
new file mode 100644
index 0000000..9a328d8
Binary files /dev/null and b/tests/data/t.chm.foo differ
diff --git a/tests/test_mime.py b/tests/test_mime.py
index 661f410..3c257a0 100644
--- a/tests/test_mime.py
+++ b/tests/test_mime.py
@@ -125,6 +125,8 @@ class TestMime (unittest.TestCase):
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)
@needs_program('file')
@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.flac", "audio/flac", None)
self.mime_test_mimedb("t.adf", "application/x-adf", None)
+ self.mime_test_mimedb("t.chm", "application/x-chm", None)