Added some tools to manipulate source code in bulk

This commit is contained in:
Guilhem Lavaux 2013-03-02 15:26:55 -06:00
parent e9194f5c55
commit b22257b610
3 changed files with 56 additions and 0 deletions

View file

@ -0,0 +1,26 @@
import shutil
import tempfile
import sys
import re
rex = "@FILENAME@"
filename = sys.argv[1]
fh = file("header.txt")
header = fh.read()
header_translated = re.sub(r'@FILENAME@', filename, header)
fh.close()
f = file(filename)
lines = f.read()
f.close()
lines = re.sub(r'(?s)/\*\+.*\+\*/','',lines)
lines = header_translated + lines
with tempfile.NamedTemporaryFile(delete=False) as tmp_sources:
tmp_sources.write(lines)
shutil.move(tmp_sources.name, filename)