aboutsummaryrefslogtreecommitdiff
path: root/contrib/cortex-strings/scripts/fixup.py
blob: 003783a49838b667586e81f2ac2f85a3fe8ab67e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""Simple script that enables target specific blocks based on the first argument.

Matches comment blocks like this:

/* For Foo: abc
def
*/

and de-comments them giving:
abc
def
"""
import re
import sys

def main():
    key = sys.argv[1]
    expr = re.compile(r'/\* For %s:\s([^*]+)\*/' % key, re.M)

    for arg in sys.argv[2:]:
        with open(arg) as f:
            body = f.read()
        with open(arg, 'w') as f:
            f.write(expr.sub(r'\1', body))

if __name__ == '__main__':
    main()