File: download-license-data.py

package info (click to toggle)
debian-codemods 0.171
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,312 kB
  • sloc: makefile: 888; xml: 119; python: 80; sh: 69; javascript: 3
file content (27 lines) | stat: -rwxr-xr-x 815 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/python3

import json
import sys
from urllib.request import urlopen

BASE_URL = (
    "https://raw.githubusercontent.com/spdx/license-list-data/master/json/"
)
LICENSES_URL = BASE_URL + "licenses.json"
EXCEPTIONS_URL = BASE_URL + "exceptions.json"

licenses_summary = json.loads(urlopen(LICENSES_URL).read())
licenses = {}
license_ids = []
for license in licenses_summary["licenses"]:
    license_ids.append(license["licenseId"])
    licenses[license["licenseId"]] = {
        "name": license["name"],
    }

exceptions = json.loads(urlopen(EXCEPTIONS_URL).read())
exception_ids = []
for exception in exceptions["exceptions"]:
    exception_ids.append(exception["licenseExceptionId"])
result = {"licenses": licenses, "exception_ids": exception_ids}
json.dump(result, sys.stdout, sort_keys=True, indent=4)