From d245f98cbdbd7af1a5f9876d5456abf265c76e9b Mon Sep 17 00:00:00 2001 From: nolash Date: Fri, 22 Oct 2021 19:41:01 +0200 Subject: [PATCH] Add attachments to proofs calc in export cli call --- cic/attachment.py | 1 - cic/cmd/export.py | 2 +- cic/output.py | 2 +- cic/proof.py | 9 ++++++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cic/attachment.py b/cic/attachment.py index 7c76fc4..014c0fc 100644 --- a/cic/attachment.py +++ b/cic/attachment.py @@ -59,7 +59,6 @@ class Attachment(Data): def __str__(self): s = '' - #for i in range(len(self.contents)): for k in self.contents.keys(): s += '{} = {}\n'.format(k, self.contents[k]) #self.digests[i].hex(), self.contents[i]) diff --git a/cic/cmd/export.py b/cic/cmd/export.py index 21ab9c2..a873b41 100644 --- a/cic/cmd/export.py +++ b/cic/cmd/export.py @@ -80,10 +80,10 @@ def execute(config, eargs): cp = Proof(path=eargs.directory, attachments=ca, writer=writers['proof'](path=output_writer_path_meta)) cn = Network(path=eargs.directory) + ca.load() ct.load() cp.load() cm.load() - ca.load() cn.load() chain_spec = None diff --git a/cic/output.py b/cic/output.py index 253d7fd..5d514d0 100644 --- a/cic/output.py +++ b/cic/output.py @@ -54,7 +54,7 @@ class HTTPWriter(OutputWriter): logg.debug('http writer post {}'.format(path)) rq = urllib.request.Request(path, method='POST', data=v) r = urllib.request.urlopen(rq) - logg.info('proof submited at {}'.format(r.read())) + logg.info('http writer submitted at {}'.format(r.read())) class KeyedWriter(OutputWriter): diff --git a/cic/proof.py b/cic/proof.py index d01d2e9..8c74ec4 100644 --- a/cic/proof.py +++ b/cic/proof.py @@ -44,6 +44,7 @@ class Proof(Data): self.description = o['description'] self.namespace = o['namespace'] self.issuer = o['issuer'] + self.proofs = o['proofs'] if self.extra_attachments != None: a = self.extra_attachments.asdict() @@ -111,6 +112,7 @@ class Proof(Data): if writer == None: writer = self.writer + (k, v) = self.root() writer.write(k, v) @@ -138,7 +140,12 @@ class Proof(Data): #logg.debug('generated proof {} for hashes {}'.format(r_hex, hshs)) #writer.write(r_hex, hshs_cat) - + + o = self.asdict() + f = open(self.proof_path, 'w') + json.dump(o, f, sort_keys=True, indent="\t") + f.close() + return k