view Resources/PostgreSQL/PrepareCMakeConfigurationFile.py @ 60:412e30336847

allowing dollars and underscores in MySQL database identifiers
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 19 Nov 2018 15:06:08 +0100
parents 7cea966b6829
children 8c7bb94adff7
line wrap: on
line source

#!/usr/bin/python

import re
import sys

if len(sys.argv) != 3:
    raise Exception('Bad number of arguments')

r = re.compile(r'^#undef ([A-Z0-9_]+)$')

with open(sys.argv[1], 'r') as f:
    with open(sys.argv[2], 'w') as g:
        for l in f.readlines():
            m = r.match(l)
            if m != None:
                s = m.group(1)
                g.write('#cmakedefine %s @%s@\n' % (s, s))
            else:
                g.write(l)