190 self.childCount = int(dvalue.split('x')[0]) |
190 self.childCount = int(dvalue.split('x')[0]) |
191 dvalue = VariableItem.noOfItemsStr.format(dvalue) |
191 dvalue = VariableItem.noOfItemsStr.format(dvalue) |
192 else: |
192 else: |
193 dvalue = VariableItem.unsized |
193 dvalue = VariableItem.unsized |
194 self.hasChildren = True |
194 self.hasChildren = True |
|
195 |
195 elif dtype in VariableItem.arrayTypes: |
196 elif dtype in VariableItem.arrayTypes: |
196 self.childCount = int(dvalue) |
197 self.childCount = int(dvalue) |
197 dvalue = VariableItem.noOfItemsStr.format(dvalue) |
198 dvalue = VariableItem.noOfItemsStr.format(dvalue) |
198 self.hasChildren = True |
199 self.hasChildren = True |
199 |
200 |
209 elif ( |
210 elif ( |
210 dvalue.startswith(("{", "(", "[")) and |
211 dvalue.startswith(("{", "(", "[")) and |
211 dvalue.endswith(("}", ")", "]")) |
212 dvalue.endswith(("}", ")", "]")) |
212 ): |
213 ): |
213 # it is most probably a dict, tuple or list derived class |
214 # it is most probably a dict, tuple or list derived class |
214 value = ast.literal_eval(dvalue) |
215 with contextlib.suppress(Exception): |
215 valueTypeStr = str(type(value))[8:-2] |
216 value = ast.literal_eval(dvalue) |
216 if valueTypeStr in VariableItem.arrayTypes: |
217 valueTypeStr = str(type(value))[8:-2] |
217 self.childCount = len(value) |
218 if valueTypeStr in VariableItem.arrayTypes: |
218 self.hasChildren = True |
219 self.childCount = len(value) |
|
220 self.hasChildren = True |
219 |
221 |
220 elif ( |
222 elif ( |
221 (dvalue.endswith("})") and "({" in dvalue) or |
223 (dvalue.endswith("})") and "({" in dvalue) or |
222 (dvalue.endswith("])") and "([" in dvalue) |
224 (dvalue.endswith("])") and "([" in dvalue) |
223 ): |
225 ): |
224 # that is probably a set derived class |
226 # that is probably a set derived class |
225 value = ast.literal_eval(dvalue.split("(", 1)[1][:-1]) |
227 with contextlib.suppress(Exception): |
226 valueTypeStr = str(type(value))[8:-2] |
228 value = ast.literal_eval(dvalue.split("(", 1)[1][:-1]) |
227 if valueTypeStr in VariableItem.arrayTypes: |
229 valueTypeStr = str(type(value))[8:-2] |
228 self.childCount = len(value) |
230 if valueTypeStr in VariableItem.arrayTypes: |
229 self.hasChildren = True |
231 self.childCount = len(value) |
|
232 self.hasChildren = True |
230 |
233 |
231 self.value = dvalue |
234 self.value = dvalue |
232 |
235 |
233 if len(dvalue) > 2048: # 2 kB |
236 if len(dvalue) > 2048: # 2 kB |
234 self.tooltip = dvalue[:2048] |
237 self.tooltip = dvalue[:2048] |
441 # Check if value has changed |
444 # Check if value has changed |
442 if child.value != newItem.value: |
445 if child.value != newItem.value: |
443 child.value = newItem.value |
446 child.value = newItem.value |
444 child.valueShort = newItem.valueShort |
447 child.valueShort = newItem.valueShort |
445 child.tooltip = newItem.tooltip |
448 child.tooltip = newItem.tooltip |
|
449 child.nameWithId = newItem.nameWithId |
446 |
450 |
447 child.currentCount = -1 |
451 child.currentCount = -1 |
448 child.populated = False |
452 child.populated = False |
449 child.childCount = newItem.childCount |
453 child.childCount = newItem.childCount |
450 |
454 |