in samcli/cli/types.py [0:0]
def convert(self, value, param, ctx):
result = {}
fail = False
# Empty tuple
if value == ("",):
return result
# if value comes in via samconfig file and is a list, it is parsed to string.
if isinstance(value, list):
if not value:
return result
value = " ".join(value)
# if value comes in a via configuration file, it will be a string. So we should still convert it.
value = (value,) if not isinstance(value, tuple) else value
for val in value:
# Using standard parser first.
# We should implement other type parser like JSON and Key=key,Value=val type format.
parsed, tags = self._standard_key_value_parser(val)
if not parsed:
parsed, tags = self._space_separated_key_value_parser(val)
if parsed:
for k in tags:
result[_unquote_wrapped_quotes(k)] = _unquote_wrapped_quotes(tags[k])
else:
groups = re.findall(self._pattern, val)
if not groups:
fail = True
for group in groups:
key, v = group
# assign to result['KeyName1'] = string and so on.
result[_unquote_wrapped_quotes(key)] = _unquote_wrapped_quotes(v)
if fail:
return self.fail(
"{} is not in valid format. It must look something like '{}'".format(value, self._EXAMPLE),
param,
ctx,
)
return result