selectable_int: simplify SelectableIntMapping class
authorDmitry Selyutin <dmitry.selyutin@3mdeb.com>
Tue, 19 Apr 2022 19:56:58 +0000 (19:56 +0000)
committerDmitry Selyutin <dmitry.selyutin@3mdeb.com>
Tue, 19 Apr 2022 21:23:20 +0000 (21:23 +0000)
src/openpower/decoder/selectable_int.py

index 810d24cc53e789b7db7bca8228accc79e232df15..fc1dfeb9bb19b8684ed71c3a16bb7296049ff1e1 100644 (file)
@@ -438,24 +438,21 @@ class SelectableInt:
         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