From 66001fde36dc6adfc57bb4ac28a667988c182fbf Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Thu, 17 May 2012 10:43:21 +0200 Subject: [PATCH] Add boilerplate support for Monkey's Audio Compressors APE format. --- patoolib/__init__.py | 6 +++++- patoolib/programs/mac.py | 23 +++++++++++++++++++++++ patoolib/util.py | 14 ++++++++++++++ tests/data/t.ape | Bin 0 -> 2616 bytes tests/data/t.ape.foo | Bin 0 -> 2616 bytes tests/test_archives.py | 5 +++++ tests/test_foo_archives.py | 5 +++++ tests/test_mime.py | 3 +++ 8 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 patoolib/programs/mac.py create mode 100644 tests/data/t.ape create mode 100644 tests/data/t.ape.foo diff --git a/patoolib/__init__.py b/patoolib/__init__.py index e7792af..4cc8f20 100644 --- a/patoolib/__init__.py +++ b/patoolib/__init__.py @@ -22,7 +22,7 @@ from patoolib import util ArchiveCommands = ('list', 'extract', 'test', 'create') # 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', 'lzip', 'lzma', 'lzop', 'rar', 'rpm', 'rzip', 'tar', 'xz', 'zip', 'zoo') @@ -63,6 +63,7 @@ ArchiveMimetypes = { 'application/x-rzip': 'rzip', 'application/x-zoo': 'zoo', 'application/x-dms': 'dms', + 'audio/x-ape': 'ape', } # List of programs supporting the given archive format and command. @@ -79,6 +80,9 @@ ArchivePrograms = { 'test': ('unalz',), 'list': ('unalz',), }, + 'ape': { + None: ('mac',), + }, 'ar': { None: ('ar',), }, diff --git a/patoolib/programs/mac.py b/patoolib/programs/mac.py new file mode 100644 index 0000000..9730ddf --- /dev/null +++ b/patoolib/programs/mac.py @@ -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 . +"""Archive commands for the MAC.exe program.""" + +def extract_ape (archive, compression, cmd, **kwargs): + """Extract an APE archive.""" + cmdlist = [cmd] + # XXX todo + return cmdlist + diff --git a/patoolib/util.py b/patoolib/util.py index 395f30c..21a44a6 100644 --- a/patoolib/util.py +++ b/patoolib/util.py @@ -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-dms', '.dms', strict=False) mimedb.add_type('application/x-zip-compressed', '.crx', strict=False) +mimedb.add_type('audio/x-ape', '.ape', strict=False) class PatoolError (StandardError): @@ -243,6 +244,7 @@ FileText2Mime = { "ARC archive data": "application/x-arc", "Zoo archive data": "application/x-zoo", "DMS archive data": "application/x-dms", + "Monkey's Audio": "audio/x-ape", } def guess_mime_file_text (file_prog, filename): @@ -378,6 +380,7 @@ def find_program (program): path = os.environ['PATH'] if os.name == 'nt': path = append_to_path(path, get_nt_7z_dir()) + path = append_to_path(path, get_nt_mac_dir()) return find_executable(program, path=path) @@ -404,6 +407,17 @@ def get_nt_7z_dir (): 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): """Return comma separated string, and last entry appended with ' or '.""" if len(alist) > 1: diff --git a/tests/data/t.ape b/tests/data/t.ape new file mode 100644 index 0000000000000000000000000000000000000000..68674078aa82388c0d555869dbb85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