473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
|
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
|
+
+
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
+
+
|
# depending on priority: classifier.
#
def add_plugin_defaults(conf_options, conf_plugins, meta={}, module=""):
# Option defaults, if not yet defined
for opt in meta.get("config", []):
if "name" in opt and "value" in opt:
_value = opt.get("value", "")
_name = opt.get("name")
_type = opt.get("type")
if opt["name"] not in conf_options:
if _name not in conf_options:
# typemap "bool" and "int" here
if opt["type"] in ("bool", "boolean"):
val = opt["value"].lower() in ("1", "true", "yes", "on")
elif opt["type"] in ("int", "integer", "numeric"):
val = int(opt["value"])
elif opt["type"] in ("array", "table", "list"):
val = [ opt["value"].split(",") ]
elif opt["type"] in ("dict"):
val = dict(opt["value"].split(","))
if _type in ("bool", "boolean"):
val = _value.lower() in ("1", "true", "yes", "on")
elif _type in ("int", "integer", "numeric"):
val = int(_value)
elif _type in ("array", "table", "list"):
val = [ re.split("\s*[,;]\s*", s.strip()) for s in re.split("\s[|]\s*", _value) ]
elif _type in ("dict"):
val = dict([ re.split("\s*(?:=>+|==*|-+>|:=+)\s*", s.strip()) for s in re.split("\s*[|;,]\s*", _value) ])
else:
val = str(opt["value"])
conf_options[opt["name"]] = val
val = str(_value)
conf_options[_name] = val
# Initial plugin activation status
if module and module not in conf_plugins:
conf_plugins[module] = meta.get("priority") in (
"core", "builtin", "always", "default", "standard"
)
|