diff --git a/doc/changelog.txt b/doc/changelog.txt index 3d79dd9..62e6842 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -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) diff --git a/doc/patool.1 b/doc/patool.1 index 78943d0..129b30c 100644 --- a/doc/patool.1 +++ b/doc/patool.1 @@ -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 diff --git a/doc/patool.txt b/doc/patool.txt index bf085b5..a2bfb55 100644 --- a/doc/patool.txt +++ b/doc/patool.txt @@ -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 diff --git a/patoolib/__init__.py b/patoolib/__init__.py index 014795d..8e49954 100644 --- a/patoolib/__init__.py +++ b/patoolib/__init__.py @@ -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',), }, diff --git a/patoolib/programs/py_echo.py b/patoolib/programs/py_echo.py index 59c822a..3298387 100644 --- a/patoolib/programs/py_echo.py +++ b/patoolib/programs/py_echo.py @@ -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 diff --git a/patoolib/programs/shorten.py b/patoolib/programs/shorten.py new file mode 100644 index 0000000..6b27f1c --- /dev/null +++ b/patoolib/programs/shorten.py @@ -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 . +"""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}) diff --git a/setup.py b/setup.py index 2a88c17..83b5826 100644 --- a/setup.py +++ b/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 diff --git a/tests/__init__.py b/tests/__init__.py index dd1e0eb..2be7915 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -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) diff --git a/tests/test_archives.py b/tests/test_archives.py index 7d01c4b..505e122 100644 --- a/tests/test_archives.py +++ b/tests/test_archives.py @@ -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") diff --git a/tests/test_foo_archives.py b/tests/test_foo_archives.py index 561ba1f..4926ed6 100644 --- a/tests/test_foo_archives.py +++ b/tests/test_foo_archives.py @@ -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')