-
Notifications
You must be signed in to change notification settings - Fork 90
/
fbApplyConfigSetting.py
49 lines (48 loc) · 1.96 KB
/
fbApplyConfigSetting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from dxConfig import dxConfig;
from foConsoleLoader import foConsoleLoader;
from mColorsAndChars import *;
oConsole = foConsoleLoader();
def fbApplyConfigSetting(sSettingName, xValue, sIndentation): # sIndentation is None means no output!
asGroupNames = sSettingName.split("."); # last element is not a group name
sFullName = ".".join(asGroupNames);
sSettingName = asGroupNames.pop(); # so pop it.
dxConfigGroup = dxConfig;
asHandledGroupNames = [];
for sGroupName in asGroupNames:
asHandledGroupNames.append(sGroupName);
if sGroupName not in dxConfigGroup:
oConsole.fOutput(
COLOR_ERROR, "Unknown config group ",
COLOR_INFO, ".".join(asHandledGroupNames),
COLOR_ERROR, " in setting name ",
COLOR_INFO, sFullName,
COLOR_ERROR, ".",
);
return False;
dxConfigGroup = dxConfigGroup.get(sGroupName, {});
if sSettingName not in dxConfigGroup:
if len(asHandledGroupNames) > 0:
oConsole.fOutput(
COLOR_ERROR, "Unknown setting name ",
COLOR_INFO, sSettingName,
COLOR_ERROR, " in config group ",
COLOR_INFO, ".".join(asHandledGroupNames),
COLOR_ERROR, ".",
);
else:
oConsole.fOutput(
COLOR_ERROR, "Unknown setting name ",
COLOR_INFO, sSettingName,
COLOR_ERROR, ".",
);
return False;
if repr(dxConfigGroup[sSettingName]) == repr(xValue):
if sIndentation is not None:
oConsole.fOutput(sIndentation, "* The default value for config setting ", COLOR_HILITE, sFullName, COLOR_NORMAL, \
" is ", COLOR_INFO, repr(dxConfigGroup[sSettingName]), COLOR_NORMAL, ".");
else:
if sIndentation is not None:
oConsole.fOutput(sIndentation, "+ Changed config setting ", COLOR_HILITE, sFullName, COLOR_NORMAL, \
" from ", COLOR_HILITE, repr(dxConfigGroup[sSettingName]), COLOR_NORMAL, " to ", COLOR_INFO, repr(xValue), COLOR_NORMAL, ".");
dxConfigGroup[sSettingName] = xValue;
return True;