File: make_swig.py

package info (click to toggle)
egenix-mx-base 2.0.6-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,028 kB
  • ctags: 4,762
  • sloc: ansic: 14,965; python: 11,739; sh: 313; makefile: 117
file content (23 lines) | stat: -rwxr-xr-x 446 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/local/bin/python

import re,sys

static_const = re.compile('static (\w+) const')

def fix(text):

    """ SWIG doesn't like 'static int const' members... using 'const int'
        works instead.
    """
    return static_const.sub(r'const \1',text)

def main(infile,outfile):

    text = open(infile,'rb').read()
    text = fix(text)
    open(outfile,'wb').write(text)

if __name__ == '__main__':

    apply(main,tuple(sys.argv[1:]))