MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / copytree

Function copytree

tools/python-3.11.9-amd64/Lib/shutil.py:530–576  ·  view source on GitHub ↗

Recursively copy a directory tree and return the destination directory. If exception(s) occur, an Error is raised with a list of reasons. If the optional symlinks flag is true, symbolic links in the source tree result in symbolic links in the destination tree; if it is false,

(src, dst, symlinks=False, ignore=None, copy_function=copy2,
             ignore_dangling_symlinks=False, dirs_exist_ok=False)

Source from the content-addressed store, hash-verified

528 return dst
529
530def copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2,
531 ignore_dangling_symlinks=False, dirs_exist_ok=False):
532 """Recursively copy a directory tree and return the destination directory.
533
534 If exception(s) occur, an Error is raised with a list of reasons.
535
536 If the optional symlinks flag is true, symbolic links in the
537 source tree result in symbolic links in the destination tree; if
538 it is false, the contents of the files pointed to by symbolic
539 links are copied. If the file pointed by the symlink doesn't
540 exist, an exception will be added in the list of errors raised in
541 an Error exception at the end of the copy process.
542
543 You can set the optional ignore_dangling_symlinks flag to true if you
544 want to silence this exception. Notice that this has no effect on
545 platforms that don't support os.symlink.
546
547 The optional ignore argument is a callable. If given, it
548 is called with the `src` parameter, which is the directory
549 being visited by copytree(), and `names` which is the list of
550 `src` contents, as returned by os.listdir():
551
552 callable(src, names) -> ignored_names
553
554 Since copytree() is called recursively, the callable will be
555 called once for each directory that is copied. It returns a
556 list of names relative to the `src` directory that should
557 not be copied.
558
559 The optional copy_function argument is a callable that will be used
560 to copy each file. It will be called with the source path and the
561 destination path as arguments. By default, copy2() is used, but any
562 function that supports the same signature (like copy()) can be used.
563
564 If dirs_exist_ok is false (the default) and `dst` already exists, a
565 `FileExistsError` is raised. If `dirs_exist_ok` is true, the copying
566 operation will continue if it encounters existing directories, and files
567 within the `dst` tree will be overwritten by corresponding files from the
568 `src` tree.
569 """
570 sys.audit("shutil.copytree", src, dst)
571 with os.scandir(src) as itr:
572 entries = list(itr)
573 return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
574 ignore=ignore, copy_function=copy_function,
575 ignore_dangling_symlinks=ignore_dangling_symlinks,
576 dirs_exist_ok=dirs_exist_ok)
577
578if hasattr(os.stat_result, 'st_file_attributes'):
579 # Special handling for directory junctions to make them behave like

Callers 2

_copytreeFunction · 0.85
moveFunction · 0.85

Calls 2

listFunction · 0.85
_copytreeFunction · 0.85

Tested by

no test coverage detected