diff options
| author | Eugene Triguba <eugenetriguba@gmail.com> | 2020-02-02 14:21:02 -0600 |
|---|---|---|
| committer | Eugene Triguba <eugenetriguba@gmail.com> | 2020-02-02 14:21:02 -0600 |
| commit | 592ea6812da05ec49a7428862309e078704bc740 (patch) | |
| tree | c200a4924bcfd3cb83997c4aa4dc83c9cf7c8f41 /config_file/parsers/ini_parser.py | |
| parent | Add ability to parse values in list to native types (diff) | |
| download | config-file-592ea6812da05ec49a7428862309e078704bc740.zip | |
Add type hints + contents is now content in BaseParser
Diffstat (limited to 'config_file/parsers/ini_parser.py')
| -rw-r--r-- | config_file/parsers/ini_parser.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/config_file/parsers/ini_parser.py b/config_file/parsers/ini_parser.py index 549ed37..93f239c 100644 --- a/config_file/parsers/ini_parser.py +++ b/config_file/parsers/ini_parser.py @@ -19,7 +19,7 @@ class IniParser(BaseParser): except configparser.Error as error: raise ParsingError(error) - def get(self, section_key, parse_type=True): + def get(self, section_key: str, parse_type: bool = True): """ Read the value of `section.key` of the config file. @@ -54,18 +54,17 @@ class IniParser(BaseParser): return items - def set(self, section_key, value): + def set(self, section_key: str, value) -> bool: """ Sets the value of 'section.key' of the config file. If the specified section is not in the configuration file, it will be created before adding the key to it. :param section_key: The key to set from the config file. e.g. 'section1.key' - :param value: The value to set the key to. + :param value: The value to set the key to. It can be any type that can + be converted to a string. :return: True if the setting was successful. - :rtype: boolean - :raises ValueError: If there is no dot (.) in section_key """ section, key = split_on_dot(section_key, only_last_dot=True) @@ -79,7 +78,7 @@ class IniParser(BaseParser): self.parsed_content.set(section, key, value) return True - def delete(self, section_key): + def delete(self, section_key: str) -> bool: """ Deletes a key or an entire section. |