[Pythonmac-SIG] Spotlight and Python
Jonathan Wight
jwight_lists at toxicsoftware.com
Wed May 11 17:06:39 CEST 2005
It is entirely possible I screwed something up and that it doesn't
work on anything other than my Powerbook ;-)
However:
As the last part of the install process the installer kicks off a
script to reindex the Python files on the hard drive. This could be
failing. To manually reindex runt this:
mdimport -r /Library/Spotlight/Python\ Metadata\ Importer.mdimporter/
You should see a response like this:
2005-05-11 10:55:48.004 mdimport[21563] Asking server to reimport
files with UTIs: (
"dyn.ah62d4rv4ge81a8k",
"dyn.ah62d4rv4gq81k3p2su11upputf4gu55sfz30g6xmsb4a",
"public.python-script"
)
On my machine with 2748 python files indexable by Spotlight ( mdfind
'kMDItemContentType == "public.python-script' | wc -l ) it seems to
take less than 5 minutes with 2 mdimport tasks running at between
30-70% CPU.
Note that spotlight doesn't index Python.framework by default - so
you'd need to configure that somehow (perhaps via the .Spotlight-V100
directory).
To confirm that the Python mdimporter is working run mdimport against
a python file (with classes & functions declared) with debugging
turned on. You should see something like this, note that mdimport is
using the Python mdimporter and that the 'org_python_functions'
attribute is present in the output:
mdimport -d 2 myimporter.py
2005-05-11 11:03:51.318 mdimport[21650] Import '/Volumes/Home/Users/
schwa/Desktop/Python Metadata Importer/myimporter.py' type
'public.python-script' using 'file://localhost/Library/Spotlight/
Python%20Metadata%20Importer.mdimporter/'
2005-05-11 11:03:51.622 mdimport[21650] Done.
2005-05-11 11:03:51.624 mdimport[21650] Sending attributes of '/
Volumes/Home/Users/schwa/Desktop/Python Metadata Importer/
myimporter.py' to server. Attributes: '{
"com_apple_metadata_modtime" = 137481386;
kMDItemContentCreationDate = "2005-05-11 00:03:18 -0400";
kMDItemContentModificationDate = "2005-05-11 01:16:26 -0400";
kMDItemContentType = "public.python-script";
kMDItemContentTypeTree = (
"public.python-script",
"public.shell-script",
"public.script",
"public.source-code",
"public.plain-text",
"public.text",
"public.data",
"public.item",
"public.content"
);
kMDItemDisplayName = {"" = "myimporter.py"; };
kMDItemKind = {"" = "Python Script"; };
"org_python_classes" = ();
"org_python_functions" = (find, main);
Let me know if this works.
Jon.
On May 11, 2005, at 10:51, David Reed wrote:
> Thanks for working on this. I'm not certain it is working
> correctly. I installed it about 3 hours ago so I would think it has
> had time to index my drive by now. It does seem to have indexed
> files that are part of python packages but it hasn't index Python
> files in my home directory and subdirectories. Is it skipping these
> on purpose or does it somehow not realize they are Python files
> (most of them were created with emacs and many on Linux systems
> before I switched to a Mac)? They all do have a .py extension.
>
> Also, how do you uninstall your plugin?
>
> I do have XCode installed.
More information about the Pythonmac-SIG
mailing list