in samcli/cli/types.py [0:0]
def convert(self, value, param, ctx):
result = {}
fail = False
if not value:
return result
try:
# Look to load the value into json if we can.
result = json.loads(value)
for val in result.values():
if isinstance(val, (dict, list)):
# Need a non nested dictionary or a dictionary with non list values,
# If either is found, fail the conversion.
fail = True
except JSONDecodeError:
# if looking for a json format failed, look at if the specified value follows
# KeyName1=string,KeyName2=string format
groups = re.findall(self._pattern, value)
if not groups:
fail = True
for group in groups:
key, v = group
# assign to result['KeyName1'] = string and so on.
result[key] = v
if fail:
return self.fail(
"{} is not in valid format. It must look something like '{}'".format(value, self._EXAMPLE), param, ctx
)
return result