py_ext: better handling of coma separated OnChange attribute for python safe global variables.
authorEdouard Tisserant
Wed, 18 Nov 2020 10:15:44 +0100
changeset 2694 3225990eb33e
parent 2693 7ab2b5a18e65
child 2695 a4704fb40b0b
py_ext: better handling of coma separated OnChange attribute for python safe global variables.
py_ext/PythonFileCTNMixin.py
--- a/py_ext/PythonFileCTNMixin.py	Mon Nov 02 10:56:09 2020 +0100
+++ b/py_ext/PythonFileCTNMixin.py	Wed Nov 18 10:15:44 2020 +0100
@@ -121,8 +121,13 @@
         configname = self.GetCTRoot().GetProjectConfigNames()[0]
 
         def _onchangecode(var):
-            return [onchangecall.strip() + "('" + var.getname() + "')"
-                    for onchangecall in self.GetVarOnChangeContent(var).split(',')]
+            result = []
+            for onchangecall in self.GetVarOnChangeContent(var).split(','):
+                onchangecall = onchangecall.strip()
+                if onchangecall:
+                    result.append(onchangecall + "('" + var.getname() + "')")
+            return result
+
 
         def _onchange(var):
             content = self.GetVarOnChangeContent(var)
@@ -169,8 +174,7 @@
         on_change_func_body = "\n".join(["""
     if changes.next():
         # %(name)s
-        try:
-""" % varinfo + """ 
+        try:""" % varinfo + """
             """ + """
             """.join(varinfo['onchangecode'])+"""
         except Exception as e: