sa
Fork of nRF51822 by
TARGET_MCU_NRF51822/sdk/script/replace_headers.py@639:fdeb2820ef26, 2016-12-29 (annotated)
- Committer:
- nakamae
- Date:
- Thu Dec 29 07:05:48 2016 +0000
- Revision:
- 639:fdeb2820ef26
- Parent:
- 638:c90ae1400bf2
new;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Vincent Coubard |
638:c90ae1400bf2 | 1 | # Copyright (c) 2015-2016 ARM Limited |
Vincent Coubard |
638:c90ae1400bf2 | 2 | # SPDX-License-Identifier: Apache-2.0 |
Vincent Coubard |
638:c90ae1400bf2 | 3 | # |
Vincent Coubard |
638:c90ae1400bf2 | 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
Vincent Coubard |
638:c90ae1400bf2 | 5 | # you may not use this file except in compliance with the License. |
Vincent Coubard |
638:c90ae1400bf2 | 6 | # You may obtain a copy of the License at |
Vincent Coubard |
638:c90ae1400bf2 | 7 | # |
Vincent Coubard |
638:c90ae1400bf2 | 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
Vincent Coubard |
638:c90ae1400bf2 | 9 | # |
Vincent Coubard |
638:c90ae1400bf2 | 10 | # Unless required by applicable law or agreed to in writing, software |
Vincent Coubard |
638:c90ae1400bf2 | 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
Vincent Coubard |
638:c90ae1400bf2 | 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Vincent Coubard |
638:c90ae1400bf2 | 13 | # See the License for the specific language governing permissions and |
Vincent Coubard |
638:c90ae1400bf2 | 14 | # limitations under the License. |
Vincent Coubard |
638:c90ae1400bf2 | 15 | |
Vincent Coubard |
638:c90ae1400bf2 | 16 | import os |
Vincent Coubard |
638:c90ae1400bf2 | 17 | |
Vincent Coubard |
638:c90ae1400bf2 | 18 | with open("copyright_header.txt", "r") as fd: |
Vincent Coubard |
638:c90ae1400bf2 | 19 | header = fd.read() |
Vincent Coubard |
638:c90ae1400bf2 | 20 | |
Vincent Coubard |
638:c90ae1400bf2 | 21 | path = "../source/nordic_sdk" |
Vincent Coubard |
638:c90ae1400bf2 | 22 | for root, dirs, files in os.walk(path): |
Vincent Coubard |
638:c90ae1400bf2 | 23 | for fn in [os.path.join(root, x) for x in files]: |
Vincent Coubard |
638:c90ae1400bf2 | 24 | with open(fn, "r+") as fd: |
Vincent Coubard |
638:c90ae1400bf2 | 25 | print "+"*35 |
Vincent Coubard |
638:c90ae1400bf2 | 26 | print fn |
Vincent Coubard |
638:c90ae1400bf2 | 27 | s = fd.read() |
Vincent Coubard |
638:c90ae1400bf2 | 28 | start = s.find("/*") |
Vincent Coubard |
638:c90ae1400bf2 | 29 | end = s.find("*/") |
Vincent Coubard |
638:c90ae1400bf2 | 30 | copyright_str = s[start:end+2] |
Vincent Coubard |
638:c90ae1400bf2 | 31 | if "copyright (c)" not in copyright_str.lower(): |
Vincent Coubard |
638:c90ae1400bf2 | 32 | s = header + "\n\n" + s |
Vincent Coubard |
638:c90ae1400bf2 | 33 | elif copyright_str is not header: |
Vincent Coubard |
638:c90ae1400bf2 | 34 | s = s.replace(copyright_str, header) |
Vincent Coubard |
638:c90ae1400bf2 | 35 | |
Vincent Coubard |
638:c90ae1400bf2 | 36 | fd.seek(0) |
Vincent Coubard |
638:c90ae1400bf2 | 37 | fd.write(s) |
Vincent Coubard |
638:c90ae1400bf2 | 38 | fd.truncate() |