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

Source Code for Package pyctags

 1  ## Copyright (C) 2008 Ben Smith <benjamin.coder.smith@gmail.com> 
 2   
 3  ##    This file is part of pyctags. 
 4   
 5  ##    pyctags is free software: you can redistribute it and/or modify 
 6  ##    it under the terms of the GNU Lesser General Public License as published 
 7  ##    by the Free Software Foundation, either version 3 of the License, or 
 8  ##    (at your option) any later version. 
 9   
10  ##    pyctags is distributed in the hope that it will be useful, 
11  ##    but WITHOUT ANY WARRANTY; without even the implied warranty of 
12  ##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
13  ##    GNU General Public License for more details. 
14   
15  ##    You should have received a copy of the GNU Lesser General Public License 
16  ##    and the GNU Lesser General Public Licens along with pyctags.  If not,  
17  ##    see <http://www.gnu.org/licenses/>. 
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