def build_translation_map(self):
operation_model = self.help_command.obj
d = {}
for cli_name, cli_argument in self.help_command.arg_table.items():
if cli_argument.argument_model is not None:
argument_name = cli_argument.argument_model.name
if argument_name in d:
previous_mapping = d[argument_name]
# If the argument name is a boolean argument, we want the
# the translation to default to the one that does not start
# with --no-. So we check if the cli parameter currently
# being used starts with no- and if stripping off the no-
# results in the new proposed cli argument name. If it
# does, we assume we have the postive form of the argument
# which is the name we want to use in doc translations.
if cli_argument.cli_type_name == 'boolean' and \
previous_mapping.startswith('no-') and \
cli_name == previous_mapping[3:]:
d[argument_name] = cli_name
else:
d[argument_name] = cli_name
for operation_name in operation_model.service_model.operation_names:
d[operation_name] = xform_name(operation_name, '-')
return d
评论列表
文章目录