2021-10-11 15:28:09 +02:00
|
|
|
# standard imports
|
|
|
|
import logging
|
|
|
|
|
|
|
|
logg = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2021-10-11 12:23:08 +02:00
|
|
|
class Processor:
|
|
|
|
|
2021-10-11 19:13:21 +02:00
|
|
|
def __init__(self, proof=None, attachment=None, metadata=None, outputs_writer=None, extensions=[]):
|
2021-10-11 12:23:08 +02:00
|
|
|
self.token_address = None
|
2021-10-11 15:28:09 +02:00
|
|
|
self.extensions = extensions
|
2021-10-11 17:39:01 +02:00
|
|
|
self.cores = {
|
|
|
|
'metadata': metadata,
|
|
|
|
'attachment': attachment,
|
2021-10-11 19:13:21 +02:00
|
|
|
'proof': proof,
|
2021-10-11 17:39:01 +02:00
|
|
|
}
|
2021-10-11 15:28:09 +02:00
|
|
|
self.outputs = []
|
2021-10-11 12:23:08 +02:00
|
|
|
self.__outputs_writer = outputs_writer
|
|
|
|
|
|
|
|
|
|
|
|
def writer(self):
|
|
|
|
return self.__outputs_writer
|
|
|
|
|
|
|
|
|
2021-10-11 15:28:09 +02:00
|
|
|
def get_outputs(self):
|
|
|
|
outputs = []
|
|
|
|
for ext in self.extensions:
|
|
|
|
outputs += ext.outputs
|
|
|
|
outputs += self.outputs
|
|
|
|
return outputs
|
2021-10-11 12:23:08 +02:00
|
|
|
|
|
|
|
|
2021-10-12 11:27:26 +02:00
|
|
|
def process(self, writer=None):
|
|
|
|
|
2021-10-11 12:23:08 +02:00
|
|
|
tasks = [
|
2021-10-11 17:39:01 +02:00
|
|
|
'attachment',
|
2021-10-12 14:26:57 +02:00
|
|
|
'proof',
|
2021-10-11 19:13:21 +02:00
|
|
|
'metadata',
|
2021-10-11 12:23:08 +02:00
|
|
|
]
|
|
|
|
|
2021-10-11 15:28:09 +02:00
|
|
|
for ext in self.extensions:
|
|
|
|
token_address = ext.process()
|
2021-10-11 12:23:08 +02:00
|
|
|
|
2021-10-11 15:28:09 +02:00
|
|
|
for task in tasks:
|
2021-10-11 17:39:01 +02:00
|
|
|
a = self.cores.get(task)
|
2021-10-12 11:27:26 +02:00
|
|
|
logg.debug('>>>>>>> checking task {} {}'.format(task, a))
|
2021-10-11 15:28:09 +02:00
|
|
|
if a == None:
|
|
|
|
logg.debug('skipping missing task receiver "{}"'.format(task))
|
|
|
|
continue
|
|
|
|
v = a.process(token_address=token_address, writer=self.__outputs_writer)
|
|
|
|
self.outputs.append(v)
|
2021-10-11 19:13:21 +02:00
|
|
|
|