None

Dependents:   nRF51822

Fork of nrf51-sdk by Lancaster University

Committer:
Asimov
Date:
Fri Jan 13 20:59:21 2017 +0000
Revision:
9:118fd63123a5
Parent:
0:bc2961fa1ef0
None

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