generate_resources.py 文件源码

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

项目:EasyEuler 作者: Encrylize 项目源码 文件源码
def generate_resources(resources, path):
    if len(resources) > 1 and not os.path.isdir(path):
        if os.path.exists(path):
            sys.exit('%s needs to be a directory to create multiple '
                     'resource files' % click.format_filename(path))
        os.mkdir(path)

    for resource in resources:
        if len(resources) > 1 or os.path.isdir(path):
            resource_path = '%s/%s' % (path, resource)
        else:
            resource_path = path

        if os.path.exists(resource_path) and not \
           click.confirm('%s already exists. Do you want to overwrite it?' %
                         click.format_filename(resource_path)):
            continue

        shutil.copy('%s/resources/%s' % (paths.DATA, resource), path)
        click.echo('Created %s at path %s' % (resource,
                                              click.format_filename(path)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号