[filehandler] use 1.5 property api

This commit is contained in:
Jan Grewe 2021-09-02 13:51:07 +02:00
parent fad56640fa
commit b7db1b9d5a

View File

@ -151,19 +151,12 @@ class FileHandler(metaclass=Singleton):
props = [] props = []
for p in section.props: for p in section.props:
value = "" value = ""
if self._file_version < (1, 1, 1): vals = p.values
vals = p.values if len(vals) == 0:
if len(vals) > 1: continue
value += "[" is_bytes = isinstance(vals[0], bytes)
value += ",".join(map(str, [v.value for v in vals])) val_list = [v.decode() for v in vals] if is_bytes else [str(v) for v in vals]
value += "]" value = val_list[0] if len(val_list) == 1 else "[%s]" % (",".join(map(str, val_list)))
else:
value = str(vals[0].value)
else:
vals = p.values
value += "["
value += ",".join(map(str, [v.value for v in vals]))
value += "]"
if p.unit is not None: if p.unit is not None:
value += " " + p.unit value += " " + p.unit
props.append(ItemDescriptor(p.name, p.id, value=value, entity_type=NodeType.Property)) props.append(ItemDescriptor(p.name, p.id, value=value, entity_type=NodeType.Property))