File: fixtemplate.py

package info (click to toggle)
pylize 1.3b-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 356 kB
  • ctags: 140
  • sloc: python: 935; makefile: 65
file content (19 lines) | stat: -rw-r--r-- 418 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import sys, re

def main(args):
    try:
        file = args.pop(0)
    except IndexError:
        print "Usage: fixtemplate.py FILE"
        sys.exit(0)
    fp = open(file)
    text = fp.read()
    fp.close()
    rx = re.compile('{(.*?)}', re.DOTALL)
    text = rx.sub(lambda x: "@(%s)" % x.group(1), text)
    fp = open(file, 'w')
    fp.write(text)
    fp.close()

if __name__ == '__main__':
    main(sys.argv[1:])