This is an automated email from the ASF dual-hosted git repository. lizhanhui pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/rocketmq-client-cpp.git
commit 6984b94343c75f5c5b6a7e945e1d45313409fbc8 Author: Li Zhanhui <[email protected]> AuthorDate: Mon Oct 18 11:36:23 2021 +0800 Add utility to fix file header copyright comment --- tools/copyright.txt | 14 ++++++++++++++ tools/fix_copyright.py | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/tools/copyright.txt b/tools/copyright.txt new file mode 100644 index 0000000..1745cfe --- /dev/null +++ b/tools/copyright.txt @@ -0,0 +1,14 @@ +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/tools/fix_copyright.py b/tools/fix_copyright.py new file mode 100755 index 0000000..263fe81 --- /dev/null +++ b/tools/fix_copyright.py @@ -0,0 +1,38 @@ +#!/usr/bin/python +import os +import fnmatch + +def checkAndFixFileHeaderComment(fileName, template): + lines = [] + with open(fileName, 'rw') as f: + lines = f.readlines() + + print(template) + for line in lines: + print(line) + + + +def main(): + template = "/*\n" + + with open('tools/copyright.txt', 'r') as reader: + line = reader.readline() + while line != '': + template += " * " + line + line = reader.readline() + template += " */" + + for root, dir, files in os.walk(os.curdir): + if ".git/" in root: + continue + + for item in fnmatch.filter(files, "*.h"): + checkAndFixFileHeaderComment(root + os.sep + item, template) + + for item in fnmatch.filter(files, "*.cpp"): + checkAndFixFileHeaderComment(root + os.sep + item, template) + + +if __name__ == "__main__": + main() \ No newline at end of file
