def by_attr(self, attrname="<STR_LIT:name>"):
def get():<EOL><INDENT>for pre, fill, node in self:<EOL><INDENT>attr = attrname(node) if callable(attrname) else getattr(node, attrname, "<STR_LIT>")<EOL>if isinstance(attr, (list, tuple)):<EOL><INDENT>lines = attr<EOL><DEDENT>else:<EOL><INDENT>lines = str(attr).split("<STR_LIT:\n>")<EOL><DEDENT>yield u"<STR_LIT>" % (pre, lines[<NUM_LIT:0>])<EOL>for line in lines[<NUM_LIT:1>:]:<EOL><INDENT>yield u"<STR_LIT>" % (fill, line)<EOL><DEDENT><DEDENT><DEDENT>return "<STR_LIT:\n>".join(get())<EOL>
Return rendered tree with node attribute `attrname`.