lpcmanager

Comment out dead MC8 code

2024-02-20, Edouard Tisserant
968105d8cb36
Comment out dead MC8 code
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import re
VARIABLETYPE = ["None", "Static", "Session", "Alarm"]
opt_parser = re.compile(r'(\w+)\s*(?:=\s*"([^"]+)"\s*|=([^\s]+)\s*)?')
class OptionsType(dict):
def __init__(self):
dict.__init__(self,
is_onchange = False,
is_scada = False,
is_static = False,
variable_type_selection = 0,
unit = None,
min = None,
max = None,
precision = None,
subgroup = None,
other = None,
disable = False,
tags = None)
self.__dict__ = self
def GenOptions(opts):
options = VARIABLETYPE[opts.variable_type_selection]
if options == "None":
options = ""
if opts.is_onchange:
options += " onchange"
if opts.is_scada:
options += " scada"
if opts.is_static:
options += " static"
if opts.min is not None or opts.max is not None:
options += ' min=' + str(opts.min if opts.min is not None else 0)
options += ' max=' + str(opts.max if opts.min is not None else 0)
if opts.precision:
options += ' precision=' + str(opts.precision)
if opts.disable:
options += ' disable=True'
for name in ['subgroup', 'unit', 'other', 'tags']:
content = opts[name]
if content is not None:
quoting = '"' if ' ' in content else ''
options += ' ' + name + '=' + quoting + content + quoting
return options
def ParseOptions(opts):
res = OptionsType()
options = re.findall(opt_parser,opts)
for key,dblquote_value,smpl_value in options:
value = dblquote_value+smpl_value
if value == "":
if key == "onchange":
res.is_onchange = True
elif key in VARIABLETYPE[1:]:
res.variable_type_selection = VARIABLETYPE.index(key)
elif key == "scada":
res.is_scada = True
elif key == "static":
res.is_static = True
else:
if key in ["precision", "min","max"]:
value = int(value)
if key == "disable":
res.disable = True
value = True
if key in res:
res[key] = value
else:
raise Exception("Unknown key in options")
return res