#NEWLINE# def parse_redir( self , redir_cmd ) : #NEWLINE# #INDENT# ' Parse a command :redir content. ' #NEWLINE# redir_cmd_str = redir_cmd [ 'str' ] #NEWLINE# matched = re . match ( 'redir?!?\\s*(=>>?\\s*)(\\S+)' , redir_cmd_str ) #NEWLINE# if matched : #NEWLINE# #INDENT# redir_cmd_op = matched . group ( 1 ) #NEWLINE# redir_cmd_body = matched . group ( 2 ) #NEWLINE# arg_pos = redir_cmd [ 'ea' ] [ 'argpos' ] #NEWLINE# start_pos = { #NEWLINE# #INDENT# 'col' : ( arg_pos [ 'col' ] + len ( redir_cmd_op ) ) , #NEWLINE# 'i' : ( arg_pos [ 'i' ] + len ( redir_cmd_op ) ) , #NEWLINE# 'lnum' : arg_pos [ 'lnum' ] , #NEWLINE# #UNINDENT# } #NEWLINE# raw_ast = self . parse ( ( 'echo ' + redir_cmd_body ) ) #NEWLINE# redir_cmd_ast = raw_ast [ 'body' ] [ 0 ] [ 'list' ] [ 0 ] #NEWLINE# def adjust_position( node ) : #NEWLINE# #INDENT# pos = node [ 'pos' ] #NEWLINE# pos [ 'col' ] += ( ( start_pos [ 'col' ] - 1 ) - 5 ) #NEWLINE# pos [ 'i' ] += ( start_pos [ 'i' ] - 5 ) #NEWLINE# pos [ 'lnum' ] += ( start_pos [ 'lnum' ] - 1 ) #NEWLINE# #UNINDENT# traverse ( redir_cmd_ast , on_enter = adjust_position ) #NEWLINE# return redir_cmd_ast #NEWLINE# #UNINDENT# return None