From ef8c0e595c3bfc9b4412e379a9eda5b9d25cc8ee Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Sat, 12 May 2012 13:36:59 +0200 Subject: [PATCH] Python module programs now have a py_ suffix. --- patoolib/__init__.py | 30 +++++++++++-------- patoolib/programs/{pybz2.py => py_bz2.py} | 0 patoolib/programs/{echo.py => py_echo.py} | 2 +- patoolib/programs/{pygzip.py => py_gzip.py} | 0 .../programs/{pytarfile.py => py_tarfile.py} | 0 .../programs/{pyzipfile.py => py_zipfile.py} | 0 tests/__init__.py | 6 ++-- tests/test_archives.py | 28 ++++++++--------- tests/test_foo_archives.py | 30 ++++++++++--------- 9 files changed, 51 insertions(+), 45 deletions(-) rename patoolib/programs/{pybz2.py => py_bz2.py} (100%) rename patoolib/programs/{echo.py => py_echo.py} (95%) rename patoolib/programs/{pygzip.py => py_gzip.py} (100%) rename patoolib/programs/{pytarfile.py => py_tarfile.py} (100%) rename patoolib/programs/{pyzipfile.py => py_zipfile.py} (100%) diff --git a/patoolib/__init__.py b/patoolib/__init__.py index 865e25f..112f905 100644 --- a/patoolib/__init__.py +++ b/patoolib/__init__.py @@ -78,6 +78,7 @@ CompressionPrograms = { # List of programs supporting the given archive format and command. # If command is None, the program supports all commands (list, extract, ...) +# Programs starting with "py_" are Python modules. ArchivePrograms = { 'ace': { 'extract': ('unace',), @@ -100,16 +101,16 @@ ArchivePrograms = { }, 'bzip2': { None: ('7z', '7za'), - 'extract': ('pbzip2', 'lbzip2', 'bzip2', 'pybz2'), + 'extract': ('pbzip2', 'lbzip2', 'bzip2', 'py_bz2'), 'test': ('pbzip2', 'lbzip2', 'bzip2'), - 'create': ('pbzip2', 'lbzip2', 'bzip2', 'pybz2'), - 'list': ('echo',), + 'create': ('pbzip2', 'lbzip2', 'bzip2', 'py_bz2'), + 'list': ('py_echo',), }, 'tar': { - None: ('tar', 'star', 'pytarfile'), + None: ('tar', 'star', 'py_tarfile'), }, 'zip': { - None: ('7z', '7za', 'pyzipfile'), + None: ('7z', '7za', 'py_zipfile'), 'extract': ('unzip',), 'list': ('unzip',), 'test': ('unzip',), @@ -117,27 +118,27 @@ ArchivePrograms = { }, 'gzip': { None: ('pigz', 'gzip', '7z', '7za'), - 'extract': ('pygzip',), - 'create': ('pygzip',), + 'extract': ('py_gzip',), + 'create': ('py_gzip',), }, 'lzh': { None: ('lha',), }, 'lzip': { 'extract': ('plzip', 'lzip', 'clzip', 'pdlzip'), - 'list': ('echo',), + 'list': ('py_echo',), 'test': ('plzip', 'lzip', 'clzip', 'pdlzip'), 'create': ('plzip', 'lzip', 'clzip', 'pdlzip'), }, 'lrzip': { 'extract': ('lrzip',), - 'list': ('echo',), + 'list': ('py_echo',), 'test': ('lrzip',), 'create': ('lrzip',), }, 'compress': { 'extract': ('gzip', '7z', '7za', 'uncompress.real'), - 'list': ('7z', '7za', 'echo',), + 'list': ('7z', '7za', 'py_echo',), 'test': ('gzip', '7z', '7za'), 'create': ('compress',), }, @@ -182,13 +183,13 @@ ArchivePrograms = { }, 'lzma': { 'extract': ('lzma',), - 'list': ('echo',), + 'list': ('py_echo',), 'test': ('lzma',), 'create': ('lzma',), }, 'rzip': { 'extract': ('rzip',), - 'list': ('echo',), + 'list': ('py_echo',), 'create': ('rzip',), }, 'xz': { @@ -255,6 +256,9 @@ def find_archive_program (format, command): raise util.PatoolError("%s archive format `%s' is not supported" % (command, format)) # return the first existing program for program in programs: + if program.startswith('py_'): + # it's a Python module and therefore always supported + return program exe = util.find_program(program) if exe: if program == '7z' and format == 'rar' and not util.p7zip_supports_rar(): @@ -272,7 +276,7 @@ def find_compression_program (program, compression): found = util.find_program(enc_program) if found: return found - elif program == 'pytarfile': + elif program == 'py_tarfile': return compression in ('gzip', 'bzip2') return None diff --git a/patoolib/programs/pybz2.py b/patoolib/programs/py_bz2.py similarity index 100% rename from patoolib/programs/pybz2.py rename to patoolib/programs/py_bz2.py diff --git a/patoolib/programs/echo.py b/patoolib/programs/py_echo.py similarity index 95% rename from patoolib/programs/echo.py rename to patoolib/programs/py_echo.py index 97802d7..678b692 100644 --- a/patoolib/programs/echo.py +++ b/patoolib/programs/py_echo.py @@ -13,7 +13,7 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . -"""Archive commands for the echo program, simulated by the Python print +"""Archive commands echoing data, implemented by the Python print statement.""" from patoolib import util diff --git a/patoolib/programs/pygzip.py b/patoolib/programs/py_gzip.py similarity index 100% rename from patoolib/programs/pygzip.py rename to patoolib/programs/py_gzip.py diff --git a/patoolib/programs/pytarfile.py b/patoolib/programs/py_tarfile.py similarity index 100% rename from patoolib/programs/pytarfile.py rename to patoolib/programs/py_tarfile.py diff --git a/patoolib/programs/pyzipfile.py b/patoolib/programs/py_zipfile.py similarity index 100% rename from patoolib/programs/pyzipfile.py rename to patoolib/programs/py_zipfile.py diff --git a/tests/__init__.py b/tests/__init__.py index 14ae689..75288d0 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -102,14 +102,14 @@ class ArchiveTest (unittest.TestCase): command = 'test' program = self.program # special case for programs that cannot test what they create - if self.program in ('compress', 'pygzip'): + if self.program in ('compress', 'py_gzip'): program = 'gzip' - elif self.program == 'pybz2': + elif self.program == 'py_bz2': program = 'bzip2' elif self.program == 'zip': program = 'unzip' elif self.program == 'rzip': - program = 'echo' + program = 'py_echo' command = 'list' patoolib._handle_archive(archive, command, program=program) finally: diff --git a/tests/test_archives.py b/tests/test_archives.py index a3da9f9..10b0fa7 100644 --- a/tests/test_archives.py +++ b/tests/test_archives.py @@ -96,17 +96,17 @@ class TestArchives (ArchiveTest): self.program = 'star' self.archive_commands('t.tar.xz') - def test_pytarfile (self): - self.program = 'pytarfile' + def test_py_tarfile (self): + self.program = 'py_tarfile' self.archive_commands('t.tar') - def test_pytarfile_gz (self): - self.program = 'pytarfile' + def test_py_tarfile_gz (self): + self.program = 'py_tarfile' self.archive_commands('t.tar.gz') self.archive_commands('t.tgz') - def test_pytarfile_bz2 (self): - self.program = 'pytarfile' + def test_py_tarfile_bz2 (self): + self.program = 'py_tarfile' self.archive_commands('t.tar.bz2') self.archive_commands('t.tbz2') @@ -118,8 +118,8 @@ class TestArchives (ArchiveTest): self.archive_create('t .bz2', singlefile=True) @needs_program('bzip2') - def test_pybz2 (self): - self.program = 'pybz2' + def test_py_bz2 (self): + self.program = 'py_bz2' self.archive_extract('t .bz2') # bzip2 is used to test the created archive self.archive_create('t .bz2', singlefile=True) @@ -138,8 +138,8 @@ class TestArchives (ArchiveTest): self.archive_test('t .bz2') self.archive_create('t .bz2', singlefile=True) - def test_echo (self): - self.program = 'echo' + def test_py_echo (self): + self.program = 'py_echo' self.archive_list('t .bz2') self.archive_list('t.Z') self.archive_list('t.lzma') @@ -162,8 +162,8 @@ class TestArchives (ArchiveTest): self.program = 'zip' self.archive_create('t.zip') - def test_pyzipfile (self): - self.program = 'pyzipfile' + def test_py_zipfile (self): + self.program = 'py_zipfile' self.archive_commands('t.zip') @needs_program('gzip') @@ -174,8 +174,8 @@ class TestArchives (ArchiveTest): self.archive_extract('t.Z') @needs_program('gzip') - def test_pygzip (self): - self.program = 'pygzip' + def test_py_gzip (self): + self.program = 'py_gzip' self.archive_extract('t.gz') self.archive_extract('t.txt.gz') # gzip is used to test the created archive diff --git a/tests/test_foo_archives.py b/tests/test_foo_archives.py index 8d267bf..72a2b31 100644 --- a/tests/test_foo_archives.py +++ b/tests/test_foo_archives.py @@ -113,19 +113,19 @@ class TestArchives (ArchiveTest): self.archive_commands('t.tar.xz.foo', format="tar", encoding="xz") @needs_program('file') - def test_pytarfile_file (self): - self.program = 'pytarfile' + def test_py_tarfile_file (self): + self.program = 'py_tarfile' self.archive_commands('t.tar.foo', format="tar") @needs_program('file') - def test_pytarfile_gz_file (self): - self.program = 'pytarfile' + def test_py_tarfile_gz_file (self): + self.program = 'py_tarfile' self.archive_commands('t.tar.gz.foo', format="tar", encoding="gzip") self.archive_commands('t.tgz.foo', format="tar", encoding="gzip") @needs_program('file') - def test_pytarfile_bz2 (self): - self.program = 'pytarfile' + def test_py_tarfile_bz2 (self): + self.program = 'py_tarfile' self.archive_commands('t.tar.bz2.foo', format="tar", encoding="bzip2") self.archive_commands('t.tbz2.foo', format="tar", encoding="bzip2") @@ -138,8 +138,8 @@ class TestArchives (ArchiveTest): self.archive_create('t.bz2.foo', format="bzip2", singlefile=True) @needs_program('file') - def test_pybz2 (self): - self.program = 'pybz2' + def test_py_bz2 (self): + self.program = 'py_bz2' self.archive_extract('t.bz2.foo') self.archive_create('t.bz2.foo', format="bzip2", singlefile=True) @@ -160,8 +160,8 @@ class TestArchives (ArchiveTest): self.archive_create('t.bz2.foo', format="bzip2", singlefile=True) @needs_program('file') - def test_echo (self): - self.program = 'echo' + def test_py_echo (self): + self.program = 'py_echo' self.archive_list('t.bz2.foo') self.archive_list('t.Z.foo') # file(1) does not recognize .lzma files @@ -186,8 +186,8 @@ class TestArchives (ArchiveTest): self.archive_create('t.zip.foo', format="zip") @needs_program('file') - def test_pyzipfile (self): - self.program = 'pyzipfile' + def test_py_zipfile (self): + self.program = 'py_zipfile' self.archive_commands('t.zip.foo', format="zip") @needs_program('file') @@ -199,10 +199,12 @@ class TestArchives (ArchiveTest): self.archive_extract('t.Z.foo') @needs_program('file') - def test_pygzip (self): - self.program = 'pygzip' + @needs_program('gzip') + def test_py_gzip (self): + self.program = 'py_gzip' self.archive_extract('t.gz.foo') self.archive_extract('t.txt.gz.foo') + # gzip is used to test the created archive self.archive_create('t.gz.foo', format="gzip", singlefile=True) self.archive_create('t.txt.gz.foo', format="gzip", singlefile=True)