view contrib/tmplrewrite.py @ 13041:79388a8325dc stable

wix: switch Mercurial Windows installer to use py2exe --bundle 3 --bundle 3 leaves all of the compiled C extensions and other DLLs outside of the library.zip, so we no longer add the installer folder to the system PATH. Instead, we now ship a small bin/hg.cmd and it is placed in the PATH. Switching to py2exe --bundle 3 is necessary because the higher bundle options are not supported on x64.
author Steve Borho <steve@borho.org>
date Fri, 26 Nov 2010 16:18:19 -0600
parents 94ef2c8ce683
children
line wrap: on
line source

#!/usr/bin/python
import sys, os, re

IGNORE = ['.css', '.py']
oldre = re.compile('#([\w\|%]+)#')

def rewrite(fn):
    f = open(fn)
    new = open(fn + '.new', 'wb')
    for ln in f:
        new.write(oldre.sub('{\\1}', ln))
    new.close()
    f.close()
    os.rename(new.name, f.name)

if __name__ == '__main__':
    if len(sys.argv) < 2:
        print 'usage: python tmplrewrite.py [file [file [file]]]'
    for fn in sys.argv[1:]:
        if os.path.splitext(fn) in IGNORE:
            continue
        print 'rewriting %s...' % fn
        rewrite(fn)