diff options
Diffstat (limited to 'config_file/config_file.py')
| -rw-r--r-- | config_file/config_file.py | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/config_file/config_file.py b/config_file/config_file.py index 934c198..18f3e0f 100644 --- a/config_file/config_file.py +++ b/config_file/config_file.py @@ -34,15 +34,24 @@ class ConfigFile: def original_path(self) -> Path: return Path(self.__path.original_path) - def __getitem__(self, key: str): + def __getitem__(self, key: str) -> Any: return self.__parser.parsed_content[key] - def __setitem__(self, key: str, value: Any): + def __setitem__(self, key: str, value: Any) -> None: self.__parser.parsed_content[key] = value - def __delitem__(self, key: str): + def __delitem__(self, key: str) -> None: del self.__parser.parsed_content[key] + def __contains__(self, key: str) -> bool: + return self.has(key) + + def __str__(self) -> str: + return self.stringify() + + def __repr__(self) -> str: + return f"{self.path}\n\n{self.stringify()}" + def get( self, key: str, @@ -122,6 +131,9 @@ class ConfigFile: Returns: The internal representation of the file that has been read in converted to a string. + + Depreciated: + Use str() on the ConfigFile object instead. """ return self.__parser.stringify() |