--- a/py_ext/py_ext.py Sun May 12 23:32:30 2013 +0200
+++ b/py_ext/py_ext.py Mon May 13 14:31:23 2013 +0200
@@ -38,9 +38,35 @@
# define a unique name for the generated C file
location_str = "_".join(map(lambda x:str(x), current_location))
+ sections_code = self.GetSectionsCode()
+
+ text = "## Code generated by Beremiz python mixin confnode\n\n"
+
+ # Adding variables
+ text += "## User variables reference\n"
+ text += sections_code["variables"]
+ text += "\n"
+
+ # Adding user global variables and routines
+ text += "## User internal user variables and routines\n"
+ text += sections_code["globals"]
+ text += "\n"
+
+ # Adding Beremiz python runtime functions
+ text += "## Beremiz python runtime functions\n"
+ for section in self.SECTIONS_NAMES:
+ if section != "globals":
+ code_object = getattr(self.CodeFile, section)
+ text += "def _runtime_%s_%s():\n" % (location_str, section)
+ section_code = sections_code.get(section)
+ if section_code:
+ text += section_code
+ else:
+ text += " pass\n\n"
+
runtimefile_path = os.path.join(buildpath, "runtime_%s.py"%location_str)
runtimefile = open(runtimefile_path, 'w')
- runtimefile.write(self.GetPythonCode())
+ runtimefile.write(text)
runtimefile.close()
return [], "", False, ("runtime_%s.py"%location_str, file(runtimefile_path,"rb"))