def pprint(walker):
output = []<EOL>indent = <NUM_LIT:0><EOL>for token in concatenateCharacterTokens(walker):<EOL><INDENT>type = token["<STR_LIT:type>"]<EOL>if type in ("<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>if token["<STR_LIT>"] and token["<STR_LIT>"] != constants.namespaces["<STR_LIT:html>"]:<EOL><INDENT>if token["<STR_LIT>"] in constants.prefixes:<EOL><INDENT>ns = constants.prefixes[token["<STR_LIT>"]]<EOL><DEDENT>else:<EOL><INDENT>ns = token["<STR_LIT>"]<EOL><DEDENT>name = "<STR_LIT>" % (ns, token["<STR_LIT:name>"])<EOL><DEDENT>else:<EOL><INDENT>name = token["<STR_LIT:name>"]<EOL><DEDENT>output.append("<STR_LIT>" % ("<STR_LIT:U+0020>" * indent, name))<EOL>indent += <NUM_LIT:2><EOL>attrs = token["<STR_LIT:data>"]<EOL>for (namespace, localname), value in sorted(attrs.items()):<EOL><INDENT>if namespace:<EOL><INDENT>if namespace in constants.prefixes:<EOL><INDENT>ns = constants.prefixes[namespace]<EOL><DEDENT>else:<EOL><INDENT>ns = namespace<EOL><DEDENT>name = "<STR_LIT>" % (ns, localname)<EOL><DEDENT>else:<EOL><INDENT>name = localname<EOL><DEDENT>output.append("<STR_LIT>" % ("<STR_LIT:U+0020>" * indent, name, value))<EOL><DEDENT>if type == "<STR_LIT>":<EOL><INDENT>indent -= <NUM_LIT:2><EOL><DEDENT><DEDENT>elif type == "<STR_LIT>":<EOL><INDENT>indent -= <NUM_LIT:2><EOL><DEDENT>elif type == "<STR_LIT>":<EOL><INDENT>output.append("<STR_LIT>" % ("<STR_LIT:U+0020>" * indent, token["<STR_LIT:data>"]))<EOL><DEDENT>elif type == "<STR_LIT>":<EOL><INDENT>if token["<STR_LIT:name>"]:<EOL><INDENT>if token["<STR_LIT>"]:<EOL><INDENT>output.append("""<STR_LIT>""" %<EOL>("<STR_LIT:U+0020>" * indent,<EOL>token["<STR_LIT:name>"],<EOL>token["<STR_LIT>"],<EOL>token["<STR_LIT>"] if token["<STR_LIT>"] else "<STR_LIT>"))<EOL><DEDENT>elif token["<STR_LIT>"]:<EOL><INDENT>output.append("""<STR_LIT>""" %<EOL>("<STR_LIT:U+0020>" * indent,<EOL>token["<STR_LIT:name>"],<EOL>token["<STR_LIT>"]))<EOL><DEDENT>else:<EOL><INDENT>output.append("<STR_LIT>" % ("<STR_LIT:U+0020>" * indent,<EOL>token["<STR_LIT:name>"]))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>output.append("<STR_LIT>" % ("<STR_LIT:U+0020>" * indent,))<EOL><DEDENT><DEDENT>elif type == "<STR_LIT>":<EOL><INDENT>output.append("<STR_LIT>" % ("<STR_LIT:U+0020>" * indent, token["<STR_LIT:data>"]))<EOL><DEDENT>elif type == "<STR_LIT>":<EOL><INDENT>assert False, "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>" % type)<EOL><DEDENT><DEDENT>return "<STR_LIT:\n>".join(output)<EOL>
Pretty printer for tree walkers

    Takes a TreeWalker instance and pretty prints the output of walking the tree.

    :arg walker: a TreeWalker instance