ID: 2efc39360b566f5362d8d7e9089cf07e9bf60ef1
40 lines
—
988B —
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: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}")
|