summaryrefslogtreecommitdiffstats
path: root/scripts/addheader.py
blob: 09e628eb2d0474c1bd3bd13719f081d16f1916cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env python
import sys

def add_header(name, header):
    with file(name) as fin:
        lines = fin.readlines()
    with file(name, "w") as fout:
        for l in header:
            print >> fout, l,
        if lines[0].startswith("/*") and lines[0].endswith("*/\n"):
            pass
        else:
            print >> fout, lines[0],
        for l in lines[1:]:
            print >> fout, l,

def main():
    with file("header") as f:
        header = f.readlines()
    for name in sys.argv[1:]:
        add_header(name, header)

if __name__ == "__main__":
    main()