Package pyctags
[hide private]
[frames] | no frames]

Package pyctags

source code

A ctags file reader and a wrapper to the command line program ctags. With the extensions that exuberant ctags provides, this could be useful for static code analysis.

This package has been tested against exuberant ctags version 5.7 and SVN revision 686 on Windows XP and Linux with Python 2.5 and 3.0.

Security Notes:

Included in the source distribution are a few examples of usage, the test cases provide a more comprehensive usage reference.

Here's a very small sample to show it in action:

   from pyctags import exuberant_ctags, ctags_file
   from pyctags.harvesters import kind_harvester

   # if you have a list of source files:
   ctags = exuberant_ctags(files=['path/to/source.h', 'path/to/source.c', 'path/to/source.py'])

   # you can generate a ctags_file instance right away
   # ctags_file is what parses lines from the generator or a 
   # tags file and creates a list of ctags_entry instances
   tag_file = ctags.generate_object()

   # override the default run parameters for exuberant ctags, so we get full kind names, say
   tag_file = ctags.generate_object(generator_options={'--fields' : '+iKmn', '-F' : None})

   print len(tagfile.tags) # number of tags
   
   harvester = kind_harvester()
   harvester.process_tag_list(tagfile.tags)
   kinds = harvester.get_data()
   print(kinds['class']) # print list of classes

I'm not certain if ctags generators other than Exuberant Ctags are in much use, but wrappers for them can be derived from ctags_base. Feel free to contact me for or with details.

Pyctags is pretty heavy for large projects. A 153 MB tag file generated from linux kernel sources takes a while to process and consumes over 1.1GB of RAM. I hope to discover more ways to trim this down without going for a C implementation.

Submodules [hide private]