Newer
Older
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""
Fix autogenerated py files to contain header information.
Writes to the file in-place
"""
import sys
import os
def lines_to_pre_append():
lines = list()
# PYLINT ingnore flags
lines.append("#pylint: skip-file\n")
return lines
def main(argv):
"""
Main entry point
Args:
argv (list): List of strings giving command line arguments The full absolulte path to the file to wrap is mandatory.
"""
argv.reverse()
to_wrap = argv[0]
if not os.path.exists(to_wrap):
raise ValueError("%s : Does not exist." % to_wrap)
with open(to_wrap, "r+") as f:
existing = f.read();
f.seek(0);
# Add initial lines
for line in lines_to_pre_append():
f.write(line)
f.write(existing)
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv))