from __future__ import absolute_import
VARIABLETYPE = ["None", "Static", "Session", "Alarm"]
opt_parser = re.compile(r'(\w+)\s*(?:=\s*"([^"]+)"\s*|=([^\s]+)\s*)?')
variable_type_selection = 0,
options = VARIABLETYPE[opts.variable_type_selection]
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) + '"'
options += ' precision="' + str(opts.precision) + '"'
for name in ['subgroup', 'unit', 'other', 'tags']:
options += ' ' + name + '="' + content + '"'
options = re.findall(opt_parser,opts)
for key,dblquote_value,smpl_value in options:
# sometime there is a dblquote at the end only of the value
# because of old bug in previous version, fix for backward compatibility
if len(smpl_value) > 0 and smpl_value[-1] == '"':
smpl_value = smpl_value[:-1]
value = dblquote_value+smpl_value
elif key in VARIABLETYPE[1:]:
res.variable_type_selection = VARIABLETYPE.index(key)
if key in ["precision", "min","max"]:
raise Exception("Unknown key in options")