#NEWLINE# def main( argv ) : #NEWLINE# #INDENT# target = '' #NEWLINE# search = 'C:\\Python27' #NEWLINE# replace = '..' #NEWLINE# try : #NEWLINE# #INDENT# ( opts , args ) = getopt . getopt ( argv , 'hf:s:r:' , [ 'file=' , 'search=' , 'replace=' ] ) #NEWLINE# #UNINDENT# except getopt . GetoptError : #NEWLINE# #INDENT# display_help ( ) #NEWLINE# #UNINDENT# for ( opt , arg ) in opts : #NEWLINE# #INDENT# if ( opt == '-h' ) : #NEWLINE# #INDENT# display_help ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( opt in ( '-f' , '--file' ) ) : #NEWLINE# #INDENT# target = arg #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( opt in ( '-s' , '--search' ) ) : #NEWLINE# #INDENT# search = arg #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( opt in ( '-r' , '--replace' ) ) : #NEWLINE# #INDENT# replace = arg #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( opts == '' ) : #NEWLINE# #INDENT# display_help ( ) #NEWLINE# #UNINDENT# f = open ( target , 'rb' ) . read ( ) #NEWLINE# f = f . replace ( search , replace ) #NEWLINE# f = f . replace ( search . lower ( ) , replace ) #NEWLINE# open ( target , 'wb' ) . write ( f )