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 raised
(src, dst, *, follow_symlinks=True)
| 473 | raise |
| 474 | |
| 475 | def copy(src, dst, *, follow_symlinks=True): |
| 476 | """Copy data and mode bits ("cp src dst"). Return the file's destination. |
| 477 | |
| 478 | The destination may be a directory. |
| 479 | |
| 480 | If follow_symlinks is false, symlinks won't be followed. This |
| 481 | resembles GNU's "cp -P src dst". |
| 482 | |
| 483 | If source and destination are the same file, a SameFileError will be |
| 484 | raised. |
| 485 | |
| 486 | """ |
| 487 | if os.path.isdir(dst): |
| 488 | dst = os.path.join(dst, os.path.basename(src)) |
| 489 | copyfile(src, dst, follow_symlinks=follow_symlinks) |
| 490 | copymode(src, dst, follow_symlinks=follow_symlinks) |
| 491 | return dst |
| 492 | |
| 493 | def copy2(src, dst, *, follow_symlinks=True): |
| 494 | """Copy data and metadata. Return the file's destination. |