py_ext/PythonFileCTNMixin.py
changeset 1118 2c96a2f36295
parent 1113 16e5b6abd91c
child 1120 35d772ec1a76
equal deleted inserted replaced
1117:1aef6a7db08d 1118:2c96a2f36295
    46         
    46         
    47         text = "## Code generated by Beremiz python mixin confnode\n\n"
    47         text = "## Code generated by Beremiz python mixin confnode\n\n"
    48         
    48         
    49         # Adding includes
    49         # Adding includes
    50         text += "## User includes\n"
    50         text += "## User includes\n"
    51         text += self.CodeFile.includes.gettext()
    51         text += self.CodeFile.includes.gettext().strip()
    52         text += "\n"
    52         text += "\n"
    53         
    53         
    54         # Adding variables
    54         # Adding variables
    55         text += "## User variables reference\n"
    55         text += "## User variables reference\n"
    56         config = self.GetCTRoot().GetProjectConfigNames()[0]
    56         config = self.GetCTRoot().GetProjectConfigNames()[0]
    63                 str(variable.getinitial()))
    63                 str(variable.getinitial()))
    64         text += "\n"
    64         text += "\n"
    65         
    65         
    66         # Adding user global variables and routines
    66         # Adding user global variables and routines
    67         text += "## User internal user variables and routines\n"
    67         text += "## User internal user variables and routines\n"
    68         text += self.CodeFile.globals.gettext()
    68         text += self.CodeFile.globals.gettext().strip()
    69         text += "\n"
    69         text += "\n"
    70         
    70         
    71         # Adding Beremiz confnode functions
    71         # Adding Beremiz confnode functions
    72         text += "## Beremiz confnode functions\n"
    72         text += "## Beremiz confnode functions\n"
    73         for func, args, return_code, code_object in [
    73         for func, args, return_code, code_object in [
    76             ("__cleanup_", "", "", self.CodeFile.cleanUpFunction),
    76             ("__cleanup_", "", "", self.CodeFile.cleanUpFunction),
    77             ("__retrieve_", "", "", self.CodeFile.retrieveFunction),
    77             ("__retrieve_", "", "", self.CodeFile.retrieveFunction),
    78             ("__publish_", "", "", self.CodeFile.publishFunction),]:
    78             ("__publish_", "", "", self.CodeFile.publishFunction),]:
    79             text += "def %s%s(%s):\n" % (func, location_str, args)
    79             text += "def %s%s(%s):\n" % (func, location_str, args)
    80             lines = code_object.gettext().strip().splitlines()
    80             lines = code_object.gettext().strip().splitlines()
       
    81             print lines
    81             if len(lines) > 0 or return_code != "":
    82             if len(lines) > 0 or return_code != "":
    82                 for line in lines:
    83                 for line in lines:
    83                     text += "    " + line + "\n"
    84                     text += "    " + line + "\n"
    84                 text += "    " + return_code + "\n\n"
    85                 if return_code != "":
       
    86                     text += "    " + return_code + "\n"
       
    87                 text += "\n"
    85             else:
    88             else:
    86                 text += "    pass\n\n"
    89                 text += "    pass\n\n"
    87         
    90         
    88         return text
    91         return text
    89 
    92