yarn_launcher.py 文件源码

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

项目:spylon 作者: maxpoint 项目源码 文件源码
def _extract_local_archive(working_dir, cleanup_functions, env_name, local_archive):
    """Helper internal function for extracting a zipfile and ensure that a cleanup is queued.

    Parameters
    ----------
    working_dir : str
    cleanup_functions : List[() -> NoneType]
    env_name : str
    local_archive : str
    """
    with zipfile.ZipFile(local_archive) as z:
        z.extractall(working_dir)
        archive_filenames = z.namelist()

    root_elements = {m.split(posixpath.sep, 1)[0] for m in archive_filenames}
    abs_archive_filenames = [os.path.abspath(os.path.join(working_dir, f)) for f in root_elements]

    def cleanup():
        for fn in abs_archive_filenames:
            if os.path.isdir(fn):
                shutil.rmtree(fn)
            else:
                os.unlink(fn)

    cleanup_functions.append(cleanup)
    env_dir = os.path.join(working_dir, env_name)
    # Because of a python deficiency (Issue15795), the execute bits aren't
    # preserved when the zip file is unzipped. Need to add them back here.
    _fix_permissions(env_dir)
    return env_dir
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号