Add boilerplate support for Monkey's Audio Compressors APE format.
This commit is contained in:
parent
b3b48adf39
commit
66001fde36
|
@ -22,7 +22,7 @@ from patoolib import util
|
||||||
ArchiveCommands = ('list', 'extract', 'test', 'create')
|
ArchiveCommands = ('list', 'extract', 'test', 'create')
|
||||||
|
|
||||||
# Supported archive formats
|
# Supported archive formats
|
||||||
ArchiveFormats = ('7z', 'ace', 'alzip', 'ar', 'arc', 'arj', 'bzip2',
|
ArchiveFormats = ('7z', 'ace', 'alzip', 'ape', 'ar', 'arc', 'arj', 'bzip2',
|
||||||
'cab', 'compress', 'cpio', 'deb', 'dms', 'gzip', 'lrzip', 'lzh',
|
'cab', 'compress', 'cpio', 'deb', 'dms', 'gzip', 'lrzip', 'lzh',
|
||||||
'lzip', 'lzma', 'lzop', 'rar', 'rpm', 'rzip', 'tar', 'xz', 'zip', 'zoo')
|
'lzip', 'lzma', 'lzop', 'rar', 'rpm', 'rzip', 'tar', 'xz', 'zip', 'zoo')
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ ArchiveMimetypes = {
|
||||||
'application/x-rzip': 'rzip',
|
'application/x-rzip': 'rzip',
|
||||||
'application/x-zoo': 'zoo',
|
'application/x-zoo': 'zoo',
|
||||||
'application/x-dms': 'dms',
|
'application/x-dms': 'dms',
|
||||||
|
'audio/x-ape': 'ape',
|
||||||
}
|
}
|
||||||
|
|
||||||
# List of programs supporting the given archive format and command.
|
# List of programs supporting the given archive format and command.
|
||||||
|
@ -79,6 +80,9 @@ ArchivePrograms = {
|
||||||
'test': ('unalz',),
|
'test': ('unalz',),
|
||||||
'list': ('unalz',),
|
'list': ('unalz',),
|
||||||
},
|
},
|
||||||
|
'ape': {
|
||||||
|
None: ('mac',),
|
||||||
|
},
|
||||||
'ar': {
|
'ar': {
|
||||||
None: ('ar',),
|
None: ('ar',),
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
# -*- 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 MAC.exe program."""
|
||||||
|
|
||||||
|
def extract_ape (archive, compression, cmd, **kwargs):
|
||||||
|
"""Extract an APE archive."""
|
||||||
|
cmdlist = [cmd]
|
||||||
|
# XXX todo
|
||||||
|
return cmdlist
|
||||||
|
|
|
@ -51,6 +51,7 @@ 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)
|
mimedb.add_type('application/x-dms', '.dms', strict=False)
|
||||||
mimedb.add_type('application/x-zip-compressed', '.crx', strict=False)
|
mimedb.add_type('application/x-zip-compressed', '.crx', strict=False)
|
||||||
|
mimedb.add_type('audio/x-ape', '.ape', strict=False)
|
||||||
|
|
||||||
|
|
||||||
class PatoolError (StandardError):
|
class PatoolError (StandardError):
|
||||||
|
@ -243,6 +244,7 @@ FileText2Mime = {
|
||||||
"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",
|
"DMS archive data": "application/x-dms",
|
||||||
|
"Monkey's Audio": "audio/x-ape",
|
||||||
}
|
}
|
||||||
|
|
||||||
def guess_mime_file_text (file_prog, filename):
|
def guess_mime_file_text (file_prog, filename):
|
||||||
|
@ -378,6 +380,7 @@ def find_program (program):
|
||||||
path = os.environ['PATH']
|
path = os.environ['PATH']
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
path = append_to_path(path, get_nt_7z_dir())
|
path = append_to_path(path, get_nt_7z_dir())
|
||||||
|
path = append_to_path(path, get_nt_mac_dir())
|
||||||
return find_executable(program, path=path)
|
return find_executable(program, path=path)
|
||||||
|
|
||||||
|
|
||||||
|
@ -404,6 +407,17 @@ def get_nt_7z_dir ():
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
def get_nt_program_dir ():
|
||||||
|
"""Return the Windows program files directory."""
|
||||||
|
progvar = "%ProgramFiles%"
|
||||||
|
return os.path.expandvars(progvar)
|
||||||
|
|
||||||
|
|
||||||
|
def get_nt_mac_dir ():
|
||||||
|
"""Return Monkey Audio Compressor (MAC) directory, or an empty string."""
|
||||||
|
return os.path.join(get_nt_program_dir(), "Monkey's Audio")
|
||||||
|
|
||||||
|
|
||||||
def strlist_with_or (alist):
|
def strlist_with_or (alist):
|
||||||
"""Return comma separated string, and last entry appended with ' or '."""
|
"""Return comma separated string, and last entry appended with ' or '."""
|
||||||
if len(alist) > 1:
|
if len(alist) > 1:
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -438,3 +438,8 @@ class TestArchives (ArchiveTest):
|
||||||
self.archive_test('t.dms')
|
self.archive_test('t.dms')
|
||||||
self.archive_extract('t.dms')
|
self.archive_extract('t.dms')
|
||||||
self.archive_list('t.dms')
|
self.archive_list('t.dms')
|
||||||
|
|
||||||
|
@needs_program('mac')
|
||||||
|
def test_mac (self):
|
||||||
|
self.program = 'mac'
|
||||||
|
self.archive_extract('t.ape', singlefile=True)
|
||||||
|
|
|
@ -486,3 +486,8 @@ class TestArchives (ArchiveTest):
|
||||||
# self.archive_extract('t.dms.foo')
|
# self.archive_extract('t.dms.foo')
|
||||||
# self.archive_test('t.dms.foo')
|
# self.archive_test('t.dms.foo')
|
||||||
# self.archive_list('t.dms.foo')
|
# self.archive_list('t.dms.foo')
|
||||||
|
|
||||||
|
@needs_program('mac')
|
||||||
|
def test_mac (self):
|
||||||
|
self.program = 'mac'
|
||||||
|
self.archive_extract('t.ape.foo', singlefile=True)
|
||||||
|
|
|
@ -116,6 +116,8 @@ class TestMime (unittest.TestCase):
|
||||||
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", "application/x-dms", None)
|
||||||
self.mime_test_file("t.dms.foo", "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)
|
||||||
|
|
||||||
@needs_program('file')
|
@needs_program('file')
|
||||||
@needs_program('lzip')
|
@needs_program('lzip')
|
||||||
|
@ -183,3 +185,4 @@ class TestMime (unittest.TestCase):
|
||||||
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)
|
self.mime_test_mimedb("t.dms", "application/x-dms", None)
|
||||||
|
self.mime_test_mimedb("t.ape", "audio/x-ape", None)
|
||||||
|
|
Loading…
Reference in New Issue