print AST children counts for internal nodes

This commit is contained in:
rocky
2016-06-01 08:55:41 -04:00
parent 5f6314d757
commit e368ab282c
2 changed files with 6 additions and 1 deletions

1
.gitignore vendored
View File

@@ -1,5 +1,6 @@
*_dis *_dis
*~ *~
*.pyc
/.cache /.cache
/.eggs /.eggs
/.python-version /.python-version

View File

@@ -34,5 +34,9 @@ class AST(UserList):
def __repr__(self, indent=''): def __repr__(self, indent=''):
rv = str(self.type) rv = str(self.type)
for k in self: for k in self:
rv = rv + '\n' + str(k).replace('\n', '\n ') child_text = str(k).replace('\n', '\n ')
if hasattr(k, '__len__'):
rv += '\n(%d) %s' % (len(k), child_text)
else:
rv += '\n' + child_text
return rv return rv