2014-08-10 | Paul Boddie | file changeset files shortlog | Added notes about where certain operations can be performed so that they can be split into those performed on the server and those performed on the machine converting the content, if distinct. Made the profile-related operations a bit more obvious. |
paul@17 | 1 | #!/usr/bin/env python |
paul@17 | 2 | |
paul@17 | 3 | from os.path import join |
paul@17 | 4 | from os import walk |
paul@17 | 5 | import re, sys |
paul@17 | 6 | |
paul@17 | 7 | pattern = re.compile(r"(?<!{){[^{}]+}") |
paul@17 | 8 | |
paul@17 | 9 | if len(sys.argv) < 2: |
paul@17 | 10 | print >>sys.stderr, "Need a directory name." |
paul@17 | 11 | sys.exit(1) |
paul@17 | 12 | |
paul@17 | 13 | dirname = sys.argv[1] |
paul@17 | 14 | |
paul@17 | 15 | for dirpath, dirnames, filenames in walk(dirname): |
paul@17 | 16 | for filename in filenames: |
paul@17 | 17 | f = open(join(dirpath, filename)) |
paul@17 | 18 | try: |
paul@17 | 19 | for match in pattern.finditer(f.read()): |
paul@17 | 20 | print match.group() |
paul@17 | 21 | finally: |
paul@17 | 22 | f.close() |
paul@17 | 23 | |
paul@17 | 24 | # vim: tabstop=4 expandtab shiftwidth=4 |