start_project.py 文件源码

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

项目:jawaf 作者: danpozmanter 项目源码 文件源码
def handle(self, **options):
        options['secret_key'] = token_hex(60)
        options['template'] = 'project_template'
        base_dir, name = super(Command, self).handle(**options)
        # Setup Alembic Migrations
        alembic_dir = os.path.join(base_dir, name, 'migrations')
        cfg = Config(os.path.join(alembic_dir, 'alembic.ini'))
        command.init(config=cfg, directory=alembic_dir)
        with open(os.path.join(alembic_dir, 'env.py'), 'r') as f:
            env_py = f.read()
        env_py = env_py.replace('target_metadata = None', METADATA_CODE)
        env_py = env_py.replace('config = context.config', SQL_CONNECT_OVERRIDE)
        with open(os.path.join(alembic_dir, 'env.py'), 'w') as f:
            f.write(env_py)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号