From f6207d86fba57d15dd0e76d0dfb8ceff72313b90 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Fri, 19 Feb 2021 12:15:02 +0100 Subject: [PATCH] Adding support for array parsing --- stabilizer.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stabilizer.py b/stabilizer.py index 5ecee84..a78452f 100644 --- a/stabilizer.py +++ b/stabilizer.py @@ -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: