chore: license-checker improvements (#212)
This commit is contained in:
@@ -271,12 +271,23 @@ class LicenseChecker:
|
|||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
parser = argparse.ArgumentParser(description="Check package licenses in TOML files")
|
parser = argparse.ArgumentParser(description="Check package licenses in TOML files")
|
||||||
parser.add_argument("toml_files", type=Path, nargs="+", help="Paths to TOML files")
|
parser.add_argument("toml_files", type=Path, nargs="*", help="Paths to TOML files")
|
||||||
args = parser.parse_args()
|
parser.add_argument("--supported-licenses", action="store_true", help="Print supported licenses")
|
||||||
|
|
||||||
checker = LicenseChecker()
|
checker = LicenseChecker()
|
||||||
all_results: dict[str, LicenseInfo] = {}
|
all_results: dict[str, LicenseInfo] = {}
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
if args.supported_licenses:
|
||||||
|
for license in sorted(checker.config.allowed_licenses, key=str.casefold):
|
||||||
|
print(f" - {license}")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
if not args.toml_files:
|
||||||
|
print("Error: No TOML files specified", file=sys.stderr)
|
||||||
|
parser.print_help()
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
for toml_file in args.toml_files:
|
for toml_file in args.toml_files:
|
||||||
results = checker.check_licenses(toml_file)
|
results = checker.check_licenses(toml_file)
|
||||||
for package, info in results.items():
|
for package, info in results.items():
|
||||||
|
|||||||
@@ -11,8 +11,28 @@ integration *FLAGS:
|
|||||||
@uv run pytest tests/ -m integration {{ FLAGS }}
|
@uv run pytest tests/ -m integration {{ FLAGS }}
|
||||||
|
|
||||||
# check licenses
|
# check licenses
|
||||||
check-licenses:
|
check-licenses force="":
|
||||||
@uv run .github/workflows/scripts/check_licenses.py pyproject.toml packages/exchange/pyproject.toml
|
#!/usr/bin/env bash
|
||||||
|
mapfile -t license_files < <(find . -type f -name 'pyproject.toml')
|
||||||
|
total=${#license_files[@]}
|
||||||
|
|
||||||
|
for ((i=0; i<total; i++)); do
|
||||||
|
license="${license_files[i]}"
|
||||||
|
remaining=$((total - i - 1))
|
||||||
|
|
||||||
|
if ! git diff --quiet "$license" || [ "{{ force }}" == "--force" ]; then
|
||||||
|
echo "checking licenses for: $license"
|
||||||
|
uv run .github/workflows/scripts/check_licenses.py "$license"
|
||||||
|
|
||||||
|
if [ $remaining -gt 0 ]; then
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# list supported licenses
|
||||||
|
list-licenses:
|
||||||
|
@uv run .github/workflows/scripts/check_licenses.py --supported-licenses
|
||||||
|
|
||||||
# format code
|
# format code
|
||||||
format:
|
format:
|
||||||
|
|||||||
Reference in New Issue
Block a user