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)
评论列表
文章目录