from nodetypes import DiscoType
ANY = -1
class Port:
def __setattr__(self, key, value):
'''Alias for __setitem___'''
self[key] = value
def __setitem__(self, key, value):
pass
def __getattr__(self, key):
'''Alias for __getitem___'''
return self[key]
def __getitem__(self, key):
class InputPort(Port):
def __init__(self, required=1, maxpins=ANY):
def __init__(self, allowedtype, required=1, maxpins=ANY):
self.pins = []
class OutputPort(Port):
def __init__(self):
class Pin:
def __init__(self, connection, value=DiscoType):
'''
Snippet Pi=3: RFC 2: New port semantics
# an example of the max node's op
def changed(self, inputs):
# note how this function does not use stateaccess, as it doesn't use state
return max(inputs.values())
# so, how the heck does this work?
# we check the function to get the names of kw args in the function.
# we always pass self, but everything else is optional
# the node asked for inputs, which looks like this:
# inputs = {'portname' : PortObj, 'portname2', PortObj}
# somehow, the PortObjs are max'ible.
Status change: