Better names for some functions and values
This commit is contained in:
parent
82e97a62a6
commit
1b38fff5ce
|
@ -18,8 +18,8 @@ import shutil
|
||||||
from distutils.spawn import find_executable
|
from distutils.spawn import find_executable
|
||||||
from . import util
|
from . import util
|
||||||
|
|
||||||
# Supported command modes
|
# Supported archive commands
|
||||||
CommandModes = ('list', 'extract')
|
ArchiveCommands = ('list', 'extract')
|
||||||
|
|
||||||
# Supported archive formats
|
# Supported archive formats
|
||||||
ArchiveFormats = ('gzip', 'bzip2', 'tar', 'zip', 'compress', '7z', 'rar',
|
ArchiveFormats = ('gzip', 'bzip2', 'tar', 'zip', 'compress', '7z', 'rar',
|
||||||
|
@ -136,8 +136,8 @@ def check_archive_format (format, encoding):
|
||||||
raise util.PatoolError("unkonwn archive encoding `%s'" % encoding)
|
raise util.PatoolError("unkonwn archive encoding `%s'" % encoding)
|
||||||
|
|
||||||
|
|
||||||
def check_command_mode (mode):
|
def check_archive_command (mode):
|
||||||
if mode not in CommandModes:
|
if mode not in ArchiveCommands:
|
||||||
raise util.PatoolError("invalid command mode `%s'" % mode)
|
raise util.PatoolError("invalid command mode `%s'" % mode)
|
||||||
|
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ def find_archive_program (format, mode):
|
||||||
def list_formats ():
|
def list_formats ():
|
||||||
for format in ArchiveFormats:
|
for format in ArchiveFormats:
|
||||||
print format, "files:"
|
print format, "files:"
|
||||||
for mode in CommandModes:
|
for mode in ArchiveCommands:
|
||||||
program = find_archive_program(format, mode)
|
program = find_archive_program(format, mode)
|
||||||
if program:
|
if program:
|
||||||
print " %8s: %s" % (mode, program)
|
print " %8s: %s" % (mode, program)
|
||||||
|
@ -259,7 +259,7 @@ def _handle_archive (archive, mode, **kwargs):
|
||||||
encoding = None
|
encoding = None
|
||||||
format, encoding = get_archive_format(archive)
|
format, encoding = get_archive_format(archive)
|
||||||
check_archive_format(format, encoding)
|
check_archive_format(format, encoding)
|
||||||
check_command_mode(mode)
|
check_archive_command(mode)
|
||||||
config = parse_config(format, mode, **kwargs)
|
config = parse_config(format, mode, **kwargs)
|
||||||
cmd = config['cmd']
|
cmd = config['cmd']
|
||||||
# get python module for given archive program
|
# get python module for given archive program
|
||||||
|
|
|
@ -27,7 +27,7 @@ class TestConfiguration (unittest.TestCase):
|
||||||
# test that the key is an archive format
|
# test that the key is an archive format
|
||||||
self.assertEqual(set(patoolib.ArchiveFormats),
|
self.assertEqual(set(patoolib.ArchiveFormats),
|
||||||
set(patoolib.ArchivePrograms.keys()))
|
set(patoolib.ArchivePrograms.keys()))
|
||||||
for modes in patoolib.ArchivePrograms.values():
|
for commands in patoolib.ArchivePrograms.values():
|
||||||
for mode in modes:
|
for command in commands:
|
||||||
if mode is not None:
|
if command is not None:
|
||||||
self.assertTrue(mode in patoolib.CommandModes)
|
self.assertTrue(command in patoolib.ArchiveCommands)
|
||||||
|
|
Loading…
Reference in New Issue