diff options
Diffstat (limited to 'poezio/plugin.py')
-rw-r--r-- | poezio/plugin.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/poezio/plugin.py b/poezio/plugin.py index 61e0ea87..f38e47e2 100644 --- a/poezio/plugin.py +++ b/poezio/plugin.py @@ -3,6 +3,8 @@ Define the PluginConfig and Plugin classes, plus the SafetyMetaclass. These are used in the plugin system added in poezio 0.7.5 (see plugin_manager.py) """ + +from typing import Any, Dict, Set, Optional from asyncio import iscoroutinefunction from functools import partial from configparser import RawConfigParser @@ -24,6 +26,7 @@ class PluginConfig(config.Config): def __init__(self, filename, module_name, default=None): config.Config.__init__(self, filename, default=default) self.module_name = module_name + self.default_section = module_name self.read() def get(self, option, default=None, section=None): @@ -43,7 +46,7 @@ class PluginConfig(config.Config): def read(self): """Read the config file""" - RawConfigParser.read(self, str(self.file_name)) + RawConfigParser.read(self.configparser, str(self.file_name)) if not self.has_section(self.module_name): self.add_section(self.module_name) @@ -62,7 +65,7 @@ class PluginConfig(config.Config): """Write the config to the disk""" try: with self.file_name.open('w') as fp: - RawConfigParser.write(self, fp) + RawConfigParser.write(self.configparser, fp) return True except IOError: return False @@ -399,7 +402,13 @@ class BasePlugin(object, metaclass=SafetyMetaclass): Class that all plugins derive from. """ - default_config = None + # Internal use only + _unloading = False + + default_config: Optional[Dict[Any, Any]] = None + dependencies: Set[str] = set() + # This dict will get populated when the plugin is initialized + refs: Dict[str, Any] = {} def __init__(self, name, plugin_api, core, plugins_conf_dir): self.__name = name @@ -417,7 +426,7 @@ class BasePlugin(object, metaclass=SafetyMetaclass): self.init() @property - def name(self): + def name(self) -> str: """ Get the name (module name) of the plugin. """ |