generate.py 文件源码

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

项目:dj 作者: aleontiev 项目源码 文件源码
def invoke(self, context):
        given_args = context.protected_args + context.args
        interactive = True
        args = []
        for arg in given_args:
            if arg == '--interactive':
                interactive = True
            elif arg == '--not-interactive':
                interactive = False
            else:
                args.append(arg)

        name = args[0]
        application = self.application
        if not application:
            raise click.ClickException('Could not locate application')

        blueprint = application.blueprints.get(name)
        if not blueprint:
            raise click.ClickException('Could not locate blueprint')

        command = blueprint.load_context()
        args = args[1:]
        ctx = command.main(args, standalone_mode=False)

        try:
            return application.generate(
                blueprint,
                ctx,
                interactive=interactive
            )
        except UndefinedError as e:
            raise click.ClickException(
                '%s.\n'
                "The blueprint's context may be invalid.\n"
                'Blueprint: %s\n'
                'Context: %s' % (str(e), str(blueprint), str(ctx))
            )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号