mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 23:31:12 +00:00
Added some tools to manipulate source code in bulk
This commit is contained in:
parent
e9194f5c55
commit
b22257b610
3 changed files with 56 additions and 0 deletions
26
build_tools/apply_license.py
Normal file
26
build_tools/apply_license.py
Normal 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)
|
Loading…
Add table
Add a link
Reference in a new issue