insndb/core: walk over individual operands
authorDmitry Selyutin <ghostmansd@gmail.com>
Sat, 2 Sep 2023 16:39:03 +0000 (19:39 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Wed, 6 Sep 2023 18:56:09 +0000 (21:56 +0300)
src/openpower/insndb/core.py

index f441cf8bada4ad875800f68f5cf3e2874cced6c1..403bacabf9b9f1b3e144cd3393f7dc36cb5e6e91 100644 (file)
@@ -3731,3 +3731,19 @@ class Walker(mdis.walker.Walker):
     @mdis.dispatcher.Hook(Database)
     def dispatch_database(self, node):
         yield from self(tuple(node))
+
+    @mdis.dispatcher.Hook(Record)
+    def dispatch_record(self, node):
+        self.__record = node
+        for field in _dataclasses.fields(node):
+            key = field.name
+            value = getattr(node, key)
+            yield (value, node, key, mdis.walker.AttributePath)
+
+    @mdis.dispatcher.Hook(Operands)
+    def dispatch_operands(self, node):
+        def hook(cls_kwargs):
+            (cls, kwargs) = cls_kwargs
+            return cls(record=self.__record, **kwargs)
+
+        yield from self(tuple(map(hook, node)))