mutually_exclusive_option.py 文件源码

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

项目:treadmill 作者: Morgan-Stanley 项目源码 文件源码
def handle_parse_result(self, ctx, opts, args):
        if self.mutually_exclusive.intersection(opts) and \
           self.name in opts:
            raise click.UsageError(
                "Illegal usage: `{}` is mutually exclusive with "
                "arguments `{}`.".format(
                    self.name,
                    ', '.join(self.mutually_exclusive)
                )
            )
        if self.name == _OPTIONS_FILE and self.name in opts:
            _file = opts.pop(_OPTIONS_FILE)
            for _param in ctx.command.params:
                opts[_param.name] = _param.default or \
                    _param.value_from_envvar(ctx) or ''
            with open(_file, 'r') as stream:
                data = yaml.load(stream)

            _command_name = ctx.command.name
            if data.get(_command_name, None):
                opts.update(data[_command_name])
            else:
                raise click.BadParameter(
                    'Manifest file should have %s scope' % _command_name
                )
            opts['vpc_id'] = opts.pop('vpc_name')
            ctx.params = opts

        return super().handle_parse_result(ctx, opts, args)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号