Add bundler, test

This commit is contained in:
lash 2023-03-05 09:59:41 +00:00
parent 9fa00f32a7
commit 910ce54055
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
8 changed files with 69 additions and 50 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
cic.json

6
Makefile Normal file
View File

@ -0,0 +1,6 @@
all:
python bundle.py > cic.json
test: all
check-jsonschema --schemafile cic.json test_valid.json

38
bundle.py Normal file
View File

@ -0,0 +1,38 @@
# 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
print(json.dumps(o))

24
cic.in.json Normal file
View File

@ -0,0 +1,24 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "sha256:",
"title": "CIC core metadata container",
"type": "object",
"properties": {
"targets": {
"type": "array",
"items": {
"type": "string",
"pattern": "^(0x)?[a-fA-F0-9]{40}"
}
},
"attachments": {
"type": "array",
"items": {
"$ref": "/mime"
}
}
},
"required": ["targets", "attachments"]
}

View File

@ -1,50 +0,0 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "sha256:",
"title": "CIC core metadata container",
"type": "object",
"properties": {
"targets": {
"type": "array",
"items": {
"type": "string",
"pattern": "^(0x)?[a-fA-F0-9]{40}"
}
},
"attachments": {
"type": "array",
"items": {
"$ref": "/mime"
}
}
},
"required": ["targets", "attachments"],
"jsonmime": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "/mime",
"title": "A single generic attachment for documenting any asset",
"type": "object",
"properties": {
"contentType": {
"type": "string",
"$comment": "valid mime type"
},
"contentTransferEncoding": {
"type": "string",
"enum": ["BASE64", "QUOTED-PRINTABLE", "8BIT", "7BIT"]
},
"subject": {
"type": "string",
"$comment": "utf-8"
},
"body": {
"type": "string",
"$comment": "uri including dataurl"
}
},
"required": ["contentType", "body", "subject"]
}
}