Move documentation to texinfo, add makefiles, rename Cert to Attestation (python)
This commit is contained in:
@@ -1 +1 @@
|
||||
from .cert import Cert
|
||||
from .cert import Attestation
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,7 @@ class CIC(enum.Enum):
|
||||
voucherTransfer = URIRef('https://defalsify.org/rdf-eth/0.1/voucherTransfer')
|
||||
|
||||
|
||||
class Cert:
|
||||
class Attestation:
|
||||
|
||||
def __init__(self):
|
||||
self.g = Graph()
|
||||
|
||||
2
python/cic_schema/error.py
Normal file
2
python/cic_schema/error.py
Normal file
@@ -0,0 +1,2 @@
|
||||
class InvalidCertificationError(Exception):
|
||||
pass
|
||||
64
python/cic_schema/nft.py
Normal file
64
python/cic_schema/nft.py
Normal file
@@ -0,0 +1,64 @@
|
||||
# standard imports
|
||||
import os
|
||||
import json
|
||||
from urllib.request import urlopen
|
||||
#import binascii.error
|
||||
|
||||
# external imports
|
||||
from jsonschema import validate as json_validate
|
||||
|
||||
# local imports
|
||||
from .error import InvalidCertificationError
|
||||
|
||||
|
||||
script_dir = os.path.realpath(os.path.dirname(__file__))
|
||||
data_dir = os.path.join(script_dir, 'data')
|
||||
__f = open(os.path.join(data_dir, 'cic.json'), 'r')
|
||||
schema = __f.read()
|
||||
__f.close()
|
||||
|
||||
|
||||
class NFT:
|
||||
|
||||
def __init__(self):
|
||||
self.name = None
|
||||
self.description = None
|
||||
self.image = None
|
||||
self.attachments = []
|
||||
self.attributes = {}
|
||||
self.certifications = []
|
||||
|
||||
|
||||
@classmethod
|
||||
def from_path(cls, path):
|
||||
f = open(path, 'r')
|
||||
o = json.load(f)
|
||||
f.close()
|
||||
json_validate(schema, o)
|
||||
c = cls()
|
||||
c.name = o['name']
|
||||
c.description = o['description']
|
||||
c.image = o['image']
|
||||
c.attributes = o['attributes']
|
||||
c.attachments = o['attachments']
|
||||
c.certifications = o['certifications']
|
||||
|
||||
|
||||
def __decode_certification(self):
|
||||
for v in self.certiciations:
|
||||
try:
|
||||
r = self.__try_data_uri(v)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def __try_data_uri(self, data):
|
||||
r = None
|
||||
try:
|
||||
r = urllib.request.urlopen(data)
|
||||
#except binascii.error:
|
||||
# raise InvalidCertificationError()
|
||||
except Exception:
|
||||
raise InvalidCertificationError()
|
||||
#return None
|
||||
return r
|
||||
Reference in New Issue
Block a user