ID: fa5db334b3118cd5a43972110bb4a62ec048b7ec
41 lines
—
1K —
View raw
| #!/usr/bin/env python3
import json
import os
# Load the list of licenses
with open('license-list-data/json/licenses.json', 'r') as file:
licenses = json.load(file)
for license in licenses['licenses']:
# Load the license json file
details_file = f"license-list-data/json/details/{license['licenseId']}.json"
assert os.path.isfile(details_file)
assert '/' not in license['licenseId']
with open(details_file, 'r') as file:
details = json.load(file)
node_id = f"dokk:license:{license['licenseId']}"
# Our graph node
node = {
'@context': {
'@base': 'dokk:',
'license': 'dokk:vocab:license:'
},
'@id': node_id,
'@type': 'license:License',
'license:id': license['licenseId'],
'license:name': license['name'],
'license:text': details['licenseText']
}
# Save node to file
with open(f"nodes/{node_id}.jsonld", 'w') as file:
json.dump(node, file, indent=4)
print(f"[done] {node_id}")
|