Fix Audit license script comments (#121374)

This commit is contained in:
Joost Lekkerkerker 2024-07-06 15:24:45 +02:00 committed by GitHub
parent 3c14aa12ab
commit cf34b46b5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,6 +4,7 @@ from __future__ import annotations
from dataclasses import dataclass from dataclasses import dataclass
import json import json
from pathlib import Path
import sys import sys
from awesomeversion import AwesomeVersion from awesomeversion import AwesomeVersion
@ -218,7 +219,7 @@ TODO = {
def main() -> int: def main() -> int:
"""Run the main script.""" """Run the main script."""
raw_licenses = json.load(open("licenses.json")) raw_licenses = json.loads(Path("licenses.json").read_text())
package_definitions = [PackageDefinition.from_dict(data) for data in raw_licenses] package_definitions = [PackageDefinition.from_dict(data) for data in raw_licenses]
exit_code = 0 exit_code = 0
for package in package_definitions: for package in package_definitions:
@ -232,25 +233,29 @@ def main() -> int:
if previous_unapproved_version < package.version: if previous_unapproved_version < package.version:
if approved: if approved:
print( print(
f"Approved license detected for {package.name}@{package.version}: {package.license}" "Approved license detected for"
f"{package.name}@{package.version}: {package.license}"
) )
print("Please remove the package from the TODO list.") print("Please remove the package from the TODO list.")
print("") print("")
else: else:
print( print(
f"We could not detect an OSI-approved license for {package.name}@{package.version}: {package.license}" "We could not detect an OSI-approved license for "
f"{package.name}@{package.version}: {package.license}"
) )
print("") print("")
exit_code = 1 exit_code = 1
elif not approved and package.name not in EXCEPTIONS: elif not approved and package.name not in EXCEPTIONS:
print( print(
f"We could not detect an OSI-approved license for {package.name}@{package.version}: {package.license}" "We could not detect an OSI-approved license for"
f"{package.name}@{package.version}: {package.license}"
) )
print("") print("")
exit_code = 1 exit_code = 1
elif approved and package.name in EXCEPTIONS: elif approved and package.name in EXCEPTIONS:
print( print(
f"Approved license detected for {package.name}@{package.version}: {package.license}" "Approved license detected for"
f"{package.name}@{package.version}: {package.license}"
) )
print(f"Please remove the package from the EXCEPTIONS list: {package.name}") print(f"Please remove the package from the EXCEPTIONS list: {package.name}")
print("") print("")
@ -259,7 +264,8 @@ def main() -> int:
for package in [*TODO.keys(), *EXCEPTIONS]: for package in [*TODO.keys(), *EXCEPTIONS]:
if package not in current_packages: if package not in current_packages:
print( print(
f"Package {package} is tracked, but not used. Please remove from the licenses.py file." f"Package {package} is tracked, but not used. Please remove from the licenses.py"
"file."
) )
print("") print("")
exit_code = 1 exit_code = 1