diff options
author | Johnathan Corgan <johnathan@corganlabs.com> | 2015-11-28 12:52:03 -0800 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2015-11-28 12:52:03 -0800 |
commit | ee06ad1eb9437d1db989076ca61ed0e4573244ec (patch) | |
tree | ebe51c26bf69183feefbd7cf919827be9274581d /grc/python/FlowGraph.py | |
parent | 27e8311d8b6bf88c8b46461abe6de8d222e2ee25 (diff) | |
parent | dcc09deb064453f4add1ece3502ee99f12f3cb25 (diff) |
Merge remote-tracking branch 'gnuradio-wg-grc/master_grcwg'
Diffstat (limited to 'grc/python/FlowGraph.py')
-rw-r--r-- | grc/python/FlowGraph.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/grc/python/FlowGraph.py b/grc/python/FlowGraph.py index 49530af8a3..9b55cb6d43 100644 --- a/grc/python/FlowGraph.py +++ b/grc/python/FlowGraph.py @@ -30,9 +30,11 @@ _bussrc_searcher = re.compile('^(bus_source)$') _bus_struct_sink_searcher = re.compile('^(bus_structure_sink)$') _bus_struct_src_searcher = re.compile('^(bus_structure_source)$') + class FlowGraph(_FlowGraph, _GUIFlowGraph): def __init__(self, **kwargs): + self.grc_file_path = '' _FlowGraph.__init__(self, **kwargs) _GUIFlowGraph.__init__(self) self._eval_cache = dict() @@ -232,7 +234,6 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph): return bussrc - def rewrite(self): """ Flag the namespace to be renewed. @@ -299,3 +300,21 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph): #evaluate e = self._eval(expr, self.n, self.n_hash) return e + + def get_new_block(self, key): + """Try to auto-generate the block from file if missing""" + block = _FlowGraph.get_new_block(self, key) + if not block: + platform = self.get_parent() + # we're before the initial fg rewrite(), so no evaluated values! + # --> use raw value instead + path_param = self._options_block.get_param('hier_block_src_path') + file_path = platform.find_file_in_paths( + filename=key + '.' + platform.get_key(), + paths=path_param.get_value(), + cwd=self.grc_file_path + ) + if file_path: # grc file found. load and get block + platform.load_and_generate_flow_graph(file_path) + block = _FlowGraph.get_new_block(self, key) # can be None + return block |