cic-schema/python/cic_schema/cert.py

45 lines
1004 B
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# standard imports
import sys
import enum
# external imports
from rdflib import Graph, RDF
from rdflib.term import URIRef
from rdflib.collection import Collection
class CIC(enum.Enum):
voucherContract = URIRef('https://defalsify.org/rdf-eth/0.1/voucherContract')
voucherTransfer = URIRef('https://defalsify.org/rdf-eth/0.1/voucherTransfer')
class Attestation:
def __init__(self):
self.g = Graph()
self.txs = {}
self.typ = None
@classmethod
def from_path(cls, path):
c = cls()
c.g.parse(path, format='turtle')
c.__apply_graph()
return c
def __apply_graph(self):
current_subject = None
for (s, p, o) in self.g:
if s != current_subject:
current_subject = s
if p == RDF.first:
pass
print('{} {} {}'.format(s, p, o))
def export(self, w=sys.stdout):
v = self.g.serialize(format='xml')
w.write(v)