lpcmanager

Fix ThirdPartyPath again

18 months ago, Edouard Tisserant
6868d48a7c7e
Fix ThirdPartyPath again
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from OptionsParsing import ParseOptions, GenOptions
@staticmethod
def GetVarOnChangeContent(var):
"""
Function to overide the way PythonFileCTNMixin access OnChange column when
generating python code
"""
opts = ParseOptions(var.getopts())
if opts.is_onchange:
new_onchange = []
for onchangecall in var.getonchange().split(','):
onchangecall = onchangecall.strip()
if onchangecall:
new_onchange.append(onchangecall)
if opts.variable_type_selection == 1 : # "Static"
new_onchange += ["StoredValue"]
elif opts.variable_type_selection == 3 : # "Alarm"
new_onchange += ["Alarm"]
return ','.join(new_onchange)
return var.getonchange()
def FixOptions(self):
"""
Function to be called at the end of PythonFileCTNMixin.__init__()
"""
for var in self.CodeFile.variables.variable:
onchanges = [
onchange.strip() for onchange in var.getonchange().split(',')]
opts = ParseOptions(var.getopts())
for unwanted in ["Alarm", "StoredValue"]:
if unwanted in onchanges:
opts.is_onchange = True
onchanges.remove(unwanted)
var.setonchange(','.join(onchanges))
var.setopts(GenOptions(opts))