test_util.py 文件源码

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

项目:runcommands 作者: wylee 项目源码 文件源码
def copy(contents, config=None, destination_dir=False, **kwargs):
    if config is None:
        config = Config(xyz='123')

    with NamedTemporaryFile('w', delete=False) as tp:
        tp.write(contents)

    source = tp.name

    if destination_dir:
        with TemporaryDirectory() as destination:
            path = copy_file(config, source, destination, **kwargs)
            yield source, destination, path
            os.remove(source)
    else:
        destination = source + '.copy'
        path = copy_file(config, source, destination, **kwargs)
        yield source, destination, path
        os.remove(source)
        os.remove(path)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号