I found glimpse usefull to this kind of searches, here is how I use it.
A good tip is to only install python package unzipped in your virtualenv, that is provide a -Z option parameter to the easy_install command. This will help pydev and glimpse to parse the packages content.
install
to install glimpse, download the latest release from http://webglimpse.net/trial/glimpse-latest.tar.gz
then the usual commands
$>./configure $>make #>make install
this will give you two new commands, glimpse to search in the index, glimpseindex to build the index
if you can't access the root privileges, it is possible to set a --prefix parameter.
you then create a place to store the indexes, I issued a
$>mkdir index.tg2
you don't want to index a few extensions, in the newly created index.tg folder create a file named .glimpse_exclude containig something like :
\.pyc$ \.bak$ .svn \.cover$ .*~$ \.log$
to ease the use of the commands you can set a few aliases in your environment
#Aliases for glimpse #------------------- # search all alias tsh='glimpse -n -H ~/index.tg2' # search po translation files alias tshpo='glimpse -F \.po$ -n -H ~/index.tg2' # search python sources alias tshpy='glimpse -F \.py$ -n -H ~/index.tg2' # search css alias tshcss='glimpse -F \.css$ -n -H ~/index.tg2' # search javascripts alias tshjs='glimpse -F \.js$ -n -H ~/index.tg2' # search genshi templates alias tshhtml='glimpse -F \.html$ -n -H ~/index.tg2' # reindex glimpse alias treindex='glimpseindex -H ~/index.tg2 ~/virtualenvs/tg2/'
This setup has proven quite efficient in numerous situation.
example: I need to find where the Spacer Class from the tw.forms is defined
$ pchpy Spacer | grep class /lib/python2.6/site-packages/tw.forms-0.9.9-py2.6.egg/tw/forms/fields.py: 667: class Spacer(FormField):
more details with the help commands
$>glimpse --help $>man glimpse $>man glimpseindex
No comments:
Post a Comment