1 Introduction
2 ------------
3
4 The astgrep program permits the searching of Python source files for textual
5 information of a specific type. Instead of matching a search term or
6 expression to all text in a program, as grep would do, astgrep matches only
7 tokens in the program having a particular type, such as names or constants.
8
9 Quick Start
10 -----------
11
12 Try the following examples, replacing astgrep with astgrep.py if the software
13 has not been installed from a package:
14
15 Search for classes whose name contains Node in a particular file:
16
17 astgrep -t Class -e Node libxml2dom/__init__.py
18
19 Search for functions or methods whose name starts with visit in a particular
20 directory hierarchy, micropython, showing the name of the matching functions
21 in the output:
22
23 astgrep -p -t Function -e '^visit' -r micropython
24
25 Search for accesses of attributes having the exact name _node in a particular
26 directory hierarchy, libxml2dom, showing the line number of each match in the
27 output:
28
29 astgrep -n -t Getattr -e '^_node$' -r libxml2dom
30
31 Dependencies
32 ------------
33
34 The astgrep program has the following basic dependencies:
35
36 Package Release Information
37 ------- -------------------
38
39 Python 2.5.1
40 cmdsyntax Tested with 0.91
41
42 URLs
43 ----
44
45 Python http://www.python.org/
46 CMDsyntax http://www.boddie.org.uk/david/Projects/Python/CMDSyntax/index.html
47
48 Contact, Copyright and Licence Information
49 ------------------------------------------
50
51 The current Web page for astgrep at the time of release is:
52
53 http://www.boddie.org.uk/python/astgrep.html
54
55 Copyright and licence information can be found in the docs directory - see
56 docs/COPYING.txt and docs/gpl-3.0.txt for more information.
57
58 New in astgrep 0.1.1 (Changes since astgrep 0.1)
59 ------------------------------------------------
60
61 * Supported searching of mixtures of files and directories.
62 * Prevented searching of docstrings, since the information about them is
63 deficient in the abstract syntax trees.
64 * Removed the term type requirement, permitting searching in all types.
65 * Removed the pattern requirement, permitting searching for all tokens of a
66 particular type (or, indeed, all tokens).
67
68 Release Procedures
69 ------------------
70
71 Update the astgrep.py __version__ attributes.
72 Change the version number and package filename/directory in the documentation.
73 Update the release notes (see above).
74 Check the setup.py file.
75 Check the release information in the PKG-INFO file and in the package
76 changelog (and other files).
77 Tag, export.
78 Remove generated .pyc files: rm `find . -name "*.pyc"`
79 Archive, upload.
80
81 Making Packages
82 ---------------
83
84 To make Debian-based packages:
85
86 1. Create new package directories under packages if necessary.
87 2. Make a symbolic link in the distribution's root directory to keep the
88 Debian tools happy. Try one of the following:
89
90 ln -s packages/ubuntu-gutsy/python-astgrep/debian/
91
92 3. Run the package builder:
93
94 dpkg-buildpackage -rfakeroot
95
96 4. Locate and tidy up the packages in the parent directory of the
97 distribution's root directory.