py ('text/ -python'nonepyw (nonenonehtml ('text/html'nonec ('text/plain'noneh ('text/plain'nonexml ('text/xml'nonewe can add this technique to our earlier searchvisitor class by redefining its candidate selection methodin order to replace its default extension lists with mimetypes guesses-yet more evidence of the power of oop customization at workc:\pp \toolspython import mimetypes from visitor import searchvisitor or pp tools visitor if not class searchmimevisitor(searchvisitor)def candidate(selffname)contypeencoding mimetypes guess_type(fnamereturn (contype and contype split('/')[ ='textand encoding =nonev searchmimevisitor('mimetypes'trace= search key run( ' :\temp\pp \examples'root dir :\temp\pp \examples\pp \extras\losalamosadvancedclass\day -system\data txt ha mimetypes :\temp\pp \examples\pp \internet\email\mailtools\mailparser py has mimetypes :\temp\pp \examples\pp \internet\email\mailtools\mailsender py has mimetypes :\temp\pp \examples\pp \internet\ftp\mirror\downloadflat py has mimetypes :\temp\pp \examples\pp \internet\ftp\mirror\downloadflat_modular py has mimet ypes :\temp\pp \examples\pp \internet\ftp\mirror\ftptools py has mimetypes :\temp\pp \examples\pp \internet\ftp\mirror\uploadflat py has mimetypes :\temp\pp \examples\pp \system\media\playfile py has mimetypes scountv fcountv dcount ( because this is not completely accuratethough (you may need to add logic to include extensions like pywmissed by the guess)and because it' not even appropriate for all search clients (some may want to search specific kinds of text only)this scheme was not used for the original class using and tailoring it for your own searches is left as optional exercise running the script nowwhen example - is run from the command lineif all goes well its canned selftest code at the end opens number of audioimagetextand other file types located in the script' directoryusing either platform-specific players or general web browser on my windows laptopgif and html files open in new ie browser tabsjpeg files in windows photo viewerplain text files in notepaddoc and xls files in microsoft word and exceland audio files in windows media player complete system programs