[Pythonmac-SIG] Spotlight and Python
Jonathan Wight
jwight_lists at toxicsoftware.com
Tue May 10 18:01:03 CEST 2005
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.
On May 10, 2005, at 11:28, David Reed wrote:
> I noticed Spotlight doesn't index Python files. I'm not certain how
> useful it would be but I was thinking about trying to get spotlight
> to index the name of classes and functions/methods (i.e., you could
> enter a class name and spotlight would find the Python file
> containing the class). I don't care if it does it on the fly as files
> are updated, but thought it would be nice to be able to run a Python
> script that would index all Python files in a directory. You could
> use the inspect module to grab the class/function/method names and
> tell spotlight to include them. I know there are some command line
> tools to interact with spotlight, but after a quick look at them,
> nothing jumped out at me for doing this.
>
> Is anyone interested in this (i.e., would you find it useful) and if
> so, does anyone understand Spotlight well enough to point me in the
> right direction (pointers to specific documentation are welcome).
>
> Thanks,
> Dave
More information about the Pythonmac-SIG
mailing list