-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinclude.py
More file actions
28 lines (22 loc) · 773 Bytes
/
include.py
File metadata and controls
28 lines (22 loc) · 773 Bytes
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
28
import sys
from parse import compile
if __name__ == '__main__':
result = ''
n = 0
with open(sys.argv[1], 'r') as f:
p = compile("#include <{}>")
for line in f.readlines():
include = p.parse(line.strip())
if not include:
result += line
else:
include = include[0]
if include.endswith('.hpp') or include.endswith('.cpp'):
result += '#include <wpp/{}>\n'.format(include)
n += 1
else:
result += line
print('Successfully amended {} includes in {}, writing output...'.format(n, sys.argv[1]), end='')
with open(sys.argv[1], 'w') as f:
f.write(result)
print(' done.')