Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import os, sys
- import glob
- nargs = len(sys.argv)
- if not 3 <= nargs <= 5:
- print "usage: %s search_text replace_text [infile [outfile]]" % \
- os.path.basename(sys.argv[0])
- else:
- stext = sys.argv[1]
- rtext = sys.argv[2]
- input = sys.stdin
- output = sys.stdout
- files = glob.glob('./employee/*/*py')
- for file in files:
- if nargs > 3:
- input = open(file)
- if nargs > 4:
- output = open(file + '_copy', 'w')
- for s in input.xreadlines( ):
- output.write(s.replace(stext, rtext))
- output.close( )
- input.close( )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement