def __init__(self, parent=None):
self._parent = parent
- self.flag()
def test(self):
"""
def get_parent(self): return self._parent
- ##############################################
- ## Update flagging
- ##############################################
- def is_flagged(self): return self._flag
- def flag(self):
- self._flag = True
- if self.get_parent(): self.get_parent().flag()
- def deflag(self):
- self._flag = False
- if self.get_parent(): self.get_parent().deflag()
-
##############################################
## Type testing methods
##############################################
@param key the block key
@return the new block or None if not found
"""
- self.flag()
if key not in self.get_parent().get_block_keys(): return None
block = self.get_parent().get_new_block(self, key)
self.get_elements().append(block)
@throw Exception bad connection
@return the new connection
"""
- self.flag()
connection = self.get_parent().Connection(flow_graph=self, porta=porta, portb=portb)
self.get_elements().append(connection)
return connection
If the element is a block, remove its connections.
If the element is a connection, just remove the connection.
"""
- self.flag()
if element not in self.get_elements(): return
#found a port, set to parent signal block
if element.is_port():
self.set_value(value)
return value
- def set_value(self, value):
- self.flag()
- self._value = str(value) #must be a string
+ def set_value(self, value): self._value = str(value) #must be a string
def get_type(self): return self.get_parent().resolve_dependencies(self._type)
def is_enum(self): return self._type == 'enum'
def __init__(self, **kwargs):
_FlowGraph.__init__(self, **kwargs)
_GUIFlowGraph.__init__(self)
+ self._eval_cache = dict()
- _eval_cache = dict()
def _eval(self, code, namespace, namespace_hash):
"""
Evaluate the code with the given namespace.
parameters = filter(lambda b: _parameter_matcher.match(b.get_key()), self.get_enabled_blocks())
return parameters
+ def rewrite(self):
+ """
+ Flag the namespace to be renewed.
+ """
+ self._renew_eval_ns = True
+ _FlowGraph.rewrite(self)
+
def evaluate(self, expr):
"""
Evaluate the expression.
@throw Exception bad expression
@return the evaluated data
"""
- if self.is_flagged():
- self.deflag()
+ if self._renew_eval_ns:
+ self._renew_eval_ns = False
#reload namespace
n = dict()
#load imports