freebsd-dev/contrib/cortex-strings/scripts/fixup.py
Andrew Turner 09a53ad8f1 Import the Linaro Cortex Strings library into contrib.
Sponsored by:	The FreeBSD Foundation
2016-09-19 13:12:09 +00:00

28 lines
504 B
Python

"""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()