| 1 |
# Call with path to SPDX license-list-data repo, cloned from: |
| 2 |
# https://github.com/spdx/license-list-data |
| 3 |
|
| 4 |
import json |
| 5 |
import pprint |
| 6 |
import sys |
| 7 |
from pathlib import Path |
| 8 |
|
| 9 |
list_data_repo = Path(sys.argv[1]) |
| 10 |
with (list_data_repo / 'json' / 'licenses.json').open('rb') as f: |
| 11 |
licenses_json = json.load(f) |
| 12 |
with (list_data_repo / 'json' / 'exceptions.json').open('rb') as f: |
| 13 |
exceptions_json = json.load(f) |
| 14 |
|
| 15 |
licenses = { |
| 16 |
l['licenseId'].lower(): {'id': l['licenseId']} |
| 17 |
for l in licenses_json['licenses'] |
| 18 |
if not l['isDeprecatedLicenseId'] |
| 19 |
} |
| 20 |
exceptions = { |
| 21 |
e['licenseExceptionId'].lower(): {'id': e['licenseExceptionId']} |
| 22 |
for e in exceptions_json['exceptions'] |
| 23 |
if not e['isDeprecatedLicenseId'] |
| 24 |
} |
| 25 |
|
| 26 |
with Path('flit_core', 'flit_core', '_spdx_data.py').open('w') as f: |
| 27 |
f.write("# This file is generated from SPDX license data; don't edit it manually.\n\n") |
| 28 |
|
| 29 |
for name, data in (("licenses", licenses), ("exceptions", exceptions)): |
| 30 |
f.write(f"{name} = \\\n") |
| 31 |
pprint.pprint(data, f) |