cic-schema/bundle.py

58 lines
1.2 KiB
Python
Raw Normal View History

2023-03-05 10:59:41 +01:00
# standard imports
import json
import os
fp = os.path.join('.', 'cic.in.json')
f = open(fp, 'r')
o = json.load(f)
fp = os.path.join('.', 'mime.in.json')
f = open(fp, 'r')
o_mime = json.load(f)
o['mime'] = o_mime
fp = os.path.join('.', 'opensea_part.in.json')
f = open(fp, 'r')
o_opensea = json.load(f)
for k in o_opensea['properties'].keys():
p = {}
for v in o_opensea['properties'][k]:
p[v] = o_opensea['properties'][k][v]
o['properties'][k] = p
o['required'] += o_opensea['required']
o['oneOf'] = o_opensea['oneOf']
fp = os.path.join('.', 'nft.in.json')
f = open(fp, 'r')
o_nft = json.load(f)
for k in o_nft['properties'].keys():
p = {}
for v in o_nft['properties'][k]:
p[v] = o_nft['properties'][k][v]
o['properties'][k] = p
2023-03-05 12:18:41 +01:00
os.makedirs('out', exist_ok=True)
fp = os.path.join('out', 'cic.json')
f = open(fp, 'w')
json.dump(o, f)
f.close()
fp = os.path.join('.', 'voucher.in.json')
f = open(fp, 'r')
o_voucher = json.load(f)
for k in o_voucher['properties'].keys():
p = {}
for v in o_voucher['properties'][k]:
p[v] = o_voucher['properties'][k][v]
o['properties'][k] = p
fp = os.path.join('out', 'voucher.json')
f = open(fp, 'w')
json.dump(o, f)
f.close()