summaryrefslogtreecommitdiff
path: root/grc/base
diff options
context:
space:
mode:
authorSebastian Koslowski <koslowski@kit.edu>2015-08-19 14:37:55 +0200
committerSebastian Koslowski <koslowski@kit.edu>2015-09-02 11:48:33 +0200
commit791c1a705d9e1457d9c09c79c7f1300c2ac63f5e (patch)
tree90fd62889640cde760c16e9945b81a483af4e83f /grc/base
parentc3ed72b9d9fffb234ed266c243a6b3c3b49d42d2 (diff)
grc: sort blocks in export_data(), draw disabled blocks first (fixes #830)
Diffstat (limited to 'grc/base')
-rw-r--r--grc/base/FlowGraph.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/grc/base/FlowGraph.py b/grc/base/FlowGraph.py
index 61e60f9968..217c4d7302 100644
--- a/grc/base/FlowGraph.py
+++ b/grc/base/FlowGraph.py
@@ -131,17 +131,8 @@ class FlowGraph(Element):
def iter_blocks(self):
return ifilter(methodcaller('is_block'), self.get_elements())
- def get_blocks_unordered(self):
- return list(self.iter_blocks())
-
def get_blocks(self):
- # refactored the slow, ugly version
- # don't know why we need this here, using it for sorted export_data()
- return sorted(self.iter_blocks(), key=lambda b: (
- b.get_key() != 'options', # options to the front
- not b.get_key().startswith('variable'), # then vars
- str(b)
- ))
+ return list(self.iter_blocks())
def iter_connections(self):
return ifilter(methodcaller('is_connection'), self.get_elements())
@@ -273,10 +264,17 @@ class FlowGraph(Element):
Returns:
a nested data odict
"""
+ # sort blocks and connections for nicer diffs
+ blocks = sorted(self.iter_blocks(), key=lambda b: (
+ b.get_key() != 'options', # options to the front
+ not b.get_key().startswith('variable'), # then vars
+ str(b)
+ ))
+ connections = sorted(self.get_connections(), key=str)
n = odict()
n['timestamp'] = self._timestamp
- 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)]
+ n['block'] = [b.export_data() for b in blocks]
+ n['connection'] = [c.export_data() for c in connections]
instructions = odict({
'created': self.get_parent().get_version_short(),
'format': FLOW_GRAPH_FILE_FORMAT_VERSION,