summaryrefslogtreecommitdiff
path: root/grc/gui/FlowGraph.py
diff options
context:
space:
mode:
authorSebastian Koslowski <koslowski@kit.edu>2016-06-19 20:39:22 -0700
committerSebastian Koslowski <koslowski@kit.edu>2016-07-13 16:35:49 +0200
commit020878e8468d848cebe1bfe5b0dc7c9b557214f7 (patch)
tree3d576c9bc0320fa15367a889758c7cf54c282592 /grc/gui/FlowGraph.py
parent4f29b9ae0b518bcc41038d6d300429e5d656d8e0 (diff)
grc: refactor: block states are no longer hidden params
Diffstat (limited to 'grc/gui/FlowGraph.py')
-rw-r--r--grc/gui/FlowGraph.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py
index 87bd91d880..d592242e2e 100644
--- a/grc/gui/FlowGraph.py
+++ b/grc/gui/FlowGraph.py
@@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
from __future__ import absolute_import
import functools
+import ast
import random
from distutils.spawn import find_executable
from itertools import count
@@ -219,12 +220,17 @@ class FlowGraph(Element, _Flowgraph):
continue # unknown block was pasted (e.g. dummy block)
selected.add(block)
#set params
- params = {n['key']: n['value'] for n in block_n.get('param', [])}
+ param_data = {n['key']: n['value'] for n in block_n.get('param', [])}
+ for key in block.states:
+ try:
+ block.states[key] = ast.literal_eval(param_data.pop(key))
+ except (KeyError, SyntaxError, ValueError):
+ pass
if block_key == 'epy_block':
- block.get_param('_io_cache').set_value(params.pop('_io_cache'))
- block.get_param('_source_code').set_value(params.pop('_source_code'))
+ block.get_param('_io_cache').set_value(param_data.pop('_io_cache'))
+ block.get_param('_source_code').set_value(param_data.pop('_source_code'))
block.rewrite() # this creates the other params
- for param_key, param_value in six.iteritems(params):
+ for param_key, param_value in six.iteritems(param_data):
#setup id parameter
if param_key == 'id':
old_id2block[param_value] = block