diff --git a/doc/changelog.txt b/doc/changelog.txt index 62e6842..429c2a1 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -2,6 +2,7 @@ * Added support for Monkey's Audio Compressor handling APE (.ape) files. * Added support for shorten handling SHN (.shn) files. +* Added support for flac handling FLAC (.flac) files. 0.16 "Game of thrones" (released 12.5.2012) diff --git a/doc/patool.1 b/doc/patool.1 index 129b30c..3282931 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), SHN (.shn), TAR (.tar), -XZ (.xz), ZIP (.zip, .jar) and ZOO (.zoo) formats. +FLAC (.flac), 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 a2bfb55..3d10e60 100644 --- a/doc/patool.txt +++ b/doc/patool.txt @@ -25,12 +25,12 @@ DESCRIPTION patool supports 7z (.7z), ACE (.ace), ALZIP (.alz), APE (.ape), 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), 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). + press (.Z), CPIO (.cpio), DEB (.deb), DMS (.dms), FLAC (.flac), + 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 ar‐ + chive 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 6143c61..b032b40 100644 --- a/patoolib/__init__.py +++ b/patoolib/__init__.py @@ -106,6 +106,10 @@ ArchivePrograms = { 'list': ('py_echo',), }, 'flac': { + 'extract': ('flac',), + 'test': ('flac',), + 'create': ('flac',), + 'list': ('py_echo',), }, 'tar': { None: ('tar', 'star', 'py_tarfile'), diff --git a/patoolib/programs/flac.py b/patoolib/programs/flac.py new file mode 100644 index 0000000..fb08802 --- /dev/null +++ b/patoolib/programs/flac.py @@ -0,0 +1,39 @@ +# -*- 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 flac program.""" +from patoolib import util + +def extract_flac (archive, compression, cmd, **kwargs): + """Decompress a FLAC archive to a WAV file.""" + outfile = util.get_single_outfile(kwargs['outdir'], archive, + extension=".wav") + cmdlist = [cmd, '--decode', archive, '--output-name', outfile] + return cmdlist + + +def create_flac (archive, compression, cmd, *args, **kwargs): + """Compress a WAV file to a FLAC archive.""" + cmdlist = [cmd, args[0], '--output-name', archive] + return cmdlist + + +def test_flac (archive, compression, cmd, **kwargs): + """Test a FLAC file.""" + cmdlist = [cmd, '--test'] + if not kwargs['verbose']: + cmdlist.append('-s') + cmdlist.append(archive) + return cmdlist diff --git a/patoolib/programs/py_echo.py b/patoolib/programs/py_echo.py index 3298387..7b73f8e 100644 --- a/patoolib/programs/py_echo.py +++ b/patoolib/programs/py_echo.py @@ -54,6 +54,10 @@ def list_shn (archive, compression, cmd, **kwargs): """List a SHN archive.""" return stripext(cmd, archive, extension=".wav") +def list_flac (archive, compression, cmd, **kwargs): + """List a FLAC 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/setup.py b/setup.py index 83b5826..59e1066 100644 --- a/setup.py +++ b/setup.py @@ -48,9 +48,10 @@ 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), -SHN (.shn), TAR (.tar), XZ (.xz), ZIP (.zip, .jar) and ZOO (.zoo) formats. +DEB (.deb), DMS (.dms), FLAC (.flac), 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). diff --git a/tests/data/t.flac.flac b/tests/data/t.flac.flac new file mode 100644 index 0000000..e2dd1a6 Binary files /dev/null and b/tests/data/t.flac.flac differ diff --git a/tests/data/t.flac.wav b/tests/data/t.flac.wav new file mode 100644 index 0000000..177b567 Binary files /dev/null and b/tests/data/t.flac.wav differ diff --git a/tests/test_archives.py b/tests/test_archives.py index 505e122..f44d481 100644 --- a/tests/test_archives.py +++ b/tests/test_archives.py @@ -151,6 +151,7 @@ class TestArchives (ArchiveTest): self.archive_list('t.txt.rz') self.archive_list('t.ape') self.archive_list('t.shn') + self.archive_list('t.flac') @needs_program('unzip') def test_unzip (self): @@ -453,3 +454,10 @@ class TestArchives (ArchiveTest): self.program = 'shorten' self.archive_extract('t.shn') self.archive_create('t.shn', srcfile="t.wav") + + @needs_program('flac') + def test_flac (self): + self.program = 'flac' + self.archive_extract('t.flac') + self.archive_test('t.flac') + self.archive_create('t.flac', srcfile="t.wav") diff --git a/tests/test_foo_archives.py b/tests/test_foo_archives.py index 4926ed6..690a78a 100644 --- a/tests/test_foo_archives.py +++ b/tests/test_foo_archives.py @@ -167,6 +167,12 @@ class TestArchives (ArchiveTest): # file(1) does not recognize .lzma files #self.archive_list('t.lzma.foo') self.archive_list('t.txt.lz.foo') + self.archive_list('t.txt.lrz') + self.archive_list('t.txt.rz.foo') + self.archive_list('t.ape.foo') + # file(1) does not recognize .shn files + #self.archive_list('t.shn.foo') + self.archive_list('t.flac.foo') @needs_program('file') @needs_program('unzip') @@ -502,3 +508,11 @@ class TestArchives (ArchiveTest): # self.program = 'shorten' # self.archive_extract('t.shn.foo') # self.archive_create('t.shn.foo', srcfile='t.wav') + + @needs_program('file') + @needs_program('flac') + def test_flac (self): + self.program = 'flac' + self.archive_extract('t.flac.foo') + self.archive_test('t.flac.foo') + self.archive_create('t.flac.foo', srcfile='t.wav', format='flac')