def walk(<EOL>self, node, omit=(<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'),<EOL>indent=<NUM_LIT:0>, depth=-<NUM_LIT:1>,<EOL>pos=False,<EOL>_level=<NUM_LIT:0>):
if not depth:<EOL><INDENT>return '<STR_LIT>' % node.__class__.__name__<EOL><DEDENT>attrs = []<EOL>children = node.children()<EOL>ids = {id(child) for child in children}<EOL>indentation = '<STR_LIT:U+0020>' * (indent * (_level + <NUM_LIT:1>))<EOL>header = '<STR_LIT:\n>' + indentation if indent else '<STR_LIT>'<EOL>joiner = '<STR_LIT>' + indentation if indent else '<STR_LIT:U+002CU+0020>'<EOL>tailer = '<STR_LIT:\n>' + '<STR_LIT:U+0020>' * (indent * _level) if indent else '<STR_LIT>'<EOL>for k, v in vars(node).items():<EOL><INDENT>if k.startswith('<STR_LIT:_>'):<EOL><INDENT>continue<EOL><DEDENT>if id(v) in ids:<EOL><INDENT>ids.remove(id(v))<EOL><DEDENT>if isinstance(v, Node):<EOL><INDENT>attrs.append((k, self.walk(<EOL>v, omit, indent, depth - <NUM_LIT:1>, pos, _level)))<EOL><DEDENT>elif isinstance(v, list):<EOL><INDENT>items = []<EOL>for i in v:<EOL><INDENT>if id(i) in ids:<EOL><INDENT>ids.remove(id(i))<EOL><DEDENT>items.append(self.walk(<EOL>i, omit, indent, depth - <NUM_LIT:1>, pos, _level + <NUM_LIT:1>))<EOL><DEDENT>attrs.append(<EOL>(k, '<STR_LIT:[>' + header + joiner.join(items) + tailer + '<STR_LIT:]>'))<EOL><DEDENT>else:<EOL><INDENT>attrs.append((k, repr_compat(v)))<EOL><DEDENT><DEDENT>if ids:<EOL><INDENT>attrs.append(('<STR_LIT>', '<STR_LIT:[>' + header + joiner.join(<EOL>self.walk(child, omit, indent, depth - <NUM_LIT:1>, pos, _level + <NUM_LIT:1>)<EOL>for child in children<EOL>if id(child) in ids) + tailer + '<STR_LIT:]>'))<EOL><DEDENT>position = ('<STR_LIT>' % (<EOL>'<STR_LIT:?>' if node.lineno is None else node.lineno,<EOL>'<STR_LIT:?>' if node.colno is None else node.colno,<EOL>) if pos else '<STR_LIT>')<EOL>omit_keys = () if not omit else set(omit)<EOL>return '<STR_LIT>' % (node.__class__.__name__, position, '<STR_LIT:U+002CU+0020>'.join(<EOL>'<STR_LIT>' % (k, v) for k, v in sorted(attrs)<EOL>if k not in omit_keys<EOL>))<EOL>
Accepts the standard node argument, along with an optional omit
flag - it should be an iterable that lists out all attributes
that should be omitted from the repr output.