Fixed generated code in py_ext runtime file
authorLaurent Bessard
Fri, 10 May 2013 13:07:26 +0200
changeset 1118 2c96a2f36295
parent 1117 1aef6a7db08d
child 1119 34db4294c177
Fixed generated code in py_ext runtime file
py_ext/PythonFileCTNMixin.py
--- a/py_ext/PythonFileCTNMixin.py	Fri May 10 13:06:47 2013 +0200
+++ b/py_ext/PythonFileCTNMixin.py	Fri May 10 13:07:26 2013 +0200
@@ -48,7 +48,7 @@
         
         # Adding includes
         text += "## User includes\n"
-        text += self.CodeFile.includes.gettext()
+        text += self.CodeFile.includes.gettext().strip()
         text += "\n"
         
         # Adding variables
@@ -65,7 +65,7 @@
         
         # Adding user global variables and routines
         text += "## User internal user variables and routines\n"
-        text += self.CodeFile.globals.gettext()
+        text += self.CodeFile.globals.gettext().strip()
         text += "\n"
         
         # Adding Beremiz confnode functions
@@ -78,10 +78,13 @@
             ("__publish_", "", "", self.CodeFile.publishFunction),]:
             text += "def %s%s(%s):\n" % (func, location_str, args)
             lines = code_object.gettext().strip().splitlines()
+            print lines
             if len(lines) > 0 or return_code != "":
                 for line in lines:
                     text += "    " + line + "\n"
-                text += "    " + return_code + "\n\n"
+                if return_code != "":
+                    text += "    " + return_code + "\n"
+                text += "\n"
             else:
                 text += "    pass\n\n"