diff options
Diffstat (limited to 'config_file/parsers/ini_parser.py')
| -rw-r--r-- | config_file/parsers/ini_parser.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/config_file/parsers/ini_parser.py b/config_file/parsers/ini_parser.py index 3c8f12f..549ed37 100644 --- a/config_file/parsers/ini_parser.py +++ b/config_file/parsers/ini_parser.py @@ -33,14 +33,27 @@ class IniParser(BaseParser): :raises ParsingError: if the specified `section.key` is not found, in an invalid format, or if we are unable to coerce the return value to value_type. """ - section, key = split_on_dot(section_key, only_last_dot=True) + if "." not in section_key: + return self.__retrieve_section(section_key, parse_type) try: + section, key = split_on_dot(section_key, only_last_dot=True) value = self.parsed_content.get(section, key) return parse_value(value) if parse_type else value except configparser.Error as error: raise ParsingError(error.message) + def __retrieve_section(self, section, parse_type): + items = dict(self.parsed_content.items(section)) + + if not parse_type: + return items + + for item in items: + items[item] = parse_value(items[item]) + + return items + def set(self, section_key, value): """ Sets the value of 'section.key' of the config file. If the specified section |