[Pythonmac-SIG] Spotlight and Python
David Reed
dreedmac at columbus.rr.com
Tue May 10 20:49:31 CEST 2005
On May 10, 2005, at 12:01 PM, Jonathan Wight wrote:
> It's certainly a good idea.
>
> Writing a Spotlight plug-in is extremely straight forward - just
> fire up Xcode 2 and create a new "Metadata Importer" project. You
> just have one function that you need to provide:
>
> Boolean GetMetadataForFile(void* thisInterface,
> CFMutableDictionaryRef attributes,
> CFStringRef contentTypeUTI,
> CFStringRef pathToFile)
>
> Don't forget to modify the Info.plist and possibly the schema.xml
> file.
>
> Also - you'll probably need to create an installer for the importer
> so that when installed it forces a reindex, see: http://
> www.apple.com/downloads/macosx/submit/installers.html
>
> Now I believe that Spotlight is smart enough to detect when a file
> is created/written that needs importing so you wont have to
> manually force any re-indexing yourself.
>
> I'm currently writing a spotlight importers for the GPX xml file
> format and for another inhouse project of mine.
>
> Jon.
I've looked at the example at:
http://developer.apple.com/documentation/Carbon/Conceptual/
MDImporters/Concepts/WritingAnImp.html#//apple_ref/doc/uid/TP40001275-
CJBEJBHH
I don't yet understand what NSDictionary tempDict contains after it
"loads the document at the specified location".
My thought would be to read the file and look for def and class and
then grab the next word after it and add it to the index. Looks like
kMDItemTextContent is what could be used to do that.
I could read the file in C and look for def/class and then would just
need to figure out how to use the kMDItemTextContent class.
Am I on the correct track?
Dave
More information about the Pythonmac-SIG
mailing list