idutils and Python

R

Ramon Diaz-Uriarte

Dear All,

Has anybody tried to use ID Utils
(http://www.gnu.org/software/idutils/46) with Python? I've googled, searched
the mailing list, and have found nothing.

A silly, simple use of IDUtils with Python code does work, using a language
map that says *.py files are text files. But I am wondering if someone has
done something more sophisticated. (For instance, I get matches to
commented out functions, which I'd rather not, lots of extra stuff is
indexed which probably shouldn't, etc).

Thanks,

R.

P.D. ID utils is somewhat like [ce]tags, and has support under Emacs
(see section 5.2 of the ID utils manual:
http://www.gnu.org/software/idutils/manual/idutils.html#Emacs-gid-interface47
). One nice feature is that, when searching for matches, it shows the
results in a compilation buffer, so you can see where, in each file,
the identifier is used, and visit that if you want. I like this a lot
better than "tags-search".
 
S

sjdevnull

Ramon said:
Dear All,

Has anybody tried to use ID Utils
(http://www.gnu.org/software/idutils/46) with Python?

What exactly are you trying to accomplish? If you want to index
function/class names, variables, etc then you should take a look at
"exuberant ctags" http://ctags.sourceforge.net --although it started
off as a C indexer, it has excellent Python support, it's free, and as
a bonus its indices are well supported from inside major editors (vim,
emacs, etc) so you can easily follow code flow, find function/class
definitions, etc.
 
R

Ramon Diaz-Uriarte

What exactly are you trying to accomplish? If you want to index
function/class names, variables, etc then you should take a look at
"exuberant ctags" http://ctags.sourceforge.net53 --although it started
off as a C indexer, it has excellent Python support, it's free, and as
a bonus its indices are well supported from inside major editors (vim,
emacs, etc) so you can easily follow code flow, find function/class
definitions, etc.


Sorry for not being clear enough. I want the following:

a) have my editor go to the point where a function/whatever is defined

b) see all places where a function/whatever is used.

I've tried exuberant ctags and I do like it a lot. a) is done
wonderfully (within emacs, the editor I use, but also in other
editros, from what I've read). However, b) does not work exactly as
I'd like:

1. With Emacs and tags: using "tags-search" I can visit, one by one,
all places where a function is called, but I'd like to see where it is
called before visting that file and know, before visiting each file in
turn, whether I'll visit 1 or 20 files (or, to put it in another way,
I'd like to see like a poor-mans static callgraph).

2. From what I understand, there is a deeper difference than just how
results are shown: the tags file contains the places where, say, a
function is defined, but finding where it is used requires running
grep on every file looking for the tag. (I believe that is what
"tags-search" does in emacs). In contrast, ID utils does not do any
grep, but directly goes to the ID file, where all that is already
pre-stored, which also means that it will be a lot faster than
grepping for the tags.

A tool similar to IDutils is Global
http://www.gnu.no/software/global/, but it also does not incorporate
Python support. (Though defining other parsers might be simple; I
haven't looked at it closely).

I think the wish "do not use grep, just look at the index file, and
immediately display all matches" is reasonable and probably other
Python coders had thought about it before. But I am wondering if I am
missing something obvious, as most people seem to be very happy with
exuberant ctags.


Thanks,

R.
 
S

sjdevnull

Ramon said:
Sorry for not being clear enough. I want the following:

a) have my editor go to the point where a function/whatever is defined

That's usually ctags/etags
b) see all places where a function/whatever is used.

That's usually cscope http://cscope.sourceforge.net/ but I've not
tried to use it with Python before; from the web page it looks like it
may be worth a spin:
"The fuzzy parser supports C, but is flexible enough to be useful for
C++ and Java, and for use as a generalized 'grep database' (use it to
browse large text documents!"

The vim integration is very nice. It has emacs integration too, but I
haven't used it and can't comment on how good it is.
I think the wish "do not use grep, just look at the index file, and
immediately display all matches" is reasonable and probably other
Python coders had thought about it before. But I am wondering if I am
missing something obvious, as most people seem to be very happy with
exuberant ctags.

I am usually happy with grep, but we only have a medium-large size
project (320,000 lines of Python code); I can imagine on very large
codebases that would be too slow to be practical.
 
R

Ramon Diaz-Uriarte

That's usually cscope http://cscope.sourceforge.net/ but I've not
tried to use it with Python before; from the web page it looks like it
may be worth a spin:
"The fuzzy parser supports C, but is flexible enough to be useful for
C++ and Java, and for use as a generalized 'grep database' (use it to
browse large text documents!"

Thanks for your answer. I'll take a new look at cscope (I think I
looked at it, but discarded because it seemed to focus on C/C++; never
noticed it is possible use as a general browser for large text
collections).
I am usually happy with grep, but we only have a medium-large size
project (320,000 lines of Python code); I can imagine on very large
codebases that would be too slow to be practical.

I am generally happy with grep (and your code is much larger than
ours) but idutils' output offers both that and, by showing all
together, a kind of poor-man's static call graph, and can be of use
when refactoring.

Thanks again,

R.
 
R

Ramon Diaz-Uriarte

Thanks for the answer. I had read about PyDev and its extenssions but,
if at all possible, I'd like to keep working with Emacs (or Vim)
instead of Eclipse, and I'd rather use free/open source software.

Best,

R.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top