Microbit as a BLE gamepad
Fork of nrf51-sdk by
script/replace_headers.py@9:d3bc499d113d, 2017-01-30 (annotated)
- Committer:
- rengro01
- Date:
- Mon Jan 30 08:23:53 2017 +0000
- Revision:
- 9:d3bc499d113d
- Parent:
- 0:bc2961fa1ef0
Microbit as a BLE gamepad
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jonathan Austin |
0:bc2961fa1ef0 | 1 | import os |
Jonathan Austin |
0:bc2961fa1ef0 | 2 | |
Jonathan Austin |
0:bc2961fa1ef0 | 3 | with open("copyright_header.txt", "r") as fd: |
Jonathan Austin |
0:bc2961fa1ef0 | 4 | header = fd.read() |
Jonathan Austin |
0:bc2961fa1ef0 | 5 | |
Jonathan Austin |
0:bc2961fa1ef0 | 6 | path = "../source/nordic_sdk" |
Jonathan Austin |
0:bc2961fa1ef0 | 7 | for root, dirs, files in os.walk(path): |
Jonathan Austin |
0:bc2961fa1ef0 | 8 | for fn in [os.path.join(root, x) for x in files]: |
Jonathan Austin |
0:bc2961fa1ef0 | 9 | with open(fn, "r+") as fd: |
Jonathan Austin |
0:bc2961fa1ef0 | 10 | print "+"*35 |
Jonathan Austin |
0:bc2961fa1ef0 | 11 | print fn |
Jonathan Austin |
0:bc2961fa1ef0 | 12 | s = fd.read() |
Jonathan Austin |
0:bc2961fa1ef0 | 13 | start = s.find("/*") |
Jonathan Austin |
0:bc2961fa1ef0 | 14 | end = s.find("*/") |
Jonathan Austin |
0:bc2961fa1ef0 | 15 | copyright_str = s[start:end+2] |
Jonathan Austin |
0:bc2961fa1ef0 | 16 | if "copyright (c)" not in copyright_str.lower(): |
Jonathan Austin |
0:bc2961fa1ef0 | 17 | s = header + "\n\n" + s |
Jonathan Austin |
0:bc2961fa1ef0 | 18 | elif copyright_str is not header: |
Jonathan Austin |
0:bc2961fa1ef0 | 19 | s = s.replace(copyright_str, header) |
Jonathan Austin |
0:bc2961fa1ef0 | 20 | |
Jonathan Austin |
0:bc2961fa1ef0 | 21 | fd.seek(0) |
Jonathan Austin |
0:bc2961fa1ef0 | 22 | fd.write(s) |
Jonathan Austin |
0:bc2961fa1ef0 | 23 | fd.truncate() |