insndb: rename subnodes into walk
authorDmitry Selyutin <ghostmansd@gmail.com>
Fri, 9 Jun 2023 18:28:53 +0000 (21:28 +0300)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 22 Dec 2023 19:26:19 +0000 (19:26 +0000)
src/openpower/insndb/core.py
src/openpower/insndb/db.py

index 26e3c1a9841932fffa4c4e17cda5a836e726d21b..6a2054be930b215e98dbc1539fa3510bb8f81a2d 100644 (file)
@@ -57,7 +57,7 @@ from openpower.decoder.pseudo.pagereader import ISA as _ISA
 
 
 class Node:
-    def subnodes(self, match=None):
+    def walk(self, match=None):
         return ()
 
 
@@ -76,7 +76,7 @@ class DataclassMeta(type):
 
 
 class Dataclass(metaclass=DataclassMeta):
-    def subnodes(self, match=None):
+    def walk(self, match=None):
         if match is None:
             match = lambda subnode: True
 
@@ -96,14 +96,14 @@ def walk(root, match=None):
     nodes = _collections.deque([root])
     while nodes:
         node = nodes.popleft()
-        nodes.extend(node.subnodes(match=match))
+        nodes.extend(node.walk(match=match))
         yield node
 
 
 def visit(visitor, node):
     with visitor(node=node):
-        if hasattr(node, "subnodes"):
-            for subnode in node.subnodes():
+        if hasattr(node, "walk"):
+            for subnode in node.walk():
                 visit(visitor=visitor, node=subnode)
 
 
@@ -3724,7 +3724,7 @@ class Records(tuple):
     def __new__(cls, records):
         return super().__new__(cls, sorted(records))
 
-    def subnodes(self, match=None):
+    def walk(self, match=None):
         if match is None:
             match = lambda subnode: True
 
@@ -3767,7 +3767,7 @@ class Database(Node):
 
         return super().__init__()
 
-    def subnodes(self, match=None):
+    def walk(self, match=None):
         if match is None:
             match = lambda subnode: True
 
index 33586152d3bddc345e29c850a6811078ed3215e0..17f46911ebb0ac9dce806e3678b6dc235d49e11d 100644 (file)
@@ -139,7 +139,7 @@ def main():
     visitor = commands[command][0]()
 
     db = Database(find_wiki_dir())
-    records = next(db.subnodes(match=lambda node: isinstance(node, Records)))
+    records = next(db.walk(match=lambda node: isinstance(node, Records)))
     if command in ("list",):
         match = None
     else:
@@ -147,7 +147,7 @@ def main():
         def match(record):
             return (isinstance(record, Record) and (record.name == insn))
 
-    for node in records.subnodes(match=match):
+    for node in records.walk(match=match):
         visit(visitor=visitor, node=node)