Skip to content

Instantly share code, notes, and snippets.

@simplylizz
Created November 26, 2012 20:19
Show Gist options
  • Select an option

  • Save simplylizz/4150361 to your computer and use it in GitHub Desktop.

Select an option

Save simplylizz/4150361 to your computer and use it in GitHub Desktop.

Revisions

  1. simplylizz created this gist Nov 26, 2012.
    20 changes: 20 additions & 0 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    """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()))