mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-24 16:23:36 +05:00
Merge commit '08640e5b177595f5e84d4bf9194311282b1a91e2' into kiauh-v6-dev
This commit is contained in:
@@ -111,7 +111,13 @@ class SimpleConfigParser:
|
||||
self.in_option_block: bool = False # whether we are in a multiline option block
|
||||
|
||||
def read(self, file: Path) -> None:
|
||||
"""Read the given file and store the result in the internal state"""
|
||||
"""
|
||||
Read the given file and store the result in the internal state.
|
||||
Call this method before using any other methods. Calling this method
|
||||
multiple times will reset the internal state on each call.
|
||||
"""
|
||||
|
||||
self._reset_state()
|
||||
|
||||
try:
|
||||
with open(file, "r") as f:
|
||||
@@ -120,6 +126,16 @@ class SimpleConfigParser:
|
||||
except OSError:
|
||||
raise
|
||||
|
||||
def _reset_state(self):
|
||||
"""Reset the internal state."""
|
||||
|
||||
self._config.clear()
|
||||
self._header.clear()
|
||||
self._all_sections.clear()
|
||||
self._all_options.clear()
|
||||
self.section_name = ""
|
||||
self.in_option_block = False
|
||||
|
||||
def write(self, filename):
|
||||
"""Write the internal state to the given file"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user