= :\temp\pp \examples\pp \tempparts\part- txt = :\temp\pp \examples\pp \tempparts\part- html edited filesvisited thisfinallyis the exact tool was looking for to simplify global book examples tree maintenance after major changes to things such as shared modules and file and directory namesi run this script on the examples root directory with an appropriate search string and edit any files it pops up as needed still need to change files by hand in the editorbut that' often safer than blind global replacements global replacements in directory trees (visitorbut since brought it upgiven general tree traversal classit' easy to code global search-and-replace subclasstoo the replacevisitor class in example - is search visitor subclass that customizes the visitfile method to globally replace any appearances of one string with anotherin all text files at and below root directory it also collects the names of all files that were changed in list just in case you wish to go through and verify the automatic edits applied ( text editor could be automatically popped up on each changed filefor instanceexample - pp \tools\visitor_replace py ""use"python \tools\visitor_replace py rootdir fromstr tostrdoes global search-and-replace in all files in directory treereplaces fromstr with tostr in all text filesthis is powerful but dangerous!visitor_edit py runs an editor for you to verify and make changesand so is saferuse visitor_collect py to simply collect matched files listlistonly mode here is similar to both searchvisitor and collectvisitor""import sys from visitor import searchvisitor class replacevisitor(searchvisitor)""change fromstr to tostr in files at and below startdirfiles changed available in obj changed list after run ""def __init__(selffromstrtostrlistonly=falsetrace= )self changed [self tostr tostr self listonly listonly searchvisitor __init__(selffromstrtracedef visitmatch(selffnametext)self changed append(fnameif not self listonlyfromstrtostr self contextself tostr text text replace(fromstrtostropen(fname' 'write(text complete system programs