Python module programs now have a py_ suffix.
This commit is contained in:
parent
e4f1a06c82
commit
ef8c0e595c
|
@ -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
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#
|
||||
# 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 echo program, simulated by the Python print
|
||||
"""Archive commands echoing data, implemented by the Python print
|
||||
statement."""
|
||||
from patoolib import util
|
||||
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue