search_replace.py
Go to the documentation of this file.
00001 import os, sys
00002 
00003 def search_replace(path, out):
00004     stext = '<depend package="player_bender_dummy" />'
00005     rtext = '<!--<depend package="player_bender_dummy" />-->'   
00006     print 'Sought after text: ', stext
00007     print 'Replace text: ', rtext
00008     #path = 'manifest.xml'
00009     #out = 'tmp'
00010     input = open(path)
00011     output = open(out, 'w')
00012     for s in input.xreadlines():
00013         output.write(s.replace(stext, rtext))
00014     input.close()
00015     output.close()
00016     command = 'mv ' + out + ' ' + path
00017     os.system(command)
00018 
00019 def undo_search_replace(path, out):
00020     rtext = '<depend package="player_bender_dummy" />'
00021     stext = '<!--<depend package="player_bender_dummy" />-->'   
00022     print 'Sought after text: ', stext
00023     print 'Replace text: ', rtext
00024    # path = 'manifest.xml'
00025    # out = 'tmp'
00026     input = open(path)
00027     output = open(out, 'w')
00028     for s in input.xreadlines():
00029         output.write(s.replace(stext, rtext))
00030     input.close()
00031     output.close()
00032     command = 'mv ' + out + ' ' + path
00033     os.system(command)
00034     
00035 
00036 if __name__ == "__main__":
00037     if sys.argv[3] == '0':
00038         search_replace(sys.argv[1],sys.argv[2])
00039     elif sys.argv[3] == '1':
00040         undo_search_replace(sys.argv[1],sys.argv[2])
00041     else:
00042         print 'Do nothing!!'


player_log_actarray
Author(s): Radu Bogdan Rusu
autogenerated on Mon Oct 6 2014 09:38:35