MCPcopy Create free account
hub / github.com/catboost/catboost / copytree3

Function copytree3

library/python/fs/__init__.py:405–502  ·  view source on GitHub ↗

Recursively copy a directory tree. The copytree3 is a port of shutil.copytree function from python-3.2. It has additional useful parameters and may be helpful while we are on python-2.x. It has to be removed as soon as we have moved to python-3.2 or higher. The destination dire

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

Source from the content-addressed store, hash-verified

403
404# Directory copy ported from Python 3
405def copytree3(
406 src,
407 dst,
408 symlinks=False,
409 ignore=None,
410 copy_function=shutil.copy2,
411 ignore_dangling_symlinks=False,
412 dirs_exist_ok=False,
413):
414 """Recursively copy a directory tree.
415
416 The copytree3 is a port of shutil.copytree function from python-3.2.
417 It has additional useful parameters and may be helpful while we are
418 on python-2.x. It has to be removed as soon as we have moved to
419 python-3.2 or higher.
420
421 The destination directory must not already exist.
422 If exception(s) occur, an Error is raised with a list of reasons.
423
424 If the optional symlinks flag is true, symbolic links in the
425 source tree result in symbolic links in the destination tree; if
426 it is false, the contents of the files pointed to by symbolic
427 links are copied. If the file pointed by the symlink doesn't
428 exist, an exception will be added in the list of errors raised in
429 an Error exception at the end of the copy process.
430
431 You can set the optional ignore_dangling_symlinks flag to true if you
432 want to silence this exception. Notice that this has no effect on
433 platforms that don't support os.symlink.
434
435 The optional ignore argument is a callable. If given, it
436 is called with the `src` parameter, which is the directory
437 being visited by copytree3(), and `names` which is the list of
438 `src` contents, as returned by os.listdir():
439
440 callable(src, names) -> ignored_names
441
442 Since copytree3() is called recursively, the callable will be
443 called once for each directory that is copied. It returns a
444 list of names relative to the `src` directory that should
445 not be copied.
446
447 The optional copy_function argument is a callable that will be used
448 to copy each file. It will be called with the source path and the
449 destination path as arguments. By default, copy2() is used, but any
450 function that supports the same signature (like copy()) can be used.
451
452 """
453 names = os.listdir(src)
454 if ignore is not None:
455 ignored_names = ignore(src, names)
456 else:
457 ignored_names = set()
458
459 if not (dirs_exist_ok and os.path.isdir(dst)):
460 os.makedirs(dst)
461
462 errors = []

Callers 1

copy_treeFunction · 0.85

Calls 8

copy_functionFunction · 0.85
isinstanceFunction · 0.85
ignoreFunction · 0.50
setFunction · 0.50
strClass · 0.50
joinMethod · 0.45
appendMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected