Added missing documentation strings.

This commit is contained in:
Bastian Kleineidam 2010-03-01 16:03:31 +01:00
parent a4dcaf0f4c
commit 90f4d607df
3 changed files with 8 additions and 2 deletions

1
patool
View File

@ -49,6 +49,7 @@ def test (archive, verbose=False):
@baker.command @baker.command
def formats (): def formats ():
"""List supported and available archive formats."""
return list_formats() return list_formats()
try: try:

View File

@ -170,6 +170,7 @@ def get_archive_format (filename):
def check_archive_format (format, encoding): def check_archive_format (format, encoding):
"""Make sure format and encoding is known."""
if format not in ArchiveFormats: if format not in ArchiveFormats:
raise util.PatoolError("unknown archive format `%s'" % format) raise util.PatoolError("unknown archive format `%s'" % format)
if encoding is not None and encoding not in ArchiveEncodings: if encoding is not None and encoding not in ArchiveEncodings:
@ -177,6 +178,7 @@ def check_archive_format (format, encoding):
def check_archive_command (command): def check_archive_command (command):
"""Make sure archive command is valid."""
if command not in ArchiveCommands: if command not in ArchiveCommands:
raise util.PatoolError("invalid archive command `%s'" % command) raise util.PatoolError("invalid archive command `%s'" % command)
@ -313,7 +315,7 @@ def move_outdir_orphan (outdir, force):
def run_archive_cmdlist (archive_cmdlist): def run_archive_cmdlist (archive_cmdlist):
"""Handle result of archive command function.""" """Run archive command."""
# archive_cmdlist is a command list with optional keyword arguments # archive_cmdlist is a command list with optional keyword arguments
if isinstance(archive_cmdlist, tuple): if isinstance(archive_cmdlist, tuple):
cmdlist, runkwargs = archive_cmdlist cmdlist, runkwargs = archive_cmdlist
@ -337,6 +339,7 @@ def cleanup_outdir (archive, outdir, force):
def _handle_archive (archive, command, *args, **kwargs): def _handle_archive (archive, command, *args, **kwargs):
"""Handle archive command; raising PatoolError on errors."""
if command != 'create': if command != 'create':
# check that archive is a regular file # check that archive is a regular file
util.check_filename(archive) util.check_filename(archive)
@ -377,7 +380,7 @@ def _handle_archive (archive, command, *args, **kwargs):
def handle_archive (archive, command, *args, **kwargs): def handle_archive (archive, command, *args, **kwargs):
"""Handle archive file command.""" """Handle archive file command; with nice error reporting."""
try: try:
_handle_archive(archive, command, *args, **kwargs) _handle_archive(archive, command, *args, **kwargs)
res = 0 res = 0

View File

@ -87,10 +87,12 @@ def stripext (filename):
def log_error (msg, out=sys.stderr): def log_error (msg, out=sys.stderr):
"""Print error message to stderr (or any other given output)."""
print >> out, "patool error:", msg print >> out, "patool error:", msg
def log_internal_error (out=sys.stderr): def log_internal_error (out=sys.stderr):
"""Print internal error message to stderr."""
print >> out, "patool: internal error" print >> out, "patool: internal error"
etype, value = sys.exc_info()[:2] etype, value = sys.exc_info()[:2]
traceback.print_exc() traceback.print_exc()