view contrib/tmplrewrite.py @ 19490:074bd02352c0 stable

sslutil: force SSLv3 on Python 2.6 and later (issue3905) We can't (easily) force SSL version on older Pythons, but on 2.6 and later we can force SSLv3, which is safer and widely supported. This also appears to work around a bug in IIS detailed in issue 3905.
author Augie Fackler <raf@durin42.com>
date Wed, 24 Jul 2013 14:51:13 -0400
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)