return struct.unpack('<d', data)[0]
-class SelectableIntMapping:
+class SelectableIntMapping(dict):
def __init__(self, si, fields=None):
def field(item):
(key, value) = item
if isinstance(value, dict):
value = dict(map(field, value.items()))
else:
- value = FieldSelectableInt(self.__si, value)
+ value = FieldSelectableInt(si, value)
return (key, value)
- self.__si = si
- self.__fields = dict(map(field, fields.items()))
+ return super().__init__(map(field, fields.items()))
def __getattr__(self, attr):
- if attr == f"_SelectableIntMapping__fields":
- return self.__dict__["_SelectableIntMapping__fields"]
try:
- return self.__fields[attr]
+ return self[attr]
except KeyError as error:
raise AttributeError from error