Commit 0e9c08b4 authored by Olof Svensson's avatar Olof Svensson

Issue #6: Replaced default mutable argument for 'listPort' with None

Reformatted long lines.
parent 85b9e32c
......@@ -31,17 +31,23 @@ logger = logging.getLogger('pypushflow')
class RouterActor(AbstractActor):
def __init__(self, parent, errorHandler=None, name='Router', itemName=None, listPort=[]):
def __init__(self, parent, errorHandler=None, name='Router',
itemName=None, listPort=None):
AbstractActor.__init__(self, parent, name)
self.errorHandler = errorHandler
self.name = name
self.itemName = itemName
self.listPort = listPort
if listPort is None:
self.listPort = []
else:
self.listPort = listPort
self.dictValues = {}
def connect(self, actor, expectedValue='other'):
if expectedValue != 'other' and not expectedValue in self.listPort:
raise RuntimeError('Port {0} not defined for router actor {1}!'.format(expectedValue, self.name))
raise RuntimeError(
'Port {0} not defined for router actor {1}!'.format(
expectedValue, self.name))
if expectedValue in self.dictValues:
self.dictValues[expectedValue].append(actor)
else:
......@@ -53,9 +59,13 @@ class RouterActor(AbstractActor):
self.setFinished()
listActor = None
if self.itemName in inData:
logger.debug('In router actor "{0}", itemName {1} in inData'.format(self.name, self.itemName))
logger.debug(
'In router actor "{0}", itemName {1} in inData'.format(
self.name, self.itemName))
value = inData[self.itemName]
logger.debug('In router actor "{0}", value = {1}'.format(self.name, value))
logger.debug(
'In router actor "{0}", value = {1}'.format(
self.name, value))
if value in [None, 'None', 'null']:
value = 'null'
elif type(value) == bool:
......@@ -70,7 +80,10 @@ class RouterActor(AbstractActor):
if 'other' in self.dictValues:
listActor = self.dictValues['other']
else:
raise RuntimeError('No "other" port for router actor "{0}"'.format(self.name))
raise RuntimeError(
'No "other" port for router actor "{0}"'.format(self.name))
for actor in listActor:
logger.debug('In router actor "{0}", triggering actor "{1}"'.format(self.name, actor.name))
logger.debug(
'In router actor "{0}", triggering actor "{1}"'.format(
self.name, actor.name))
actor.trigger(inData)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment