From 9f8ed5bb5decdcc6905e4a8cbd22ac31bca619a7 Mon Sep 17 00:00:00 2001
From: Sylvain Munaut <tnt@246tNt.com>
Date: Fri, 8 Jan 2021 16:28:47 +0100
Subject: grc: Move snippets prep earlier in the file

They are going to be needed in the closeEvent() Qt stuff
and this is earlier in the file ...

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
---
 grc/core/generator/flow_graph.py.mako | 52 +++++++++++++++++++----------------
 1 file changed, 28 insertions(+), 24 deletions(-)

(limited to 'grc')

diff --git a/grc/core/generator/flow_graph.py.mako b/grc/core/generator/flow_graph.py.mako
index 81d71bd569..e79bfa6f29 100644
--- a/grc/core/generator/flow_graph.py.mako
+++ b/grc/core/generator/flow_graph.py.mako
@@ -43,6 +43,34 @@ if __name__ == '__main__':
 ${imp}
 % endfor
 
+########################################################
+##Prepare snippets
+########################################################
+% for snip in flow_graph.get_snippets_dict():
+
+${indent(snip['def'])}
+% for line in snip['lines']:
+    ${indent(line)}
+% endfor
+% endfor
+\
+<%
+snippet_sections = ['main_after_init', 'main_after_start', 'main_after_stop']
+snippets = {}
+for section in snippet_sections:
+    snippets[section] = flow_graph.get_snippets_dict(section)
+%>
+\
+%for section in snippet_sections:
+%if snippets[section]:
+
+def snippets_${section}(tb):
+    % for snip in snippets[section]:
+    ${indent(snip['call'])}
+    % endfor
+%endif
+%endfor
+
 ########################################################
 ##Create Class
 ##  Write the class declaration for a top or hier block.
@@ -269,30 +297,6 @@ gr.io_signature.makev(${len(io_sigs)}, ${len(io_sigs)}, [${', '.join(size_strs)}
         % endif
     % endfor
 \
-% for snip in flow_graph.get_snippets_dict():
-
-${indent(snip['def'])}
-% for line in snip['lines']:
-    ${indent(line)}
-% endfor
-% endfor
-\
-<%
-snippet_sections = ['main_after_init', 'main_after_start', 'main_after_stop']
-snippets = {}
-for section in snippet_sections:
-    snippets[section] = flow_graph.get_snippets_dict(section)
-%>
-\
-%for section in snippet_sections:
-%if snippets[section]:
-
-def snippets_${section}(tb):
-    % for snip in snippets[section]:
-    ${indent(snip['call'])}
-    % endfor
-%endif
-%endfor
 
 ########################################################
 ##Create Main
-- 
cgit v1.2.3