diff options
| author | Eugene Triguba <eugenetriguba@gmail.com> | 2020-08-16 22:02:04 -0500 |
|---|---|---|
| committer | Eugene Triguba <eugenetriguba@gmail.com> | 2020-08-16 22:02:04 -0500 |
| commit | 954404e8a111d6445bf9313f0f27c205d88b550f (patch) | |
| tree | 2f91adf21529b401dd9d706019a1d097db8c867e /config_file/abstract_parser.py | |
| parent | Use black isort profile (diff) | |
| download | config-file-954404e8a111d6445bf9313f0f27c205d88b550f.zip | |
Enforce `parsed_content` property in AbstractParser
It is used in the ConfigFile object to be able to index
into it.
Diffstat (limited to 'config_file/abstract_parser.py')
| -rw-r--r-- | config_file/abstract_parser.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/config_file/abstract_parser.py b/config_file/abstract_parser.py index dcc2b0f..460b238 100644 --- a/config_file/abstract_parser.py +++ b/config_file/abstract_parser.py @@ -25,6 +25,21 @@ class AbstractParser(ABC): def __init__(self, file_contents: str) -> None: self.file_contents = file_contents + @property + @abstractmethod + def parsed_content(self) -> dict: + """To be able to index into the ConfigFile object, + we have to expose the parsed dictionary object. + + Raises: + KeyError: If the key we are trying to index into + does not exist. + + Returns: + The internal contents parsed as a dictionary. + """ + raise NotImplementedError + @abstractmethod def reset_internal_contents(self, file_contents: str) -> None: """Reset the state of this parser to a new file. |