#NEWLINE# def dump( node , annotate_fields = True , include_attributes = False ) : #NEWLINE# #INDENT# '\n    Return a formatted dump of the tree in *node*.  This is mainly useful for\n    debugging purposes.  The returned string will show the names and the values\n    for fields.  This makes the code impossible to evaluate, so if evaluation is\n    wanted *annotate_fields* must be set to False.  Attributes such as line\n    numbers and column offsets are not dumped by default.  If this is wanted,\n    *include_attributes* can be set to True.\n    ' #NEWLINE# def _format( node ) : #NEWLINE# #INDENT# if isinstance ( node , AST ) : #NEWLINE# #INDENT# fields = [ ( a , _format ( b ) ) for ( a , b ) in iter_fields ( node ) ] #NEWLINE# rv = ( '%s(%s' % ( node . __class__ . __name__ , ', ' . join ( ( ( ( '%s=%s' % field ) for field in fields ) if annotate_fields else ( b for ( a , b ) in fields ) ) ) ) ) #NEWLINE# if ( include_attributes and node . _attributes ) : #NEWLINE# #INDENT# rv += ( ( fields and ', ' ) or ' ' ) #NEWLINE# rv += ', ' . join ( ( ( '%s=%s' % ( a , _format ( getattr ( node , a ) ) ) ) for a in node . _attributes ) ) #NEWLINE# #UNINDENT# return ( rv + ')' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( node , list ) : #NEWLINE# #INDENT# return ( '[%s]' % ', ' . join ( ( _format ( x ) for x in node ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# return repr ( node ) #NEWLINE# #UNINDENT# if ( not isinstance ( node , AST ) ) : #NEWLINE# #INDENT# raise TypeError ( ( 'expected AST, got %r' % _format . __class__ . __name__ ) ) #NEWLINE# #UNINDENT# return _format ( node )