MCPcopy Index your code
hub / github.com/aws/aws-cli / _unpack_complex_cli_arg

Function _unpack_complex_cli_arg

awscli/argprocess.py:185–214  ·  view source on GitHub ↗
(argument_model, value, cli_name)

Source from the content-addressed store, hash-verified

183
184
185def _unpack_complex_cli_arg(argument_model, value, cli_name):
186 type_name = argument_model.type_name
187 if type_name == 'structure' or type_name == 'map':
188 if value.lstrip()[0] == '{':
189 return _unpack_json_cli_arg(argument_model, value, cli_name)
190 raise ParamError(cli_name, "Invalid JSON:\n%s" % value)
191 elif type_name == 'list':
192 if isinstance(value, str):
193 if value.lstrip()[0] == '[':
194 return _unpack_json_cli_arg(argument_model, value, cli_name)
195 elif isinstance(value, list) and len(value) == 1:
196 single_value = value[0].strip()
197 if single_value and single_value[0] == '[':
198 return _unpack_json_cli_arg(argument_model, value[0], cli_name)
199 try:
200 # There's a couple of cases remaining here.
201 # 1. It's possible that this is just a list of strings, i.e
202 # --security-group-ids sg-1 sg-2 sg-3 => ['sg-1', 'sg-2', 'sg-3']
203 # 2. It's possible this is a list of json objects:
204 # --filters '{"Name": ..}' '{"Name": ...}'
205 member_shape_model = argument_model.member
206 return [
207 _unpack_cli_arg(member_shape_model, v, cli_name) for v in value
208 ]
209 except (ValueError, TypeError):
210 # The list params don't have a name/cli_name attached to them
211 # so they will have bad error messages. We're going to
212 # attach the parent parameter to this error message to provide
213 # a more helpful error message.
214 raise ParamError(cli_name, value[0])
215
216
217def unpack_scalar_cli_arg(argument_model, value, cli_name=''):

Callers 1

_unpack_cli_argFunction · 0.85

Calls 4

_unpack_json_cli_argFunction · 0.85
ParamErrorClass · 0.85
_unpack_cli_argFunction · 0.85
lstripMethod · 0.45

Tested by

no test coverage detected