py_ext/PythonFileCTNMixin.py
changeset 2693 7ab2b5a18e65
parent 2692 d4bede6cd3f1
child 2694 3225990eb33e
equal deleted inserted replaced
2692:d4bede6cd3f1 2693:7ab2b5a18e65
    32 import util.paths as paths
    32 import util.paths as paths
    33 from xmlclass import GenerateParserFromXSD
    33 from xmlclass import GenerateParserFromXSD
    34 
    34 
    35 from CodeFileTreeNode import CodeFile
    35 from CodeFileTreeNode import CodeFile
    36 from py_ext.PythonEditor import PythonEditor
    36 from py_ext.PythonEditor import PythonEditor
       
    37 
       
    38 
    37 
    39 
    38 
    40 
    39 class PythonFileCTNMixin(CodeFile):
    41 class PythonFileCTNMixin(CodeFile):
    40 
    42 
    41     CODEFILE_NAME = "PyFile"
    43     CODEFILE_NAME = "PyFile"
   103                for variable in variables]
   105                for variable in variables]
   104         location_str = "_".join(map(str, self.GetCurrentLocation()))
   106         location_str = "_".join(map(str, self.GetCurrentLocation()))
   105         ret.append(("On_"+location_str+"_Change", "python_poll", ""))
   107         ret.append(("On_"+location_str+"_Change", "python_poll", ""))
   106         return ret
   108         return ret
   107 
   109 
       
   110     @staticmethod
       
   111     def GetVarOnChangeContent(var):
       
   112         """
       
   113         returns given variable onchange field
       
   114         function is meant to allow customization 
       
   115         """
       
   116         return var.getonchange()
       
   117 
   108     def CTNGenerate_C(self, buildpath, locations):
   118     def CTNGenerate_C(self, buildpath, locations):
   109         # location string for that CTN
   119         # location string for that CTN
   110         location_str = "_".join(map(str, self.GetCurrentLocation()))
   120         location_str = "_".join(map(str, self.GetCurrentLocation()))
   111         configname = self.GetCTRoot().GetProjectConfigNames()[0]
   121         configname = self.GetCTRoot().GetProjectConfigNames()[0]
   112 
   122 
   113         def _onchangecode(var):
   123         def _onchangecode(var):
   114             return [onchangecall.strip() + "('" + var.getname() + "')"
   124             return [onchangecall.strip() + "('" + var.getname() + "')"
   115                     for onchangecall in var.getonchange().split(',')]
   125                     for onchangecall in self.GetVarOnChangeContent(var).split(',')]
   116 
   126 
   117         def _onchange(var):
   127         def _onchange(var):
   118             return repr(var.getonchange()) \
   128             content = self.GetVarOnChangeContent(var)
   119                 if var.getonchange() else None
   129             return repr(content) if content else None
   120 
   130 
   121         pyextname = self.CTNName()
   131         pyextname = self.CTNName()
   122         varinfos = map(
   132         varinfos = map(
   123             lambda variable: {
   133             lambda variable: {
   124                 "name": variable.getname(),
   134                 "name": variable.getname(),