[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 01/07: grc: keep block/connection/param ord
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 01/07: grc: keep block/connection/param order when saving flow-graphs |
Date: |
Wed, 29 Apr 2015 22:55:10 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit e5d9a239e42ade2f578be77bca3f24832bdc24de
Author: Sebastian Koslowski <address@hidden>
Date: Tue Apr 28 15:42:45 2015 +0200
grc: keep block/connection/param order when saving flow-graphs
---
grc/base/Block.py | 2 +-
grc/base/FlowGraph.py | 18 +++++++++---------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/grc/base/Block.py b/grc/base/Block.py
index cadff12..4b49287 100644
--- a/grc/base/Block.py
+++ b/grc/base/Block.py
@@ -413,7 +413,7 @@ class Block(Element):
"""
n = odict()
n['key'] = self.get_key()
- n['param'] = map(lambda p: p.export_data(), self.get_params())
+ n['param'] = map(lambda p: p.export_data(), sorted(self.get_params(),
key=str))
if 'bus' in map(lambda a: a.get_type(), self.get_sinks()):
n['bus_sink'] = str(1);
if 'bus' in map(lambda a: a.get_type(), self.get_sources()):
diff --git a/grc/base/FlowGraph.py b/grc/base/FlowGraph.py
index fb25b46..790aed0 100644
--- a/grc/base/FlowGraph.py
+++ b/grc/base/FlowGraph.py
@@ -126,13 +126,13 @@ class FlowGraph(Element):
def get_block(self, id): return filter(lambda b: b.get_id() == id,
self.get_blocks())[0]
def get_blocks_unordered(self): return filter(lambda e: e.is_block(),
self.get_elements())
def get_blocks(self):
- blocks = self.get_blocks_unordered();
- for i in range(len(blocks)):
- if blocks[i].get_key() == 'variable':
- blk = blocks[i];
- blocks.remove(blk);
- blocks.insert(1, blk);
- return blocks;
+ # refactored the slow, ugly version
+ # don't know why we need this here, using it for sorted export_data()
+ return sorted(self.get_blocks_unordered(), key=lambda b: (
+ b.get_key() != 'options', # options to the front
+ not b.get_key().startswith('variable'), # then vars
+ str(b)
+ ))
def get_connections(self): return filter(lambda e: e.is_connection(),
self.get_elements())
def get_children(self): return self.get_elements()
def get_elements(self):
@@ -250,8 +250,8 @@ class FlowGraph(Element):
"""
n = odict()
n['timestamp'] = self._timestamp
- n['block'] = [block.export_data() for block in self.get_blocks()]
- n['connection'] = [connection.export_data() for connection in
self.get_connections()]
+ n['block'] = [b.export_data() for b in self.get_blocks()] # already
sorted
+ n['connection'] = [c.export_data() for c in
sorted(self.get_connections(), key=str)]
instructions = odict({
'created': self.get_parent().get_version_short(),
'format': FLOW_GRAPH_FILE_FORMAT_VERSION,
- [Commit-gnuradio] [gnuradio] branch master updated (465d4e0 -> efd2116), git, 2015/04/29
- [Commit-gnuradio] [gnuradio] 04/07: Merge remote-tracking branch 'michaelld/swig_sizeof_t_fixes', git, 2015/04/29
- [Commit-gnuradio] [gnuradio] 06/07: Merge remote-tracking branch 'tom/blocks/peak_detector2_docs', git, 2015/04/29
- [Commit-gnuradio] [gnuradio] 01/07: grc: keep block/connection/param order when saving flow-graphs,
git <=
- [Commit-gnuradio] [gnuradio] 05/07: Merge remote-tracking branch 'skoslowski/master_grcwg', git, 2015/04/29
- [Commit-gnuradio] [gnuradio] 07/07: Merge branch 'maint', git, 2015/04/29
- [Commit-gnuradio] [gnuradio] 02/07: cmake & swig: more generic way to replace std::vector<size_t> by its correct-sized std::vector<TYPE>, but only with SWIG < 3.0; this issue seems to have been fixed with SWIG >= 3.0., git, 2015/04/29
- [Commit-gnuradio] [gnuradio] 03/07: blocks: improved documentation for peak_detector2., git, 2015/04/29