mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-25 08:43:36 +05:00
Squashed 'kiauh/core/submodules/simple_config_parser/' changes from 188dd1f..4d60d30
4d60d30 refactor: in multiline options we do not replace the option name 0a1fba5 refactor: set default indent to 4 spaces ab522bf refactor: the value of an option can be a list of strings git-subtree-dir: kiauh/core/submodules/simple_config_parser git-subtree-split: 4d60d30a75e7151be7b38b7cdbb2c133711b0091
This commit is contained in:
@@ -185,7 +185,9 @@ class SimpleConfigParser:
|
|||||||
|
|
||||||
return self._all_options.get(section)
|
return self._all_options.get(section)
|
||||||
|
|
||||||
def get(self, section: str, option: str, fallback: str | _UNSET = _UNSET) -> str:
|
def get(
|
||||||
|
self, section: str, option: str, fallback: str | _UNSET = _UNSET
|
||||||
|
) -> str | List[str]:
|
||||||
"""
|
"""
|
||||||
Return the value of the given option in the given section
|
Return the value of the given option in the given section
|
||||||
|
|
||||||
@@ -260,7 +262,7 @@ class SimpleConfigParser:
|
|||||||
option: str,
|
option: str,
|
||||||
value: str,
|
value: str,
|
||||||
multiline: bool = False,
|
multiline: bool = False,
|
||||||
indent: int = 2,
|
indent: int = 4,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set the given option to the given value in the given section
|
"""Set the given option to the given value in the given section
|
||||||
|
|
||||||
@@ -312,8 +314,13 @@ class SimpleConfigParser:
|
|||||||
else:
|
else:
|
||||||
for _option in self._config[section]["body"]:
|
for _option in self._config[section]["body"]:
|
||||||
if _option["option"] == option:
|
if _option["option"] == option:
|
||||||
# we preserve inline comments by replacing the old value with the new one
|
if multiline:
|
||||||
_option["_raw"] = _option["_raw"].replace(_option["value"], _value)
|
_option["_raw"] = _raw
|
||||||
|
else:
|
||||||
|
# we preserve inline comments by replacing the old value with the new one
|
||||||
|
_option["_raw"] = _option["_raw"].replace(
|
||||||
|
_option["value"], _value
|
||||||
|
)
|
||||||
_option["value"] = _value
|
_option["value"] = _value
|
||||||
if _raw_value is not None:
|
if _raw_value is not None:
|
||||||
_option["_raw_value"] = _raw_value
|
_option["_raw_value"] = _raw_value
|
||||||
|
|||||||
Reference in New Issue
Block a user