#NEWLINE# def rebase_replace_insn( path , istream ) : #NEWLINE# #INDENT# '\n    Function replaces the current instructions listed in the rebase\n    instructions (insn) file with those read from the given istream.\n    ' #NEWLINE# echo_out = False #NEWLINE# for line in fileinput . input ( path , inplace = True ) : #NEWLINE# #INDENT# stripped = line . strip ( ) #NEWLINE# if ( not stripped ) : #NEWLINE# #INDENT# if ( not line ) : #NEWLINE# #INDENT# while True : #NEWLINE# #INDENT# replacement = istream . readline ( ) . strip ( ) #NEWLINE# if ( not replacement ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# if ( not replacement . startswith ( '#' ) ) : #NEWLINE# #INDENT# print ( replacement ) #NEWLINE# #UNINDENT# #UNINDENT# print ( '' ) #NEWLINE# echo_out = True #NEWLINE# #UNINDENT# continue #NEWLINE# #UNINDENT# if echo_out : #NEWLINE# #INDENT# print ( stripped )