Add check license script

This commit is contained in:
Gabriel Augendre 2021-02-08 14:32:33 +01:00
parent 0c37ba3f65
commit 868d89ea95
3 changed files with 44 additions and 1 deletions

26
check_license.py Normal file
View file

@ -0,0 +1,26 @@
import requests, pprint, os
from tqdm import tqdm
GITEA_TOKEN = os.getenv("GITEA_TOKEN")
BASE_URL = "https://git.augendre.info/api/v1"
def main():
session = requests.Session()
session.headers.update({"Authorization": f"token {GITEA_TOKEN}"})
res = session.get(f"{BASE_URL}/user/repos", params={"limit": 40})
repos = res.json()
missing_license = []
for repo in tqdm(repos):
full_name = repo["full_name"]
url = f"{BASE_URL}/repos/{full_name}/raw/LICENSE"
res = session.get(url)
if res.status_code != 200:
missing_license.append(repo["html_url"])
print("missing license:")
pprint.pprint(missing_license)
if __name__ == "__main__":
main()

18
poetry.lock generated
View file

@ -40,6 +40,18 @@ urllib3 = ">=1.21.1,<1.27"
security = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)"]
socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"]
[[package]]
name = "tqdm"
version = "4.56.0"
description = "Fast, Extensible Progress Meter"
category = "main"
optional = false
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,>=2.7"
[package.extras]
dev = ["py-make (>=0.1.0)", "twine", "wheel"]
telegram = ["requests"]
[[package]]
name = "urllib3"
version = "1.26.3"
@ -56,7 +68,7 @@ socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
[metadata]
lock-version = "1.1"
python-versions = "^3.8"
content-hash = "c7b0119ca233bd369221338d4e3bd93bfe7ed46cd9c788ddccc23908d1a25c28"
content-hash = "9ee9d362aa98ff0e15c8275a6d8d51aee09ee2509eae82467833be9026c1cee4"
[metadata.files]
certifi = [
@ -75,6 +87,10 @@ requests = [
{file = "requests-2.25.1-py2.py3-none-any.whl", hash = "sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e"},
{file = "requests-2.25.1.tar.gz", hash = "sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804"},
]
tqdm = [
{file = "tqdm-4.56.0-py2.py3-none-any.whl", hash = "sha256:4621f6823bab46a9cc33d48105753ccbea671b68bab2c50a9f0be23d4065cb5a"},
{file = "tqdm-4.56.0.tar.gz", hash = "sha256:fe3d08dd00a526850568d542ff9de9bbc2a09a791da3c334f3213d8d0bbbca65"},
]
urllib3 = [
{file = "urllib3-1.26.3-py2.py3-none-any.whl", hash = "sha256:1b465e494e3e0d8939b50680403e3aedaa2bc434b7d5af64dfd3c958d7f5ae80"},
{file = "urllib3-1.26.3.tar.gz", hash = "sha256:de3eedaad74a2683334e282005cd8d7f22f4d55fa690a2a1020a416cb0a47e73"},

View file

@ -7,6 +7,7 @@ authors = ["Gabriel Augendre <gabriel@augendre.info>"]
[tool.poetry.dependencies]
python = "^3.8"
requests = "^2.25.1"
tqdm = "^4.56.0"
[tool.poetry.dev-dependencies]