42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
#!/usr/bin/python
|
|
# -*- coding: utf-8 -*-
|
|
# \file Output.py
|
|
# \brief TODO
|
|
# \author Florent Guiotte <florent.guiotte@gmail.com>
|
|
# \version 0.1
|
|
# \date 03 avril 2018
|
|
#
|
|
# TODO details
|
|
|
|
#from . import Node, Input
|
|
from .Node import Node
|
|
from .Input import Input
|
|
|
|
class Output(Node):
|
|
def __init__(self, name='__CHILD__'):
|
|
super().__init__('O:{}'.format(name))
|
|
self.__dict__['input'] = None
|
|
|
|
def __setattr__(self, name, value):
|
|
if name == 'input':
|
|
self._input(value)
|
|
else:
|
|
self.__dict__[name] = value
|
|
|
|
def _input(self, inode):
|
|
if not isinstance(inode, (Input)) and inode is not None:
|
|
raise NotImplementedError('{} is not an Input'.format(inode))
|
|
|
|
if self.__dict__['input'] is not None:
|
|
self.__dict__['input'].unregister(self)
|
|
|
|
self.__dict__['input'] = inode
|
|
|
|
if inode is not None:
|
|
inode.register(self)
|
|
|
|
def _run(self):
|
|
if self.input is None:
|
|
raise RuntimeError('{} do not have an input'.format(self))
|
|
return self.input.run()
|