09e628eb2d0474c1bd3bd13719f081d16f1916cb
[platform/upstream/ibus-libpinyin.git] / scripts / addheader.py
1 #!/usr/bin/env python
2 import sys
3
4 def add_header(name, header):
5     with file(name) as fin:
6         lines = fin.readlines()
7     with file(name, "w") as fout:
8         for l in header:
9             print >> fout, l,
10         if lines[0].startswith("/*") and lines[0].endswith("*/\n"):
11             pass
12         else:
13             print >> fout, lines[0],
14         for l in lines[1:]:
15             print >> fout, l,
16
17 def main():
18     with file("header") as f:
19         header = f.readlines()
20     for name in sys.argv[1:]:
21         add_header(name, header)
22
23 if __name__ == "__main__":
24     main()