in_place.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:inplace 作者: jwodder 项目源码 文件源码
def copystats(from_file, to_file):
    """
    Copy stat info from ``from_file`` to ``to_file`` using `shutil.copystat`.
    If possible, also copy the user and/or group ownership information.
    """
    shutil.copystat(from_file, to_file)
    if hasattr(os, 'chown'):
        st = os.stat(from_file)
        # Based on GNU sed's behavior:
        try:
            os.chown(to_file, st.st_uid, st.st_gid)
        except EnvironmentError:
            try:
                os.chown(to_file, -1, st.st_gid)
            except EnvironmentError:
                pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号