From 44d781df96d67e5ee301c394677b60bf77d30fce Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 3 Oct 2020 14:15:46 -0500 Subject: Fix issue #25 (INI parser isn't converting back to string) --- config_file/config_file.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'config_file/config_file.py') 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() -- cgit v1.2.3