Support SHN (.shn) files with shorten.
This commit is contained in:
parent
448eb7c720
commit
de18ff9ca3
|
@ -1,6 +1,7 @@
|
|||
0.17 "" (released xx.xx.2012)
|
||||
|
||||
* Added support for Monkey's Audio Compressor handling APE (.ape) files.
|
||||
* Added support for shorten handling SHN (.shn) files.
|
||||
|
||||
|
||||
0.16 "Game of thrones" (released 12.5.2012)
|
||||
|
|
|
@ -32,9 +32,9 @@ by the archive file extension.
|
|||
\fBpatool\fP supports 7z (.7z), ACE (.ace), ALZIP (.alz), APE (.ape), AR (.a),
|
||||
ARC (.arc), ARJ (.arj),
|
||||
BZIP2 (.bz2), CAB (.cab), compress (.Z), CPIO (.cpio), DEB (.deb), DMS (.dms),
|
||||
GZIP (.gz), LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP (.lzo),
|
||||
RPM (.rpm), RAR (.rar), RZIP (.rz), TAR (.tar), XZ (.xz), ZIP (.zip, .jar) and
|
||||
ZOO (.zoo) formats.
|
||||
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).
|
||||
.PP
|
||||
|
|
|
@ -27,10 +27,10 @@ DESCRIPTION
|
|||
AR (.a), ARC (.arc), ARJ (.arj), BZIP2 (.bz2), CAB (.cab), com‐
|
||||
press (.Z), CPIO (.cpio), DEB (.deb), DMS (.dms), GZIP (.gz),
|
||||
LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz), LZMA (.lzma), LZOP
|
||||
(.lzo), RPM (.rpm), RAR (.rar), RZIP (.rz), TAR (.tar), XZ
|
||||
(.xz), ZIP (.zip, .jar) and ZOO (.zoo) formats. It relies on
|
||||
helper applications to handle those archive formats (for exam‐
|
||||
ple bzip2 for BZIP2 archives).
|
||||
(.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 (.tar), ZIP (.zip), BZIP2 (.bz2) and
|
||||
GZIP (.gz) are supported natively and do not require helper
|
||||
|
|
|
@ -24,7 +24,8 @@ ArchiveCommands = ('list', 'extract', 'test', 'create')
|
|||
# Supported archive formats
|
||||
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')
|
||||
'lzip', 'lzma', 'lzop', 'rar', 'rpm', 'rzip', 'shn', 'tar', 'xz',
|
||||
'zip', 'zoo')
|
||||
|
||||
# Supported compressions (used with tar for example)
|
||||
# Note that all compressions must also be archive formats
|
||||
|
@ -64,6 +65,7 @@ ArchiveMimetypes = {
|
|||
'application/x-zoo': 'zoo',
|
||||
'application/x-dms': 'dms',
|
||||
'audio/x-ape': 'ape',
|
||||
'audio/x-shn': 'shn',
|
||||
}
|
||||
|
||||
# List of programs supporting the given archive format and command.
|
||||
|
@ -188,6 +190,11 @@ ArchivePrograms = {
|
|||
'list': ('py_echo',),
|
||||
'create': ('rzip',),
|
||||
},
|
||||
'shn': {
|
||||
'extract': ('shorten',),
|
||||
'list': ('py_echo',),
|
||||
'create': ('shorten',),
|
||||
},
|
||||
'xz': {
|
||||
None: ('xz',),
|
||||
},
|
||||
|
|
|
@ -50,6 +50,10 @@ def list_ape (archive, compression, cmd, **kwargs):
|
|||
"""List an APE archive."""
|
||||
return stripext(cmd, archive, extension=".wav")
|
||||
|
||||
def list_shn (archive, compression, cmd, **kwargs):
|
||||
"""List a SHN archive."""
|
||||
return stripext(cmd, archive, extension=".wav")
|
||||
|
||||
def stripext (cmd, archive, extension=""):
|
||||
"""Print the name without suffix."""
|
||||
print util.stripext(archive)+extension
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
# -*- 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 shorten program."""
|
||||
from patoolib import util
|
||||
|
||||
def extract_shn (archive, compression, cmd, **kwargs):
|
||||
"""Decompress a SHN archive to a WAV file."""
|
||||
cmdlist = [util.shell_quote(cmd)]
|
||||
outfile = util.get_single_outfile(kwargs['outdir'], archive,
|
||||
extension=".wav")
|
||||
cmdlist.extend(['-x', '-', util.shell_quote(outfile), '<',
|
||||
util.shell_quote(archive)])
|
||||
return (cmdlist, {'shell': True})
|
||||
|
||||
|
||||
def create_shn (archive, compression, cmd, *args, **kwargs):
|
||||
"""Compress a WAV file to a SHN archive."""
|
||||
cmdlist = [util.shell_quote(cmd)]
|
||||
cmdlist.extend(['-', util.shell_quote(archive), '<',
|
||||
util.shell_quote(args[0])])
|
||||
return (cmdlist, {'shell': True})
|
10
setup.py
10
setup.py
|
@ -48,11 +48,11 @@ fallback by the archive file extension.
|
|||
|
||||
patool supports 7z (.7z), ACE (.ace), ALZIP (.alz), APE (.ape), AR (.a),
|
||||
ARC (.arc), ARJ (.arj), BZIP2 (.bz2), CAB (.cab), compress (.Z), CPIO (.cpio),
|
||||
DEB (.deb), DMS (.dms), GZIP (.gz), LRZIP (.lrz), LZH (.lha, .lzh), LZIP (.lz),
|
||||
LZMA (.lzma), LZOP (.lzo), RPM (.rpm), RAR (.rar), RZIP (.rz), 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).
|
||||
DEB (.deb), DMS (.dms), 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).
|
||||
|
||||
The archive formats TAR (.tar), ZIP (.zip), BZIP2 (.bz2) and GZIP (.gz)
|
||||
are supported natively and do not require helper applications to be
|
||||
|
|
|
@ -112,7 +112,7 @@ class ArchiveTest (unittest.TestCase):
|
|||
program = 'bzip2'
|
||||
elif self.program == 'zip':
|
||||
program = 'unzip'
|
||||
elif self.program == 'rzip':
|
||||
elif self.program in ('rzip', 'shorten'):
|
||||
program = 'py_echo'
|
||||
command = 'list'
|
||||
patoolib._handle_archive(archive, command, program=program)
|
||||
|
|
|
@ -150,6 +150,7 @@ class TestArchives (ArchiveTest):
|
|||
self.archive_list('t.txt.lrz')
|
||||
self.archive_list('t.txt.rz')
|
||||
self.archive_list('t.ape')
|
||||
self.archive_list('t.shn')
|
||||
|
||||
@needs_program('unzip')
|
||||
def test_unzip (self):
|
||||
|
@ -446,3 +447,9 @@ class TestArchives (ArchiveTest):
|
|||
self.archive_extract('t.ape')
|
||||
self.archive_test('t.ape')
|
||||
self.archive_create('t.ape', srcfile="t.wav")
|
||||
|
||||
@needs_program('shorten')
|
||||
def test_shorten (self):
|
||||
self.program = 'shorten'
|
||||
self.archive_extract('t.shn')
|
||||
self.archive_create('t.shn', srcfile="t.wav")
|
||||
|
|
|
@ -460,6 +460,7 @@ class TestArchives (ArchiveTest):
|
|||
self.archive_extract('t.arc.foo')
|
||||
|
||||
# file(1) does not recognize .lrz files
|
||||
#@needs_program('file')
|
||||
#@needs_program('lrzip')
|
||||
#def test_lrzip (self):
|
||||
# self.program = 'lrzip'
|
||||
|
@ -492,3 +493,12 @@ class TestArchives (ArchiveTest):
|
|||
def test_mac (self):
|
||||
self.program = 'mac'
|
||||
self.archive_extract('t.ape.foo')
|
||||
self.archive_create('t.ape.foo', srcfile='t.wav')
|
||||
|
||||
# file(1) does not recognize .shn files
|
||||
#@needs_program('file')
|
||||
#@needs_program('shorten')
|
||||
#def test_shorten (self):
|
||||
# self.program = 'shorten'
|
||||
# self.archive_extract('t.shn.foo')
|
||||
# self.archive_create('t.shn.foo', srcfile='t.wav')
|
||||
|
|
Loading…
Reference in New Issue