""import ossys listonly false textexts [py'pyw'txt' ' 'ignore binary files def searcher(startdirsearchkey)global fcountvcount fcount vcount for (thisdirdirsherefilesherein os walk(startdir)for fname in filesheredo non-dir files here fpath os path join(thisdirfnamefnames have no dirpath visitfile(fpathsearchkeydef visitfile(fpathsearchkey)for each non-dir file global fcountvcount search for string print(vcount+ '=>'fpathskip protected files tryif not listonlyif os path splitext(fpath)[ not in textextsprint('skipping'fpathelif searchkey in open(fpathread()input('% has % (fpathsearchkey)fcount + exceptprint('failed:'fpathsys exc_info()[ ]vcount + if __name__ ='__main__'searcher(sys argv[ ]sys argv[ ]print('found in % filesvisited % (fcountvcount)operationallythis script works roughly the same as calling its visitfile function for every result generated by our find find tool with pattern of "*"but because this version is specific to searching content it can better tailored for its goal reallythis equivalence holds only because "*pattern invokes an exhaustive traversal in find findand that' all that this new script' searcher function does the finder is good at selecting specific file typesbut this script benefits from more custom single traversal when run standalonethe search key is passed on the command linewhen importedclients call this module' searcher function directly for exampleto search (that isgrepfor all appearances of string in the book examples treei run command line like this in dos or unix shellc:\\pp etools\search_all py mimetypes =\launchbrowser py =\launcher py =\launch_pydemos pyw =\launch_pygadgets_bar pyw =\__init__ py =\__init__ pyc complete system programs