handlers.py 文件源码

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

项目:intel-manager-for-lustre 作者: intel-hpdd 项目源码 文件源码
def _api_fields_to_parser_args(self, parser, add_help=False):
        if add_help:
            parser.add_argument("--help", "-h",
                                help="show this help message and exit",
                                default=SUPPRESS, action='help')
        for name, attrs in self.api_endpoint.fields.items():
            if attrs['readonly']:
                continue

            kwargs = {'help': attrs['help_text']}
            if attrs['type'] in ["related", "list"]:
                kwargs['action'] = "append"
                kwargs['type'] = str
            elif attrs['type'] == "boolean":
                kwargs['action'] = "store_true"
                kwargs['default'] = False
            elif attrs['type'] == "integer":
                kwargs['type'] = int

            parser.add_argument("--%s" % name, **kwargs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号