Black all the things

This commit is contained in:
Reid 'arrdem' McKenzie 2021-09-02 22:10:35 -06:00
commit 9ed2165072
31 changed files with 395 additions and 294 deletions

View file

@ -5,6 +5,8 @@ attrs==20.3.0
autoflake==1.4
Babel==2.9.0
beautifulsoup4==4.9.3
black==21.8b0
bleach==4.0.0
certifi==2020.12.5
chardet==4.0.0
click==7.1.2
@ -40,8 +42,10 @@ openapi-schema-validator==0.1.5
openapi-spec-validator==0.3.0
packaging==20.9
parso==0.8.2
pathspec==0.8.1
pathspec==0.9.0
pep517==0.11.0
pip-tools==6.2.0
platformdirs==2.3.0
pluggy==0.13.1
port-for==0.6.1
prompt-toolkit==3.0.18
@ -63,6 +67,7 @@ PyYAML==5.4.1
readme-renderer==29.0
recommonmark==0.7.1
redis==3.5.3
regex==2021.8.28
requests==2.25.1
requests-toolbelt==0.9.1
requirements-parser==0.2.0
@ -81,15 +86,18 @@ sphinxcontrib-programoutput==0.17
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.4
toml==0.10.2
tomli==1.2.1
tornado==6.1
typed-ast==1.4.2
typing-extensions==3.7.4.3
typing-extensions==3.10.0.2
unify==0.5
untokenize==0.1.1
urllib3==1.26.4
urwid==2.1.2
wcwidth==0.2.5
webencodings==0.5.1
Werkzeug==2.0.1
yamllint==1.26.1
yarl==1.6.3
yaspin==1.5.0
zipp==3.5.0

View file

@ -13,16 +13,16 @@ from requirements.requirement import Requirement
# Licenses approved as representing non-copyleft and not precluding commercial usage.
# This is all easy, there's a good schema here.
APPROVED_LICENSES = [
MIT := "License :: OSI Approved :: MIT License",
MIT := "License :: OSI Approved :: MIT License",
APACHE := "License :: OSI Approved :: Apache Software License",
BSD := "License :: OSI Approved :: BSD License",
MPL10 := "License :: OSI Approved :: Mozilla Public License 1.0 (MPL)",
MPL11 := "License :: OSI Approved :: Mozilla Public License 1.1 (MPL 1.1)",
MPL20 := "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
PSFL := "License :: OSI Approved :: Python Software Foundation License",
LGPL := "License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
LGPL3 := "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
ISCL := "License :: OSI Approved :: ISC License (ISCL)",
BSD := "License :: OSI Approved :: BSD License",
MPL10 := "License :: OSI Approved :: Mozilla Public License 1.0 (MPL)",
MPL11 := "License :: OSI Approved :: Mozilla Public License 1.1 (MPL 1.1)",
MPL20 := "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)",
PSFL := "License :: OSI Approved :: Python Software Foundation License",
LGPL := "License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)",
LGPL3 := "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)",
ISCL := "License :: OSI Approved :: ISC License (ISCL)",
]
UNAPPROVED_LICENSES = [
@ -36,23 +36,17 @@ LICENSES_BY_LOWERNAME = {
"apache 2.0": APACHE,
"apache": APACHE,
"http://www.apache.org/licenses/license-2.0": APACHE,
"bsd 3": BSD,
"bsd": BSD,
"gpl": GPL1,
"gpl2": GPL2,
"gpl3": GPL3,
"lgpl": LGPL,
"lgpl3": LGPL3,
"isc": ISCL,
"mit": MIT,
"mpl": MPL10,
"mpl 2.0": MPL20,
"psf": PSFL,
}
@ -75,7 +69,9 @@ with open("tools/python/requirements.txt") as fd:
def bash_license(ln):
while True:
lnn = re.sub(r"[(),]|( version)|( license)|( ?v(?=\d))|([ -]clause)", "", ln.lower())
lnn = re.sub(
r"[(),]|( version)|( license)|( ?v(?=\d))|([ -]clause)", "", ln.lower()
)
if ln != lnn:
ln = lnn
else:
@ -85,16 +81,19 @@ def bash_license(ln):
return ln
@pytest.mark.parametrize("a,b", [
("MIT", MIT),
("mit", MIT),
("BSD", BSD),
("BSD 3-clause", BSD),
("BSD 3 clause", BSD),
("GPL3", GPL3),
("GPL v3", GPL3),
("GPLv3", GPL3),
])
@pytest.mark.parametrize(
"a,b",
[
("MIT", MIT),
("mit", MIT),
("BSD", BSD),
("BSD 3-clause", BSD),
("BSD 3 clause", BSD),
("GPL3", GPL3),
("GPL v3", GPL3),
("GPLv3", GPL3),
],
)
def test_bash_license(a, b):
assert bash_license(a) == b
@ -117,7 +116,7 @@ def licenses(package: Requirement):
if not version:
blob = requests.get(
f"https://pypi.org/pypi/{package.name}/json",
headers={"Accept": "application/json"}
headers={"Accept": "application/json"},
).json()
if ln := bash_license(blob.get("license")):
lics.append(ln)
@ -131,13 +130,15 @@ def licenses(package: Requirement):
if version:
blob = requests.get(
f"https://pypi.org/pypi/{package.name}/{version}/json",
headers={"Accept": "application/json"}
headers={"Accept": "application/json"},
).json()
lics.extend([
c
for c in blob.get("info", {}).get("classifiers", [])
if c.startswith("License")
])
lics.extend(
[
c
for c in blob.get("info", {}).get("classifiers", [])
if c.startswith("License")
]
)
ln = blob.get("info", {}).get("license")
if ln and not lics:
lics.append(bash_license(ln))