[Libre-soc-bugs] [Bug 1094] insndb instruction database visitor-walker is needed

bugzilla-daemon at libre-soc.org bugzilla-daemon at libre-soc.org
Sun Jun 18 19:29:12 BST 2023


--- Comment #160 from Dmitry Selyutin <ghostmansd at gmail.com> ---
import dataclasses

import mdis.dispatcher
import mdis.walker

class CustomWalker(mdis.walker.Walker):
    def dispatch_dataclass(self, instance):
        for field in dataclasses.fields(instance):
            key = field.name
            value = getattr(instance, key)
            yield (key, value)
            yield from self((key, value))

class Thing:
    a: int
    b: str

walker = CustomWalker()
thing = Thing(a=1, b="cocojamboo")
for item in walker(thing):

('a', 1)
('b', 'cocojamboo')

You are receiving this mail because:
You are on the CC list for the bug.

More information about the libre-soc-bugs mailing list