#NEWLINE# def text_to_node( text , lineno = None ) : #NEWLINE# #INDENT# 'Given a Python source string, return the corresponding AST node.\n    The outer Module node is removed so that the node corresponding to the\n    given text can be added to an existing AST.\n    ' #NEWLINE# modnode = ast . parse ( text , 'exec' ) #NEWLINE# if ( len ( lineno . body ) == 1 ) : #NEWLINE# #INDENT# node = modnode . body [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# node = modnode . body #NEWLINE# #UNINDENT# if ( lineno is not None ) : #NEWLINE# #INDENT# node . lineno = lineno #NEWLINE# node . col_offset = 0 #NEWLINE# for child in ast . iter_child_nodes ( node ) : #NEWLINE# #INDENT# child . lineno = lineno #NEWLINE# child . col_offset = 0 #NEWLINE# #UNINDENT# #UNINDENT# return node