Adding support for array parsing

This commit is contained in:
Ryan Summers 2021-02-19 12:15:02 +01:00
parent 86a3f840e9
commit f6207d86fb

View File

@ -13,6 +13,13 @@ from gmqtt import Client as MqttClient
def parse_value(value):
""" Parse a command-line value into the most appropriate associated python datatype. """
# If the value is an array, construct it as such and recurse for individual elements.
if value.startswith('[') and value.endswith(']'):
all_values = []
for data in value[1:][:-1].split(','):
all_values.append(parse_value(data))
return all_values
if value.isnumeric():
return int(value)
try: