sotn-decomp/tools/lint-license.py
Luciano Ciccariello 487007194c
Add AGPL license (#1565)
From the [public
announcement](https://discord.com/channels/1079389589950705684/1079395108501331990/1276310695964835910)
on Discord:

> We've been progressing very far with the project and I started
wondering what would be the best course of action to protect the work of
existing and future contributors. I personally consider contributions to
a decompilation project as creative work. Therefore it is my desire to
protect this creative work from being re-claimed by other people. This
is especially true in the light of the ability of modding the existing
decompiled code and create derivative work.
> 
> I talked privately with the current most active contributors. And me,
@sozud , @bismurphy and @joshlory so far agreed on pushing through the
AGPLv3 license for all the decompiled code in `sotn-decomp/src`,
excluding any third party code and decompiled code from the PSX SDK. But
I've been wanting to ask all of you if you are fine your code to be
licensed and protected under the AGPLv3 terms.
>
>
https://raw.githubusercontent.com/Xeeynamo/sotn-decomp/89686514916cabd0dd88ae0387f749a889c19e05/src/LICENSE
> 
> I put and all the contributors, which can be accessed to the page
https://github.com/Xeeynamo/sotn-decomp/graphs/contributors . Again,
this will work for existing and future contributors. In the license I
put my full name as I will be responsible of any legality. And I
understand not every contributor wants to disclose their identity.
Please give an approval to my latest PR if you do not have any
objection. If not, please write here publicly.
>
> PS. I understand past contributors will either not see the message
above or decide to ignore it. If I do not hear from anyone of the
contributors for more than one week between those who did not interact
with me or the server, I will still go ahead and apply the license. It
is not in my intention to ignore past contributors. But I do not want
contributors who have been inactive for months or years to be a blocker.
Please do not mistake this as an act of malevolence.

---------

Co-authored-by: Joey Murphy <tjmurphy@mit.edu>
2024-09-06 16:14:55 -04:00

30 lines
924 B
Python

import sys
def add_spdx_license(file_path, license): # AGPL-3.0-or-later
spdx_line = f"// SPDX-License-Identifier: {license}"
try:
with open(file_path, "r") as file:
lines = file.readlines()
if lines and lines[0].strip() == spdx_line:
return
with open(file_path, "w") as file:
file.write(spdx_line + "\n")
file.writelines(lines)
except FileNotFoundError:
print(f"the file {file_path} does not exist")
except Exception as e:
print(f"an error occurred: {e}")
if __name__ == "__main__":
if len(sys.argv) != 3:
print("usage: python lint-license.py <file_name> <license>")
sys.exit(1)
file_names = [sys.argv[1]]
if file_names[0] == "-":
file_names = sys.stdin.readlines()
license = sys.argv[2]
for file_name in file_names:
add_spdx_license(file_name.strip(), license)