diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-04-05 03:16:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-05 03:16:16 (GMT) |
commit | 857cf55cbdd65b7a9534dc35d89a19dfe8cbdba5 (patch) | |
tree | ad11c2415bda778de51c46d78753dcffa378e258 /Doc | |
parent | 97151e1e3a683d7b5d196e66b8a3482896eb8c9b (diff) | |
download | cpython-857cf55cbdd65b7a9534dc35d89a19dfe8cbdba5.zip cpython-857cf55cbdd65b7a9534dc35d89a19dfe8cbdba5.tar.gz cpython-857cf55cbdd65b7a9534dc35d89a19dfe8cbdba5.tar.bz2 |
bpo-40982: shutil docs: Remove outdated copytree() example (GH-24778)
It is not preferable to keep a copy of the implementation in the
docs.
(cherry picked from commit e06f920c5bc6e9fad29082ba0d84043722806e17)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/shutil.rst | 37 |
1 files changed, 1 insertions, 36 deletions
diff --git a/Doc/library/shutil.rst b/Doc/library/shutil.rst index 11c6707..5f71049 100644 --- a/Doc/library/shutil.rst +++ b/Doc/library/shutil.rst @@ -470,42 +470,7 @@ file then shutil will silently fallback on using less efficient copytree example ~~~~~~~~~~~~~~~~ -This example is the implementation of the :func:`copytree` function, described -above, with the docstring omitted. It demonstrates many of the other functions -provided by this module. :: - - def copytree(src, dst, symlinks=False): - names = os.listdir(src) - os.makedirs(dst) - errors = [] - for name in names: - srcname = os.path.join(src, name) - dstname = os.path.join(dst, name) - try: - if symlinks and os.path.islink(srcname): - linkto = os.readlink(srcname) - os.symlink(linkto, dstname) - elif os.path.isdir(srcname): - copytree(srcname, dstname, symlinks) - else: - copy2(srcname, dstname) - # XXX What about devices, sockets etc.? - except OSError as why: - errors.append((srcname, dstname, str(why))) - # catch the Error from the recursive copytree so that we can - # continue with other files - except Error as err: - errors.extend(err.args[0]) - try: - copystat(src, dst) - except OSError as why: - # can't copy file access times on Windows - if why.winerror is None: - errors.extend((src, dst, str(why))) - if errors: - raise Error(errors) - -Another example that uses the :func:`ignore_patterns` helper:: +An example that uses the :func:`ignore_patterns` helper:: from shutil import copytree, ignore_patterns |