[Pythonmac-SIG] Spotlight Importing without .py
Nicholas Matsakis
matsakis at mit.edu
Sat Jan 21 20:59:42 CET 2006
On Sat, 21 Jan 2006, Jonathan Wight wrote:
> 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.
[I'm replying to a response that didn't go to pythonmac-sig, presumably
because Jonathan's sending address isn't on the list]
Actually, spotmeta allows you to have an importer extend existing
importers. So, what you could do is extend the importers for text files
and unix executables (which is a superset of python executables) and then
check the file to see if it actually is (as near as you can tell) and if
so, determine and dump the python metadata, otherwise do nothing. More
details at:
http://www.fluffy.co.uk/spotmeta/developer.html
I mention this not because I think it's a good idea; spotmeta adds another
layer of complication and the idea of inspecting _every_ text file on the
system to see if it is python source seems iffy. Rather, I'm just curious
what the "right" way of doing it should be. I would hope that 10.5 would
bring with an extensible system of file inspection such that it would only
be necessary to inspect text files that were clearly not of another type
like RTF or HTML.
And, of course, file inspection is really a last resort for applying types
to text files since there are so many edge cases and ambiguities. Still,
I just want my Mac to understand that when a file begins with
#!/usr/bin/python it should try to apply the python metadata importer to
it.
Nick
More information about the Pythonmac-SIG
mailing list