Better names for some functions and values

This commit is contained in:
Bastian Kleineidam 2010-02-21 12:20:47 +01:00
parent 82e97a62a6
commit 1b38fff5ce
2 changed files with 10 additions and 10 deletions

View File

@ -18,8 +18,8 @@ import shutil
from distutils.spawn import find_executable
from . import util
# Supported command modes
CommandModes = ('list', 'extract')
# Supported archive commands
ArchiveCommands = ('list', 'extract')
# Supported archive formats
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)
def check_command_mode (mode):
if mode not in CommandModes:
def check_archive_command (mode):
if mode not in ArchiveCommands:
raise util.PatoolError("invalid command mode `%s'" % mode)
@ -161,7 +161,7 @@ def find_archive_program (format, mode):
def list_formats ():
for format in ArchiveFormats:
print format, "files:"
for mode in CommandModes:
for mode in ArchiveCommands:
program = find_archive_program(format, mode)
if program:
print " %8s: %s" % (mode, program)
@ -259,7 +259,7 @@ def _handle_archive (archive, mode, **kwargs):
encoding = None
format, encoding = get_archive_format(archive)
check_archive_format(format, encoding)
check_command_mode(mode)
check_archive_command(mode)
config = parse_config(format, mode, **kwargs)
cmd = config['cmd']
# get python module for given archive program

View File

@ -27,7 +27,7 @@ class TestConfiguration (unittest.TestCase):
# test that the key is an archive format
self.assertEqual(set(patoolib.ArchiveFormats),
set(patoolib.ArchivePrograms.keys()))
for modes in patoolib.ArchivePrograms.values():
for mode in modes:
if mode is not None:
self.assertTrue(mode in patoolib.CommandModes)
for commands in patoolib.ArchivePrograms.values():
for command in commands:
if command is not None:
self.assertTrue(command in patoolib.ArchiveCommands)