[Pythonmac-SIG] Spotlight Importing without .py

Jonathan Wight jwight_lists at toxicsoftware.com
Sat Jan 21 18:04:16 CET 2006

On Jan 21, 2006, at 2:01 AM, Nicholas Matsakis wrote:

> http://www.apple.com/downloads/macosx/spotlight/ 
> pythonmetadataimporter.html
> I really dig the Spotlight Metadata Importer for python, but it  
> only works
> for files ending in ".py" which excludes various shell scripts I have
> written that have no filename extension.  Anyone have a super elegant
> solution to this problem?
> Here's my thoughts on the matter.  To my knowledge, Mac OS X has only
> three ways of knowing the type of a file: the HFS type code, the  
> filename
> extension, and the presence of an executable bit on a file* (in  
> order of
> precidence). I've already nixed filename extensions and the  
> executable bit
> only seems to be able to identify something as a "Unix Executable  
> File".
> So, that leaves HFS type codes. The first question is whether this  
> is an
> HFS type code lying around from the days of yore that identified a  
> python
> executable script?  If not, would anyone mind if I registered one?  
> (Once
> we've got a suitable type code, modifying the Spotlight Metadata  
> Importer
> to claim it is no big deal).

> As a crazy alternative to all of the above, the python metadata  
> importer
> could be written to work in conjunction with spotmeta
> (http://www.fluffy.co.uk/spotmeta/) to additionally run on all text or
> executable files and only add the python metadata if the file  
> actually is
> a python file.  Not that I'm suggesting this be done or anything,  
> but I
> think its an interesting idea.  Hopefully Leopard will provide a more
> elegant solution to this problem.

Hi Nicholas,

I'm the author of Python Metadata Importer. There should already be a  
HFS type code for Python source. I can add the type code to Python  
Metadata Importer to wide its search. Getting the importer to work  
with Spotmeta is AFAICT a non-starter - all Spotmeta seems to do is  
add extra metadata to a file - it doesn't change the importer that a  
file is imported with.


More information about the Pythonmac-SIG mailing list