diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..5bd0858 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,21 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Copyright", + "type": "shell", + "windows": { + "command": "python", + }, + "linux": { + "command": "python3", + }, + "osx": { + "command": "python3", + }, + "args": [ + "./Scripts/Copyright.py" + ], + } + ] +} diff --git a/Scripts/Copyright.py b/Scripts/Copyright.py new file mode 100644 index 0000000..7bf3fd0 --- /dev/null +++ b/Scripts/Copyright.py @@ -0,0 +1,35 @@ +# Copyright (c) TribuFu. All Rights Reserved + +import os + +old_copyright_notice = "// Copyright (c) TribuFu. All Rights Reserved\n\n" +new_copyright_notice = "// Copyright (c) TribuFu. All Rights Reserved\n\n" + +def GetFiles(root): + source_files = [] + + for path, dirs, files in os.walk(os.path.normpath(root)): + for name in files: + if name.endswith(".kt"): + source_files.append(os.path.join(path, name)) + + return source_files + +for file in GetFiles("lib"): + reader = open(file, "r") + + file_content = reader.read() + + reader.close() + + new_content = file_content.replace( + old_copyright_notice, new_copyright_notice) + + writer = open(file, "w", newline="") + + if old_copyright_notice in file_content or new_copyright_notice in file_content: + writer.write(new_content) + else: + writer.write(new_copyright_notice + file_content) + + writer.close()