Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'For any source file' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
For any source file
Authored by: rev_karol on May 25, '05 11:12:46AM

So you can use mdls to find out the spotlight "type" of a file. Here's what I did for a python file:

$ <b>mdls foo.py</b>
foo.py -------------
kMDItemAttributeChangeDate = 2005-05-18 15:50:45 +0100
kMDItemContentCreationDate = 2005-05-18 15:50:44 +0100
kMDItemContentModificationDate = 2005-05-18 15:50:44 +0100
kMDItemContentType = "public.python-script"
kMDItemContentTypeTree = (
<b>"public.python-script"</b>,
"public.shell-script",
"public.script",
"public.source-code",
"public.plain-text",
"public.text",
"public.data",
"public.item",
"public.content"
)
...


so the ContentTypeTree thingy tells you that public.python-script will work.
I'd beware of the public.shell-script one. I'm guessing that OS X has a ton of system shell scripts and indexing them all could slow down spotlight a lot. Although I could be wrong.


Karol.



[ Reply to This | # ]
For any source file
Authored by: schwa on May 25, '05 04:46:46PM
THe trouble with hacking a the Source Code importer to get it to index python scripts is Apple never necessarily coded the importer to handle python scripts.

It might work. It might not.

It might work with PHP because PHP is closer to C/C++/ObjC than Python is. It might just work. It might crash mdimporter every time it is run.

Notice the mights. Apple very likely did not add python to the list of support UTTypes of their source code importer because they didn't design it to work with Python. Or perhaps they did. But unless you work for Apple YOU don't know. HAcking system components like this is dumb.

And with that mini-rant out of the way ;-) I've written a Python Metadata Importer myself. This importer does more than a plain text import - it actually parses the python files and scans for function names, class names and a bunch of other metadata...

HEre's the link:

http://toxicsoftware.com/blog/index.php/weblog/python_metadata_importer_released_for_tiger/



[ Reply to This | # ]