Copy data and mode bits ("cp src dst"). Return the file's destination. The destination may be a directory. If follow_symlinks is false, symlinks won't be followed. This resembles GNU's "cp -P src dst". If source and destination are the same file, a SameFileError will be
(src, dst, *, follow_symlinks=True)
| 415 | raise |
| 416 | |
| 417 | def copy(src, dst, *, follow_symlinks=True): |
| 418 | """Copy data and mode bits ("cp src dst"). Return the file's destination. |
| 419 | |
| 420 | The destination may be a directory. |
| 421 | |
| 422 | If follow_symlinks is false, symlinks won't be followed. This |
| 423 | resembles GNU's "cp -P src dst". |
| 424 | |
| 425 | If source and destination are the same file, a SameFileError will be |
| 426 | raised. |
| 427 | |
| 428 | """ |
| 429 | if os.path.isdir(dst): |
| 430 | dst = os.path.join(dst, os.path.basename(src)) |
| 431 | copyfile(src, dst, follow_symlinks=follow_symlinks) |
| 432 | copymode(src, dst, follow_symlinks=follow_symlinks) |
| 433 | return dst |
| 434 | |
| 435 | def copy2(src, dst, *, follow_symlinks=True): |
| 436 | """Copy data and metadata. Return the file's destination. |