45 lines
1004 B
Python
45 lines
1004 B
Python
# 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)
|