1 #!/usr/bin/env python 2 3 from os.path import join 4 from os import walk 5 import re, sys 6 7 pattern = re.compile(r"(?<!{){[^{}]+}") 8 9 if len(sys.argv) < 2: 10 print >>sys.stderr, "Need a directory name." 11 sys.exit(1) 12 13 dirname = sys.argv[1] 14 15 for dirpath, dirnames, filenames in walk(dirname): 16 for filename in filenames: 17 f = open(join(dirpath, filename)) 18 try: 19 for match in pattern.finditer(f.read()): 20 print match.group() 21 finally: 22 f.close() 23 24 # vim: tabstop=4 expandtab shiftwidth=4