runtimesandbox.py 文件源码

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

项目:skymod 作者: DelusionalLogic 项目源码 文件源码
def install(context, from_str, to_str=""):
    to = Path(to_str)
    if not is_subdir(context.pkgins / to, context.pkgins):
        raise Exception("Package tried to copy to directory outside its own")

    from_ = Path(from_str).normpath()
    if from_.isabs():
        raise Exception("From glob is not allowed to be absolute")

    from_ = context.source_lookup.translate(from_)

    for d in Path().glob(from_):
        from_ = d
        if not is_subdir(from_, context.pkgsrc):
            raise Exception("Package tried to copy from directory outside its own")

        name = from_.name

        if from_.isdir():
            rel_from = from_.relpath(context.pkgsrc)
            context.add_package_file( (rel_from, to / name) )
            for e in from_.walk():
                rel_to = e.relpath(from_)
                rel_from = e.relpath(context.pkgsrc)
                context.add_package_file( (rel_from, to / name / rel_to) )
        else:
            rel_from = from_.relpath(context.pkgsrc)
            context.add_package_file( (rel_from, to / name) )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号