Skip to content

Commit

Permalink
Reimplemented offset to maintain compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Dob-The-Duilder committed Sep 10, 2023
1 parent b4a6348 commit 25068e4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pycparser/_ast_gen.py
Expand Up @@ -224,13 +224,16 @@ def children(self):
"""
pass
def show(self, buf=sys.stdout, attrnames=False, nodenames=False, showcoord=False, _my_node_name=None, indent='', islast = True):
def show(self, buf=sys.stdout, offset=0, attrnames=False, nodenames=False, showcoord=False, _my_node_name=None, indent='', islast = True):
""" Pretty print the Node and all its attributes and
children (recursively) to a buffer.
buf:
Open IO buffer into which the Node is printed.
offset:
Initial offset (amount of leading spaces)
attrnames:
True if you want to see the attribute names in
name=value pairs. False to only see the values.
Expand All @@ -250,7 +253,7 @@ def show(self, buf=sys.stdout, attrnames=False, nodenames=False, showcoord=False
Denotes if node is final element in its tree.
"""
marker = "└─" if islast else "├─"
lead = indent + marker
lead = ' ' * offset + indent + marker
if nodenames and _my_node_name is not None:
buf.write(lead + self.__class__.__name__+ ' <' + _my_node_name + '>: ')
Expand All @@ -275,6 +278,7 @@ def show(self, buf=sys.stdout, attrnames=False, nodenames=False, showcoord=False
for idx, (child_name, child) in enumerate(self.children()):
child.show(
buf,
offset=offset,
attrnames=attrnames,
nodenames=nodenames,
showcoord=showcoord,
Expand Down

0 comments on commit 25068e4

Please sign in to comment.