mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-25 00:33:37 +05:00
Squashed 'kiauh/core/submodules/simple_config_parser/' changes from 47c353f..3655330
3655330 refactor: use pop() for removing elements from lists and dicts 99733f1 refactor: add empty options dict to _all_options on section parsing git-subtree-dir: kiauh/core/submodules/simple_config_parser git-subtree-split: 3655330d2156e13acffc56fac070ab8716444c85
This commit is contained in:
@@ -192,9 +192,9 @@ class SimpleConfigParser:
|
|||||||
if section not in self._all_sections:
|
if section not in self._all_sections:
|
||||||
raise NoSectionError(section)
|
raise NoSectionError(section)
|
||||||
|
|
||||||
del self._all_sections[self._all_sections.index(section)]
|
self._all_sections.pop(self._all_sections.index(section))
|
||||||
del self._all_options[section]
|
self._all_options.pop(section)
|
||||||
del self._config[section]
|
self._config.pop(section)
|
||||||
|
|
||||||
def options(self, section) -> List[str]:
|
def options(self, section) -> List[str]:
|
||||||
"""Return a list of option names for the given section name"""
|
"""Return a list of option names for the given section name"""
|
||||||
@@ -453,6 +453,7 @@ class SimpleConfigParser:
|
|||||||
|
|
||||||
self.section_name = section
|
self.section_name = section
|
||||||
self._all_sections.append(section)
|
self._all_sections.append(section)
|
||||||
|
self._all_options[section] = {}
|
||||||
self._config[section]: Section = {"_raw": raw_value, "body": []}
|
self._config[section]: Section = {"_raw": raw_value, "body": []}
|
||||||
|
|
||||||
def _parse_option(self, line: str) -> None:
|
def _parse_option(self, line: str) -> None:
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ class TestInternalStateChanges:
|
|||||||
parser._store_internal_state_section(given, given)
|
parser._store_internal_state_section(given, given)
|
||||||
|
|
||||||
assert parser._all_sections == [given]
|
assert parser._all_sections == [given]
|
||||||
|
assert parser._all_options[given] == {}
|
||||||
assert parser._config[given]["body"] == []
|
assert parser._config[given]["body"] == []
|
||||||
assert parser._config[given]["_raw"] == given
|
assert parser._config[given]["_raw"] == given
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user