nrf51-sdk

Fork of nrf51-sdk by Lancaster University

Committer:
jancumps
Date:
Tue Nov 06 20:57:21 2018 +0000
Revision:
9:43576f23865a
Parent:
0:bc2961fa1ef0
i did not change a thing

Who changed what in which revision?

UserRevisionLine numberNew 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()