From f7d418c37e693c1693596bfa6e9ccbcea7c0b544 Mon Sep 17 00:00:00 2001 From: Anthony Barbier Date: Wed, 19 Dec 2018 11:51:09 +0000 Subject: COMPMID-1857: Updated script to add copyright headers Change-Id: Id52f92249d55ad0212fa77e37a47a95192e477ac Reviewed-on: https://review.mlplatform.org/422 Reviewed-by: Isabella Gottardi Tested-by: Arm Jenkins --- scripts/add_copyright.py | 50 +++++++++++++++++++++++++++-------------------- scripts/copyright_mit.txt | 2 +- 2 files changed, 30 insertions(+), 22 deletions(-) (limited to 'scripts') diff --git a/scripts/add_copyright.py b/scripts/add_copyright.py index ad1dab6f40..9585fa3d3e 100755 --- a/scripts/add_copyright.py +++ b/scripts/add_copyright.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import glob import os.path +import sys mit_copyright = open("scripts/copyright_mit.txt",'r').read() @@ -56,27 +57,34 @@ def remove_comment_python( content ): out += line + "\n" return out -for top in ['./arm_compute', './tests','./src','./examples','./utils/','./framework','./support']: - for root, _, files in os.walk(top): - for f in files: - path = os.path.join(root, f) +def check_file( path ): + root, f = os.path.split(path) + if f in ['.clang-tidy', '.clang-format']: + print("Skipping file: {}".format(path)) + return - if f in ['.clang-tidy', '.clang-format']: - print("Skipping file: {}".format(path)) - continue + with open(path, 'r', encoding='utf-8') as fd: + content = fd.read() + _, extension = os.path.splitext(f) - with open(path, 'r', encoding='utf-8') as fd: - content = fd.read() - _, extension = os.path.splitext(f) + if extension in ['.cpp', '.h', '.hpp', '.inl', '.cl', '.in', '.cs']: + if not content.startswith('/*'): + add_cpp_copyright(path, content) + elif extension == '.py' or f in ['SConstruct', 'SConscript']: + if not content.startswith('# Copyright'): + add_python_copyright(path, content) + elif f == 'CMakeLists.txt': + if not content.startswith('# Copyright'): + add_python_copyright(path, content) + else: + raise Exception("Unhandled file: {}".format(path)) - if extension in ['.cpp', '.h', '.hpp', '.inl', '.cl']: - if not content.startswith('/*'): - add_cpp_copyright(path, content) - elif extension == '.py' or f in ['SConstruct', 'SConscript']: - if not content.startswith('# Copyright'): - add_python_copyright(path, content) - elif f == 'CMakeLists.txt': - if not content.startswith('# Copyright'): - add_python_copyright(path, content) - else: - raise Exception("Unhandled file: {}".format(path)) +if len(sys.argv) > 1: + for path in sys.argv[1:]: + check_file(path) +else: + for top in ['./arm_compute', './tests','./src','./examples','./utils/','./opencl-1.2-stubs/','./opengles-3.1-stubs/','./support']: + for root, _, files in os.walk(top): + for f in files: + path = os.path.join(root, f) + check_file(path) diff --git a/scripts/copyright_mit.txt b/scripts/copyright_mit.txt index 18e83ec163..a43ef66bda 100644 --- a/scripts/copyright_mit.txt +++ b/scripts/copyright_mit.txt @@ -1,4 +1,4 @@ -Copyright (c) 2017 ARM Limited. +Copyright (c) 2018 ARM Limited. SPDX-License-Identifier: MIT -- cgit v1.2.1