@@ -33,10 +33,8 @@ def __init__(self):
33
33
self .plugins : dict [str , Plugin ] = {}
34
34
self .log = get_logger ()
35
35
36
- async def load_config (self , init = True ):
37
- """Loads the configuration
38
-
39
- if `init` is true, also initializes the plugins"""
36
+ async def __open_config (self ):
37
+ """Loads config file as self.config"""
40
38
if os .path .exists (OLD_CONFIG_FILE ) and not os .path .exists (CONFIG_FILE ):
41
39
self .log .warning ("Consider changing your configuration to TOML format." )
42
40
@@ -65,8 +63,10 @@ async def load_config(self, init=True):
65
63
self .log .critical ("No Config file found ! Please create %s" , CONFIG_FILE )
66
64
raise PyprError ()
67
65
68
- assert self .config
69
-
66
+ async def __load_plugins_config (self , init = True ):
67
+ """Loads the plugins mentioned in the config.
68
+ If init is `True`, call the `init()` method on each plugin.
69
+ """
70
70
for name in cast (dict , self .config ["pyprland" ]["plugins" ]):
71
71
if name not in self .plugins :
72
72
modname = name if "." in name else f"pyprland.plugins.{ name } "
@@ -95,6 +95,15 @@ async def load_config(self, init=True):
95
95
self .log .error ("Error initializing plugin %s:" , name , exc_info = True )
96
96
raise PyprError () from e
97
97
98
+ async def load_config (self , init = True ):
99
+ """Loads the configuration
100
+
101
+ if `init` is true, also initializes the plugins"""
102
+
103
+ await self .__open_config ()
104
+ assert self .config
105
+ await self .__load_plugins_config (init = init )
106
+
98
107
async def _callHandler (self , full_name , * params ):
99
108
"Call an event handler with params"
100
109
0 commit comments