diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -100,14 +100,14 @@ copied with :func:`copystat`, individual files are copied using :func:`copy2`. - If *symlinks* is true, symbolic links in the source tree are represented as - symbolic links in the new tree; if false or omitted, the contents of the + If *symlinks* is ``True``, symbolic links in the source tree are represented as + symbolic links in the new tree; if ``False`` or omitted, the contents of the linked files are copied to the new tree. - When *symlinks* is false, if the file pointed by the symlink doesn't + When *symlinks* is ``False``, if the file pointed by the symlink doesn't exist, a exception will be added in the list of errors raised in a :exc:`Error` exception at the end of the copy process. - You can set the optional *ignore_dangling_symlinks* flag to true if you + You can set the optional *ignore_dangling_symlinks* flag to ``True`` if you want to silence this exception. Notice that this option has no effect on platforms that don't support :func:`os.symlink`. @@ -134,7 +134,7 @@ .. versionchanged:: 3.2 Added the *ignore_dangling_symlinks* argument to silent dangling symlinks - errors when *symlinks* is false. + errors when *symlinks* is ``False``. .. function:: rmtree(path, ignore_errors=False, onerror=None) @@ -142,8 +142,8 @@ .. index:: single: directory; deleting Delete an entire directory tree; *path* must point to a directory (but not a - symbolic link to a directory). If *ignore_errors* is true, errors resulting - from failed removals will be ignored; if false or omitted, such errors are + symbolic link to a directory). If *ignore_errors* is ``True``, errors resulting + from failed removals will be ignored; if ``False`` or omitted, such errors are handled by calling a handler specified by *onerror* or, if that is omitted, they raise an exception. @@ -161,8 +161,16 @@ Recursively move a file or directory to another location. - If the destination is on the current filesystem, then simply use rename. - Otherwise, copy src (with :func:`copy2`) to the dst and then remove src. + If the destination *dst* is a directory or a symlink to a directory, then + *src* is moved inside that directory. + + The destination directory must not already exist. If the destination already + exists but is not a directory, it may be overwritten depending on + :func:`os.rename` semantics. + + If the destination is on the current filesystem, then :func:`os.rename` is + used. Otherwise, *src* is copied (using :func:`copy2`) to the *dst* and then + removed. .. function:: disk_usage(path) @@ -175,7 +183,7 @@ .. exception:: Error - This exception collects exceptions that raised during a multi-file operation. For + This exception collects exceptions that are raised during a multi-file operation. For :func:`copytree`, the exception argument is a list of 3-tuples (*srcname*, *dstname*, *exception*). @@ -275,7 +283,7 @@ .. function:: get_archive_formats() - Returns a list of supported formats for archiving. + Return a list of supported formats for archiving. Each element of the returned sequence is a tuple ``(name, description)`` By default :mod:`shutil` provides these formats: @@ -293,7 +301,7 @@ .. function:: register_archive_format(name, function, [extra_args, [description]]) - Registers an archiver for the format *name*. *function* is a callable that + Register an archiver for the format *name*. *function* is a callable that will be used to invoke the archiver. If given, *extra_args* is a sequence of ``(name, value)`` pairs that will be @@ -330,7 +338,7 @@ .. function:: register_unpack_format(name, extensions, function[, extra_args[, description]]) - Registers an unpack format. *name* is the name of the format and + Register an unpack format. *name* is the name of the format and *extensions* is a list of extensions corresponding to the format, like ``.zip`` for Zip files.