model.py 文件源码

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

项目:BookCloud 作者: livro-aberto 项目源码 文件源码
def __init__(self, name, user):
        self.name = name
        self.owner_id = user.id
        # create the master branch
        new_branch = application.branches.Branch('master', self, None, user)
        db.session.add(new_branch)
        db.session.commit()
        # updating branch's self reference
        new_branch.origin_id = new_branch.id
        db.session.commit()
        # create folder for resources
        os.makedirs(join('repos', name, '_resources'))
        os.makedirs(join('repos', name, '_resources/original'))
        os.makedirs(join('repos', name, '_resources/low_resolution'))
        os.makedirs(join('repos', name, '_resources/thumbnail'))
        # create the repository in the filesystem
        repo_path = join('repos', name, 'master/source')
        os.makedirs(repo_path)
        os.symlink(os.path.abspath(join('repos', name, '_resources',
                                        'low_resolution')),
                   os.path.abspath(join('repos', name,
                                        'master/source/_resources/')))
        git.Repo.init(repo_path)
        repo = git.Repo(repo_path)
        application.branches.config_repo(repo, user.username, user.email)
        copyfile('empty_repo/source/index.rst', join(repo_path, 'index.rst'))
        copyfile('empty_repo/.gitignore', join(repo_path, '.gitignore'))
        repo.index.add(['index.rst', '.gitignore'])
        author = git.Actor(user.username, user.email)
        repo.index.commit(_('Initial commit'), author=author)
        new_branch.build(timeout=30)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号