Created
November 26, 2012 20:19
-
-
Save simplylizz/4150361 to your computer and use it in GitHub Desktop.
String finder for python code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """Parses files in the current dir to find all strings""" | |
| import fnmatch | |
| import os | |
| import ast | |
| class ShowStrings(ast.NodeVisitor): | |
| def visit_Str(self, node): | |
| print node.lineno, node.col_offset, repr(node.s) | |
| if __name__ == '__main__': | |
| for root, dirs, files in os.walk('.'): | |
| for filename in fnmatch.filter(files, '*.py'): | |
| full_name = os.path.join(root, filename) | |
| if ('/migrations/' not in full_name and | |
| '/pycontrol/' not in full_name): | |
| print '### PROCESSING FILE %s ###' % full_name | |
| ShowStrings().visit(ast.parse(open(full_name, 'r').read())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment