shutil.copystat()

shutil.copystat(src, dst, *, follow_symlinks=True)

Copy the permission bits, last access time, last modification time, and flags from src to dst. On Linux, copystat() also copies the “extended attributes” where possible. The file contents, owner, and group are unaffected. src and dst are path names given as strings.

If follow_symlinks is false, and src and dst both refer to symbolic links, copystat() will operate on the symbolic links themselves rather than the files the symbolic links refer to–reading the information from the src symbolic link, and writing the information to the dst symbolic link.

Note

Not all platforms provide the ability to examine and modify symbolic links. Python itself can tell you what functionality is locally available.

  • If os.chmod in os.supports_follow_symlinks is True, copystat() can modify the permission bits of a symbolic link.
  • If os.utime in os.supports_follow_symlinks is True, copystat() can modify the last access and modification times of a symbolic link.
  • If os.chflags in os.supports_follow_symlinks is True, copystat() can modify the flags of a symbolic link. (os.chflags is not available on all platforms.)

On platforms where some or all of this functionality is unavailable, when asked to modify a symbolic link, copystat() will copy everything it can. copystat() never returns failure.

Please see os.supports_follow_symlinks for more information.

Changed in version 3.3: Added follow_symlinks argument and support for Linux extended attributes.

doc_python
2016-10-07 17:41:55
Comments
Leave a Comment

Please login to continue.