how to write a text file search & replace script

edwardt at trillium.com edwardt at trillium.com
Mon Mar 26 18:39:27 EST 2001


Hi I am trying to write a python script to do the following.
Situation:
There are currently a bunch of files which need the following to be replaced:
1. Function names,
2. the function arguments and
3. some global variables

These are a bunch of private library functions that these files are calling.
Since all these library function names are changed. Some of the function
argument names need to be changed too, and there are some extra function
arguments!!
The files calling thest functions need to be changed too! But too many files,
so too many changes. I want to automate this with a python script.

For example: 
   def main():
       tstPrp = "Damn this thing"
       pixitObj.variant = "Python"
       PrnHdr(sid, a="OLD function name", b="those people should think before
they write the library functions", c="I am frustrated")
shall be replaced by
  def main():
       testPurpose = "Damn this thing"
       guiCb.pixitObj.variant = "Python"
       CtfPrintHeader(sid,a1="OLD function name",b1="those people should think
before they write the library functions",c="I am frustrated", d="Please
help")

Can anyone help? Also, can some kind of data structure store a list of the
function name and the associated function arguments that the script canr ead
from? So that if there are more to be changed, all I need to do just to go in
and edit the entry like a spread sheet?

Thanks 

 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse at newsone.net



More information about the Python-list mailing list