diff options
| author | Eugene Triguba <eugenetriguba@gmail.com> | 2020-10-03 14:15:46 -0500 |
|---|---|---|
| committer | Eugene Triguba <eugenetriguba@gmail.com> | 2020-10-03 14:15:46 -0500 |
| commit | 44d781df96d67e5ee301c394677b60bf77d30fce (patch) | |
| tree | 8714494d580b32405ddb7b9b09da78fcaafc1276 /config_file/config_file.py | |
| parent | Add docstrings to pytest fixtures (diff) | |
| download | config-file-44d781df96d67e5ee301c394677b60bf77d30fce.zip | |
Fix issue #25 (INI parser isn't converting back to string)
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() |