Add pyproject.toml & update license check
This commit is contained in:
parent
a1e5f40297
commit
1bb3e5b199
4 changed files with 122 additions and 4 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -166,3 +166,4 @@ Network Trash Folder
|
|||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
.python-version
|
||||
|
|
84
poetry.lock
generated
Normal file
84
poetry.lock
generated
Normal file
|
@ -0,0 +1,84 @@
|
|||
[[package]]
|
||||
name = "certifi"
|
||||
version = "2021.10.8"
|
||||
description = "Python package for providing Mozilla's CA Bundle."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "charset-normalizer"
|
||||
version = "2.0.9"
|
||||
description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.5.0"
|
||||
|
||||
[package.extras]
|
||||
unicode_backport = ["unicodedata2"]
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "3.3"
|
||||
description = "Internationalized Domain Names in Applications (IDNA)"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.5"
|
||||
|
||||
[[package]]
|
||||
name = "requests"
|
||||
version = "2.26.0"
|
||||
description = "Python HTTP for Humans."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*"
|
||||
|
||||
[package.dependencies]
|
||||
certifi = ">=2017.4.17"
|
||||
charset-normalizer = {version = ">=2.0.0,<2.1.0", markers = "python_version >= \"3\""}
|
||||
idna = {version = ">=2.5,<4", markers = "python_version >= \"3\""}
|
||||
urllib3 = ">=1.21.1,<1.27"
|
||||
|
||||
[package.extras]
|
||||
socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"]
|
||||
use_chardet_on_py3 = ["chardet (>=3.0.2,<5)"]
|
||||
|
||||
[[package]]
|
||||
name = "urllib3"
|
||||
version = "1.26.7"
|
||||
description = "HTTP library with thread-safe connection pooling, file post, and more."
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4"
|
||||
|
||||
[package.extras]
|
||||
brotli = ["brotlipy (>=0.6.0)"]
|
||||
secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"]
|
||||
socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
|
||||
|
||||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = "^3.10"
|
||||
content-hash = "15913dd32401df6acd63c653d6c29acf1879651cd2c763d47f2a5736a54e0293"
|
||||
|
||||
[metadata.files]
|
||||
certifi = [
|
||||
{file = "certifi-2021.10.8-py2.py3-none-any.whl", hash = "sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569"},
|
||||
{file = "certifi-2021.10.8.tar.gz", hash = "sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872"},
|
||||
]
|
||||
charset-normalizer = [
|
||||
{file = "charset-normalizer-2.0.9.tar.gz", hash = "sha256:b0b883e8e874edfdece9c28f314e3dd5badf067342e42fb162203335ae61aa2c"},
|
||||
{file = "charset_normalizer-2.0.9-py3-none-any.whl", hash = "sha256:1eecaa09422db5be9e29d7fc65664e6c33bd06f9ced7838578ba40d58bdf3721"},
|
||||
]
|
||||
idna = [
|
||||
{file = "idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"},
|
||||
{file = "idna-3.3.tar.gz", hash = "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"},
|
||||
]
|
||||
requests = [
|
||||
{file = "requests-2.26.0-py2.py3-none-any.whl", hash = "sha256:6c1246513ecd5ecd4528a0906f910e8f0f9c6b8ec72030dc9fd154dc1a6efd24"},
|
||||
{file = "requests-2.26.0.tar.gz", hash = "sha256:b8aa58f8cf793ffd8782d3d8cb19e66ef36f7aba4353eec859e74678b01b07a7"},
|
||||
]
|
||||
urllib3 = [
|
||||
{file = "urllib3-1.26.7-py2.py3-none-any.whl", hash = "sha256:c4fdf4019605b6e5423637e01bc9fe4daef873709a7973e195ceba0a62bbc844"},
|
||||
{file = "urllib3-1.26.7.tar.gz", hash = "sha256:4987c65554f7a2dbf30c18fd48778ef124af6fab771a377103da0585e2336ece"},
|
||||
]
|
15
pyproject.toml
Normal file
15
pyproject.toml
Normal file
|
@ -0,0 +1,15 @@
|
|||
[tool.poetry]
|
||||
name = "misc"
|
||||
version = "0.1.0"
|
||||
description = ""
|
||||
authors = ["Gabriel Augendre <gabriel@augendre.info>"]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.10"
|
||||
requests = "^2.26.0"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core>=1.0.0"]
|
||||
build-backend = "poetry.core.masonry.api"
|
|
@ -17,9 +17,11 @@ def main():
|
|||
with open("UNLICENSE", "rb") as f:
|
||||
unlicense = base64.b64encode(f.read()).decode("utf-8")
|
||||
for repo in repos["data"]:
|
||||
print()
|
||||
full_name = repo["full_name"]
|
||||
url = repo["html_url"]
|
||||
license_url = f"https://git.augendre.info/api/v1/repos/{full_name}/contents/LICENSE"
|
||||
base_url = f"https://git.augendre.info/api/v1/repos/{full_name}/contents"
|
||||
license_url = f"{base_url}/LICENSE"
|
||||
res = s.get(license_url)
|
||||
if res.status_code != 200:
|
||||
print(f"No LICENSE -> Public domain : {url}")
|
||||
|
@ -30,24 +32,40 @@ def main():
|
|||
license_json = res.json()
|
||||
license = base64.b64decode(license_json["content"]).decode("utf-8")
|
||||
should_change = True
|
||||
should_add_readme_mention = True
|
||||
if "GNU" in license:
|
||||
print(f"GPL -> Public domain : {url}")
|
||||
elif "public domain" in license or "Unlicense" in license:
|
||||
print(f"Public domain : {url}")
|
||||
should_change = False
|
||||
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
|
||||
should_add_readme_mention = 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 should_add_readme_mention:
|
||||
readme_url = f"{base_url}/README.md"
|
||||
res = s.get(readme_url)
|
||||
if res.status_code != 200:
|
||||
print("No readme")
|
||||
continue
|
||||
readme_json = res.json()
|
||||
readme = base64.b64decode(readme_json["content"].encode("utf-8")).decode("utf-8")
|
||||
readme += "\n# Reuse\nIf you do reuse my work, please consider linking back to this repository 🙂"
|
||||
readme = base64.b64encode(readme.encode("utf-8")).decode("utf-8")
|
||||
current_sha = readme_json["sha"]
|
||||
res = s.put(readme_url, json={"content": readme, "sha": current_sha})
|
||||
if res.status_code != 200:
|
||||
print("issue updating readme")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in a new issue