Core seems ok

This commit is contained in:
Florent Guiotte 2018-04-04 11:16:35 +02:00
parent 5909db187f
commit 8f393c8806
5 changed files with 17 additions and 6 deletions

View File

@ -11,6 +11,7 @@
from Input import Input
from Output import Output
class Filter(Input, Output):
class Filter(Output, Input):
"""Output should be first"""
def __init__(self):
super().__init__('Filter')

View File

@ -18,5 +18,5 @@ class Input(Node):
def register(self, output):
self.outputs.append(output)
def run(self):
print('IMA INPUT N I RUNIN')
def _run(self):
print('I RUN ADSAOADIQJOWDOASJDOQIJWDOIJQOWIDJO')

View File

@ -17,7 +17,7 @@ class Node:
return ("Node:{}".format(self.name))
def _run(self):
raise NotImplementedError('This method is virtual')
raise NotImplementedError('{} should override _run()'.format(self))
def run(self):
return self._run()

View File

@ -34,4 +34,9 @@ class Output(Node):
def _process(self, data):
raise NotImplementedError('{} should override _process()'.format(self))
def _run(self):
if self.input is None:
raise RuntimeError('{} do not have an input'.format(self))
return self.input.run()

View File

@ -11,17 +11,22 @@
from Node import Node
from Filter import Filter
from Input import Input
from Output import Output
def main():
i = Input()
o = Output()
n = Filter()
f = Filter()
print(n)
n.run()
#n.run()
print(n.input)
f.input = i
n.input = f
o.input = n
o.run()
print(n.input)
print(f.outputs)
f.process(None)
if __name__ == '__main__':
main()