diff options
| author | Eugene Triguba <eugenetriguba@gmail.com> | 2020-01-17 20:31:42 -0600 |
|---|---|---|
| committer | Eugene Triguba <eugenetriguba@gmail.com> | 2020-01-17 20:31:42 -0600 |
| commit | 0174602093dcb097e23f6493bfd4f5d1a9fe2e3c (patch) | |
| tree | ced5d54e2cb5e80008adc39cf0f9fdb2c53eadc8 /config_file/parsers/base_parser.py | |
| parent | Fix bug with isinstance use in config file (diff) | |
| download | config-file-0174602093dcb097e23f6493bfd4f5d1a9fe2e3c.zip | |
Remove _split_on_dot from base parser and add it to utils
Also, change the default behavior to split on every dot and split on
only the last dot if specified
Diffstat (limited to 'config_file/parsers/base_parser.py')
| -rw-r--r-- | config_file/parsers/base_parser.py | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/config_file/parsers/base_parser.py b/config_file/parsers/base_parser.py index 38e8859..22e286a 100644 --- a/config_file/parsers/base_parser.py +++ b/config_file/parsers/base_parser.py @@ -22,7 +22,7 @@ class BaseParser(ABC): the parser and save the file when they are done using stringify(). """ self.contents = file_contents - self.parse(self.contents) + self.parsed_content = self.parse(self.contents) @abstractmethod def get(self, key, parse_type=True): @@ -74,25 +74,6 @@ class BaseParser(ABC): """ raise NotImplementedError - @staticmethod - def _split_on_dot(line: str, all_dots=False): - """ - Split a string on the first dot (.). - - :param line: The line ot split on. - :param all_dots: If the line should be split on all the dots. Defaults to - False and only splits on the first occurrence of one. - - :raises ValueError: if the line does not have a dot. - """ - if "." not in line: - raise ValueError( - "section_key must contain the section and key separated by a dot. " - + "e.g. 'section.key'" - ) - - return line.split(".") if all_dots else line.rsplit(".", 1) - class ParsingError(Exception): """Unable to parse the configuration file""" |