From 0c7f4940ab9723c96ad641fca89d1a97b62ec6be Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Fri, 9 Jun 2023 21:28:53 +0300 Subject: [PATCH] insndb: rename subnodes into walk --- src/openpower/insndb/core.py | 14 +++++++------- src/openpower/insndb/db.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/openpower/insndb/core.py b/src/openpower/insndb/core.py index 26e3c1a9..6a2054be 100644 --- a/src/openpower/insndb/core.py +++ b/src/openpower/insndb/core.py @@ -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 diff --git a/src/openpower/insndb/db.py b/src/openpower/insndb/db.py index 33586152..17f46911 100644 --- a/src/openpower/insndb/db.py +++ b/src/openpower/insndb/db.py @@ -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) -- 2.30.2