1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 """
22 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.
23
24 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.
25
26 B{Security Notes:}
27 - This package makes use of the subprocess.Popen() and eval() python constructs.
28 - This package B{does not} filter the parameters for security, instead relying on module users to implement relevant security for their applications.
29
30 Included in the source distribution are a few examples of usage, the test cases provide a more comprehensive usage reference.
31
32 Here's a very small sample to show it in action::
33
34 from pyctags import exuberant_ctags, ctags_file
35 from pyctags.harvesters import kind_harvester
36
37 # if you have a list of source files:
38 ctags = exuberant_ctags(files=['path/to/source.h', 'path/to/source.c', 'path/to/source.py'])
39
40 # you can generate a ctags_file instance right away
41 # ctags_file is what parses lines from the generator or a
42 # tags file and creates a list of ctags_entry instances
43 tag_file = ctags.generate_object()
44
45 # override the default run parameters for exuberant ctags, so we get full kind names, say
46 tag_file = ctags.generate_object(generator_options={'--fields' : '+iKmn', '-F' : None})
47
48 print len(tagfile.tags) # number of tags
49
50 harvester = kind_harvester()
51 harvester.process_tag_list(tagfile.tags)
52 kinds = harvester.get_data()
53 print(kinds['class']) # print list of classes
54
55 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.
56 Feel free to contact me for or with details.
57
58 Pyctags is pretty heavy for large projects. A 153 MB tag file generated from linux kernel sources takes a while to
59 process and consumes over 1.1GB of RAM. I hope to discover more ways to trim this down without going for a C implementation.
60 """
61
62 from pyctags.tag_file import ctags_file
63 from pyctags.tag_entry import ctags_entry
64 from pyctags.exuberant import exuberant_ctags
65 import pyctags.harvesters
66