Add update_license script
This commit is contained in:
parent
3c06f4bc8b
commit
35f6553d15
2 changed files with 75 additions and 0 deletions
25
update_license/UNLICENSE
Normal file
25
update_license/UNLICENSE
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
This is free and unencumbered software released into the public domain.
|
||||||
|
|
||||||
|
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||||
|
distribute this software, either in source code form or as a compiled
|
||||||
|
binary, for any purpose, commercial or non-commercial, and by any
|
||||||
|
means.
|
||||||
|
|
||||||
|
In jurisdictions that recognize copyright laws, the author or authors
|
||||||
|
of this software dedicate any and all copyright interest in the
|
||||||
|
software to the public domain. We make this dedication for the benefit
|
||||||
|
of the public at large and to the detriment of our heirs and
|
||||||
|
successors. We intend this dedication to be an overt act of
|
||||||
|
relinquishment in perpetuity of all present and future rights to this
|
||||||
|
software under copyright law.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
For more information, please refer to <https://unlicense.org>
|
||||||
|
|
50
update_license/main.py
Normal file
50
update_license/main.py
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
import base64, requests
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
s = requests.Session()
|
||||||
|
s.headers = {
|
||||||
|
"Authorization": "token ***REMOVED***",
|
||||||
|
"Accept": "application/json",
|
||||||
|
}
|
||||||
|
res = s.get("https://git.augendre.info/api/v1/repos/search?limit=100")
|
||||||
|
res.raise_for_status()
|
||||||
|
repos = res.json()
|
||||||
|
with open("UNLICENSE", "rb") as f:
|
||||||
|
unlicense = base64.b64encode(f.read()).decode("utf-8")
|
||||||
|
for repo in repos["data"]:
|
||||||
|
full_name = repo["full_name"]
|
||||||
|
url = repo["html_url"]
|
||||||
|
license_url = f"https://git.augendre.info/api/v1/repos/{full_name}/contents/LICENSE"
|
||||||
|
res = s.get(license_url)
|
||||||
|
if res.status_code != 200:
|
||||||
|
print(f"No LICENSE -> Public domain : {url}")
|
||||||
|
res = s.post(license_url, json={"content": unlicense})
|
||||||
|
if res.status_code != 201:
|
||||||
|
print("issue creating license")
|
||||||
|
continue
|
||||||
|
license_json = res.json()
|
||||||
|
license = base64.b64decode(license_json["content"]).decode("utf-8")
|
||||||
|
should_change = True
|
||||||
|
if "GNU" in license:
|
||||||
|
print(f"GPL -> Public domain : {url}")
|
||||||
|
elif "MIT" in license:
|
||||||
|
print(f"MIT -> Public domain : {url}")
|
||||||
|
elif "DO WHAT THE FUCK YOU WANT TO" in license:
|
||||||
|
print(f"WTFPL -> Public domain : {url}")
|
||||||
|
elif "public domain" in license:
|
||||||
|
print(f"Public domain : {url}")
|
||||||
|
should_change = False
|
||||||
|
else:
|
||||||
|
print(f"UNKNOWN : {url}")
|
||||||
|
should_change = False
|
||||||
|
|
||||||
|
if should_change:
|
||||||
|
current_sha = license_json["sha"]
|
||||||
|
res = s.put(license_url, json={"content": unlicense, "sha": current_sha})
|
||||||
|
if res.status_code != 200:
|
||||||
|
print("issue updating license")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Reference in a new issue