[Pythonmac-SIG] Spotlight and Python

Jonathan Wight jwight_lists at toxicsoftware.com
Tue May 10 21:00:32 CEST 2005


On May 10, 2005, at 14:49, David Reed wrote:

> 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?

See:

http://developer.apple.com/documentation/Carbon/Reference/MDItemRef/ 
Reference/chapter_1.3_section_2.html#//apple_ref/doc/c_ref/ 
kMDItemTextContent

The best way I think would be to create new spotlight metadata  
attribute types for "Class Name" and "Function Name" (or see if C/ 
ObjC files already provide similar useful keys (just checked - they  
don't seem to). Then find all the class/function names in the file  
and add them to the new attributes. Then you'd join all this data  
together with whitespace and put it into the kMDItemTextContent  
attribute.

I'm not sure how useful it is to index function & class names though.  
There could be a heck of a lot of those - most of which might not be  
too useful. Wouldn't doing something with the Python __doc__ blocks  
be more useful?

     Jon.


More information about the Pythonmac-SIG mailing list