--- a/mqtt/mqtt_client_gen.py Tue Jul 23 15:30:04 2024 +0200
+++ b/mqtt/mqtt_client_gen.py Tue Jul 23 17:05:59 2024 +0200
@@ -101,7 +101,9 @@
self.log("{} is invalid for IdType\n".format(value))
- self.data[row][col] = v
# Report how many columns this model provides data for.
@@ -238,7 +240,7 @@
self.change_callback = change_callback
self.dsc = lstcoldsc[direction]
- def append(self, value):
+ def _filter_line(self, value): v = dict(list(zip(self.dsc.lstcolnames, value)))
if type(v["Location"]) != int:
@@ -250,31 +252,48 @@
holes = set(range(greatest)) - iecnums
v["Location"] = min(holes) if holes else greatest+1
- if v["QoS"] not in QoS_values:
- self.log("Unknown QoS\n".format(value))
for t,n in zip(self.dsc.lstcoltypess, self.dsc.lstcolnames):
self.log("MQTT topic {} (Location={}) has invalid type\n".format(v["Topic"],v["Location"]))
+ if v["QoS"] not in QoS_values: + self.log("Unknown QoS\n".format(value)) if len(self)>0 and v["Topic"] in list(zip(*self))[self.dsc.lstcolnames.index("Topic")]:
self.log("MQTT topic {} (Location={}) already in the list\n".format(v["Topic"],v["Location"]))
+ return [v[n] for n in self.dsc.lstcolnames] - list.append(self, [v[n] for n in self.dsc.lstcolnames])
+ def insert(self, row, value): + v = self._filter_line(value) + list.insert(self, row, v)
+ def append(self, value): + v = self._filter_line(value)
+ def __setitem__(self, index, value): + list.__setitem__(self, index, value) def __delitem__(self, index):
list.__delitem__(self, index)
class MQTTClientModel(dict):
def __init__(self, log, change_callback = lambda : None):
super(MQTTClientModel, self).__init__()
@@ -290,7 +309,11 @@
# avoids calling change callback when loading CSV
- list.append(self[direction],row[1:])
+ v = l._filter_line(row[1:]) + # TODO be verbose in case of malformed CSV with open(path, 'w') as csvfile: