19from .stringOperations
import listToString
25 singleConfigurableSet method allows to assign value
26 to single configurable value arguments in JSON
with overriding.
27 This method
is used
for single value arguments
28 as JSONs will be assigned only by overriding
for single value arguments.
32 config (dict): Input
as JSON config file
33 key (string): Sub key
from upper key
in provided JSON config file
34 value (string): Value
from key
in provided JSON config file (sub-level)
35 arg (any): Argument
from parserargs
or manual
for some situations (
"-1" or "true" or "false" etc.)
39 string: Assigned
as a direct string
43 config[key][value] = arg
48def multiConfigurableSet(config: dict, key: str, value: str, arg: list, onlySelect):
50 multiConfigurableSet method allows to assign values
51 for multiple configurable value arguments
in JSON
with/without overriding
52 depending on interface mode. The onlySelect parameter decides
for
53 interface mode.if the argument contains more than one value, it
is saved
as list type by default
54 and this method converts them to comma separated string, otherwise assigns them
as string value directly
58 config (dict): Input
as JSON config file
59 key (string): Sub key
from upper key
in provided config JSON config file
60 value (string): Value
from key
in provided JSON config file (sub-level)
61 arg (any): Argument
from parserargs
62 onlySelect (boolean): Input
as args.onlySelect
for selecting interface mode.
63 true
for Overrider Mode
and false
for Additional mode
67 string
or comma seperated string: If the argument
is of list type,
68 it assign
as a comma separated string,
69 otherwise it assign directly
as a string.
73 if isinstance(arg, list):
74 arg = listToString(arg)
75 if onlySelect ==
"false":
76 actualConfig = config[key][value]
77 arg = actualConfig +
"," + arg
78 config[key][value] = arg
83def processDummySet(config: dict):
85 for k, v
in config.items():
86 if isinstance(v, dict):
87 for v, v2
in v.items():
88 if (
not v.endswith(
"Dummy"))
and (v.startswith(
"process")):
89 if config[k][v] ==
"true":
90 config[k][
"processDummy"] =
"false"
91 print(k,
"dummy converted false")
94 config[k][
"processDummy"] =
"true"
95 print(k,
"dummy converted true")
def singleConfigurableSet(dict config, str key, str value, str arg)