cardinal_pythonlib.configfiles
Original code copyright (C) 2009-2022 Rudolf Cardinal (rudolf@pobox.com).
This file is part of cardinal_pythonlib.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Support functions for config (.INI) file reading.
- cardinal_pythonlib.configfiles.get_config_bool_option(parser: ConfigParser, section: str, option: str, default: bool | None = None) bool [source]
Retrieves a boolean value from a parser.
- cardinal_pythonlib.configfiles.get_config_multiline_option(parser: ConfigParser, section: str, option: str, default: List[str] | None = None) List[str] [source]
Retrieves a multi-line string value from a parser as a list of strings (one per line, ignoring blank lines).
- cardinal_pythonlib.configfiles.get_config_parameter(config: ConfigParser, section: str, param: str, fn: Callable[[Any], Any], default: Any | None = None, loglevel: int = 10) Any [source]
Fetch parameter from
configparser
.INI
file.- Parameters:
- Returns:
parameter value, or
None
ifdefault is None
, orfn(default)
- cardinal_pythonlib.configfiles.get_config_parameter_boolean(config: ConfigParser, section: str, param: str, default: bool, loglevel: int = 10) bool [source]
Get Boolean parameter from
configparser
.INI
file.
- cardinal_pythonlib.configfiles.get_config_parameter_loglevel(config: ConfigParser, section: str, param: str, default: int, loglevel: int = 10) int [source]
Get
loglevel
parameter fromconfigparser
.INI
file, e.g. mapping'debug'
tologging.DEBUG
.
- cardinal_pythonlib.configfiles.get_config_parameter_multiline(config: ConfigParser, section: str, param: str, default: List[str], loglevel: int = 10) List[str] [source]
Get multi-line string parameter from
configparser
.INI
file, as a list of strings (one per line, ignoring blank lines).
- cardinal_pythonlib.configfiles.get_config_string_option(parser: ConfigParser, section: str, option: str, default: str | None = None) str [source]
Retrieves a string value from a parser.
- cardinal_pythonlib.configfiles.read_config_multiline_options(obj: Any, parser: ConfigParser, section: str, options: Iterable[str]) None [source]
This is to
read_config_string_options()
asget_config_multiline_option()
is toget_config_string_option()
.