]>
glassweightruler.freedombox.rocks Git - waydroid.git/blob - tools/config/load.py
1 # Copyright 2021 Oliver Smith
2 # SPDX-License-Identifier: GPL-3.0-or-later
10 cfg
= configparser
.ConfigParser()
11 if os
.path
.isfile(args
.config
):
14 if "waydroid" not in cfg
:
17 for key
in tools
.config
.defaults
:
18 if key
in tools
.config
.config_keys
and key
not in cfg
["waydroid"]:
19 cfg
["waydroid"][key
] = str(tools
.config
.defaults
[key
])
21 # We used to save default values in the config, which can *not* be
22 # configured in "waydroid init". That doesn't make sense, we always
23 # want to use the defaults from tools/config/__init__.py in that case,
24 if key
not in tools
.config
.config_keys
and key
in cfg
["waydroid"]:
25 logging
.debug("Ignored unconfigurable and possibly outdated"
26 " default value from config: {}".format(cfg
['waydroid'][key
]))
27 del cfg
["waydroid"][key
]
29 if "properties" not in cfg
:
30 cfg
["properties"] = {}
31 # no default values for property override
36 config_path
= tools
.config
.channels_defaults
["config_path"]
37 cfg
= configparser
.ConfigParser()
38 if os
.path
.isfile(config_path
):
41 if "channels" not in cfg
:
44 for key
in tools
.config
.channels_defaults
:
45 if key
in tools
.config
.channels_config_keys
and key
not in cfg
["channels"]:
46 cfg
["channels"][key
] = str(tools
.config
.channels_defaults
[key
])
48 if key
not in tools
.config
.channels_config_keys
and key
in cfg
["channels"]:
49 logging
.debug("Ignored unconfigurable and possibly outdated"
50 " default value from config: {}".format(cfg
['channels'][key
]))
51 del cfg
["channels"][key
]