[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 03/08: grc: make recursive flow graph load
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 03/08: grc: make recursive flow graph load and generate more flexible |
Date: |
Wed, 28 Sep 2016 11:42:40 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch next
in repository gnuradio.
commit 17a57c886ac5d6a3c013c94d5909f418e67b704e
Author: Sebastian Koslowski <address@hidden>
Date: Fri Sep 16 09:52:09 2016 -0600
grc: make recursive flow graph load and generate more flexible
---
grc/core/FlowGraph.py | 2 +-
grc/core/Platform.py | 23 ++++++++++++-----------
2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/grc/core/FlowGraph.py b/grc/core/FlowGraph.py
index 2c3c787..ecae11c 100644
--- a/grc/core/FlowGraph.py
+++ b/grc/core/FlowGraph.py
@@ -420,7 +420,7 @@ class FlowGraph(Element):
cwd=self.grc_file_path
)
if file_path: # grc file found. load and get block
- self.platform.load_and_generate_flow_graph(file_path)
+ self.platform.load_and_generate_flow_graph(file_path,
hier_only=True)
block = self.new_block(key) # can be None
if not block: # looks like this block key cannot be found
diff --git a/grc/core/Platform.py b/grc/core/Platform.py
index 0dc6eb0..b73dade 100644
--- a/grc/core/Platform.py
+++ b/grc/core/Platform.py
@@ -93,42 +93,43 @@ class Platform(Element):
if os.path.exists(os.path.normpath(file_path)):
return file_path
- def load_and_generate_flow_graph(self, file_path):
+ def load_and_generate_flow_graph(self, file_path, out_path=None,
hier_only=False):
"""Loads a flow graph from file and generates it"""
Messages.set_indent(len(self._auto_hier_block_generate_chain))
- Messages.send('>>> Loading: %r\n' % file_path)
+ Messages.send('>>> Loading: {}\n'.format(file_path))
if file_path in self._auto_hier_block_generate_chain:
Messages.send(' >>> Warning: cyclic hier_block dependency\n')
- return False
+ return None, None
self._auto_hier_block_generate_chain.add(file_path)
try:
flow_graph = self.get_new_flow_graph()
flow_graph.grc_file_path = file_path
- # Other, nested higiter_blocks might be auto-loaded here
+ # Other, nested hier_blocks might be auto-loaded here
flow_graph.import_data(self.parse_flow_graph(file_path))
flow_graph.rewrite()
flow_graph.validate()
if not flow_graph.is_valid():
raise Exception('Flowgraph invalid')
- if not flow_graph.get_option('generate_options').startswith('hb'):
+ if hier_only and not
flow_graph.get_option('generate_options').startswith('hb'):
raise Exception('Not a hier block')
except Exception as e:
Messages.send('>>> Load Error: {}: {}\n'.format(file_path, str(e)))
- return False
+ return None, None
finally:
self._auto_hier_block_generate_chain.discard(file_path)
Messages.set_indent(len(self._auto_hier_block_generate_chain))
try:
- Messages.send('>>> Generating: {}\n'.format(file_path))
- generator = self.Generator(flow_graph, file_path)
+ generator = self.Generator(flow_graph, out_path or file_path)
+ Messages.send('>>> Generating: {}\n'.format(generator.file_path))
generator.write()
except Exception as e:
Messages.send('>>> Generate Error: {}: {}\n'.format(file_path,
str(e)))
- return False
+ return None, None
- self.load_block_xml(generator.get_file_path_xml())
- return True
+ if flow_graph.get_option('generate_options').startswith('hb'):
+ self.load_block_xml(generator.get_file_path_xml())
+ return flow_graph, generator.file_path
def build_block_library(self):
"""load the blocks and block tree from the search paths"""
- [Commit-gnuradio] [gnuradio] branch next updated (bd7890f -> 0878c5c), git, 2016/09/28
- [Commit-gnuradio] [gnuradio] 02/08: grc: move run command getter to core, git, 2016/09/28
- [Commit-gnuradio] [gnuradio] 07/08: Merge branch 'master' into next, git, 2016/09/28
- [Commit-gnuradio] [gnuradio] 04/08: grc: rewrite grcc, git, 2016/09/28
- [Commit-gnuradio] [gnuradio] 03/08: grc: make recursive flow graph load and generate more flexible,
git <=
- [Commit-gnuradio] [gnuradio] 08/08: Merge remote-tracking branch 'skoslowski/grcc_refactor' into next, git, 2016/09/28
- [Commit-gnuradio] [gnuradio] 05/08: grc: add some test code for grcc, git, 2016/09/28
- [Commit-gnuradio] [gnuradio] 06/08: grc: changes to grcc CLI, git, 2016/09/28
- [Commit-gnuradio] [gnuradio] 01/08: grc: move grcc into grc subtree, git, 2016/09/28