Plugins: Make open method clearer to use

This highlights that the FileHandler class can also be seen as a method
similar to open, and it removes unnecessary context managers, allowing
plugins to close files as they wish (they must, however, remember to
close the file for it to be committed).
This commit is contained in:
Mike Auty
2020-10-29 09:43:16 +00:00
committed by ikelos
parent 0e596c2112
commit ea629591ef
11 changed files with 75 additions and 71 deletions
+1 -1
View File
@@ -129,7 +129,7 @@ class PluginInterface(interfaces.configuration.ConfigurableInterface,
"""Returns a context manager and thus can be called like open"""
return self._file_handler
def set_file_handler(self, handler: Type[FileHandlerInterface]) -> None:
def set_open_method(self, handler: Type[FileHandlerInterface]) -> None:
"""Sets the file handler to be used by this plugin."""
if not issubclass(handler, FileHandlerInterface):
raise ValueError("FileHandler must be a subclass of FileHandlerInterface")