Add writers to core processors from export cli cmd

This commit is contained in:
nolash 2021-10-12 11:27:26 +02:00
parent 68867d09d2
commit 33c0dac678
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
4 changed files with 18 additions and 13 deletions

View File

@ -58,7 +58,8 @@ class Attachment(Data):
def __str__(self):
s = ''
for i in range(len(self.contents)):
s += '{} = {}\n'.format(self.digests[i].hex(), self.contents[i])
#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])
return s

View File

@ -52,9 +52,9 @@ def execute(config, eargs):
writers = init_writers_from_config(config)
ct = Token(path=eargs.directory)
cm = Meta(path=eargs.directory, writer=writers['meta'])
ca = Attachment(path=eargs.directory, writer=writers['attachment'])
cp = Proof(path=eargs.directory, attachments=ca, writer=writers['proof'])
cm = Meta(path=eargs.directory, writer=writers['meta'](path=eargs.output_directory))
ca = Attachment(path=eargs.directory, writer=writers['attachment'](path=eargs.output_directory))
cp = Proof(path=eargs.directory, attachments=ca, writer=writers['proof'](path=eargs.output_directory))
cn = Network(path=eargs.directory)
ct.load()
@ -77,9 +77,8 @@ def execute(config, eargs):
ref = cn.resource(eargs.target)
chain_spec = cn.chain_spec(eargs.target)
logg.debug('found reference {} chain spec {} for target {}'.format(ref['contents'], chain_spec, eargs.target))
c = getattr(cmd_mod, 'new')(chain_spec, ref['contents'], cp, signer_hint=signer, rpc=rpc)
c = getattr(cmd_mod, 'new')(chain_spec, ref['contents'], cp, signer_hint=signer, rpc=rpc, outputs_writer=writers['ext'](path=eargs.output_directory))
c.apply_token(ct)
p = Processor(proof=cp, attachment=ca, metadata=cm, extensions=[eargs.target])
c.process(writer=writers['ext'](path=eargs.output_directory))
p = Processor(proof=cp, attachment=ca, metadata=cm, extensions=[c])
p.process()

View File

@ -156,7 +156,9 @@ class CICEth(Extension):
if r == None:
r = code
self.add_outputs('token', r)
writer.write('token_address', self.token_address.encode('utf-8'))
writer.write('token', r.encode('utf-8'))
self.add_outputs('token', r.encode('utf-8'))
return r
@ -183,6 +185,7 @@ class CICEth(Extension):
else:
r = o
writer.write('token_index', r.encode('utf-8'))
self.add_outputs('token_index', r)
return r
@ -230,5 +233,5 @@ class CICEth(Extension):
self.token_address = add_0x(to_checksum_address(self.token_address))
def new(chain_spec, resources, proof, signer_hint=None, rpc=None):
return CICEth(chain_spec, resources, proof, signer=signer_hint, rpc=rpc)
def new(chain_spec, resources, proof, signer_hint=None, rpc=None, outputs_writer=None):
return CICEth(chain_spec, resources, proof, signer=signer_hint, rpc=rpc, outputs_writer=outputs_writer)

View File

@ -30,7 +30,8 @@ class Processor:
return outputs
def process(self):
def process(self, writer=None):
tasks = [
'proof',
'attachment',
@ -42,6 +43,7 @@ class Processor:
for task in tasks:
a = self.cores.get(task)
logg.debug('>>>>>>> checking task {} {}'.format(task, a))
if a == None:
logg.debug('skipping missing task receiver "{}"'.format(task))
continue