Index: trunk/tools/code-utils/auditcode.py |
— | — | @@ -0,0 +1,31 @@ |
| 2 | +#!/usr/bin/python |
| 3 | +""" Given a list of files containing class definitions in the order of their class |
| 4 | +hierarchy, this program will print the class names and function names that will |
| 5 | +actually get executed when you call $this->function() """ |
| 6 | + |
| 7 | +import sys, re |
| 8 | + |
| 9 | +functions = {} |
| 10 | +classes = {} |
| 11 | +cl = None |
| 12 | +for fn in sys.argv[1:]: |
| 13 | + for line in open(fn): |
| 14 | + match = re.match(r'(abstract\s+)?class\s+(.*?)\s+(extends\s+(.*?)\s+)?\{', line) |
| 15 | + if match: |
| 16 | + cl = match.group(2) |
| 17 | + supercl = match.group(4) |
| 18 | + classes[cl] = supercl |
| 19 | + if supercl: |
| 20 | + classes[supercl] # superclass should already exist |
| 21 | + |
| 22 | + match = re.match(r'\s*(public\s+|static\s+)?function\s+(.*?)\(', line) |
| 23 | + if match: |
| 24 | + # we have a function definition. |
| 25 | + funct = match.group(2) |
| 26 | + functions[funct] = cl |
| 27 | + |
| 28 | +keys = functions.keys() |
| 29 | +keys.sort() |
| 30 | +for key in keys: |
| 31 | + print key,functions[key] |
| 32 | + |
Property changes on: trunk/tools/code-utils/auditcode.py |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 33 | + native |