1
1
import json
2
2
import os
3
- from typing import Union , Any
3
+ from typing import Union , Any , Dict , List
4
4
5
5
from ruamel import yaml
6
6
17
17
scripts_folder : str = ''
18
18
19
19
20
- def trigger_hooks (hook : mount .Hooks , server : PluginServerInterface , objects_dict : dict [str , Any ] = None ):
20
+ def trigger_hooks (hook : mount .Hooks , server : PluginServerInterface , objects_dict : Dict [str , Any ] = None ):
21
21
if not cfg .config .automatically :
22
22
return
23
23
@@ -29,7 +29,7 @@ def trigger_hooks(hook: mount.Hooks, server: PluginServerInterface, objects_dict
29
29
30
30
31
31
@new_thread ('hooks - trigger' )
32
- def _trigger_hooks (hook : mount .Hooks , server : PluginServerInterface , objects_dict : dict [str , Any ] = None ):
32
+ def _trigger_hooks (hook : mount .Hooks , server : PluginServerInterface , objects_dict : Dict [str , Any ] = None ):
33
33
logger .debug (f'Triggering hooks { hook .value } ' , server )
34
34
35
35
# 初始化最终变量字典
@@ -129,7 +129,7 @@ def man_run_task(task: str, env_str: str, src: CommandSource, server: PluginServ
129
129
return
130
130
131
131
try :
132
- env_dict : dict [str , str ] = dict (json .loads (env_str ))
132
+ env_dict : Dict [str , str ] = dict (json .loads (env_str ))
133
133
except Exception as e :
134
134
src .reply (RTextMCDRTranslation ('hooks.man_run.illegal_env_json' , e ))
135
135
return
@@ -175,7 +175,7 @@ def _parse_and_apply_scripts(script: str, server: PluginServerInterface):
175
175
# 读取
176
176
_yml = yaml .YAML ()
177
177
with open (cfg .temp_config .scripts_list .get (script ), 'r' ) as f :
178
- content : dict [str , Union [str , Union [list , dict ]]] = _yml .load (f ) # yaml.load(f.read(), Loader=yaml.Loader)
178
+ content : Dict [str , Union [str , Union [list , dict ]]] = _yml .load (f ) # yaml.load(f.read(), Loader=yaml.Loader)
179
179
180
180
if content is not None :
181
181
if content .get ('tasks' ) is not None :
@@ -268,9 +268,9 @@ def load_scripts(server: PluginServerInterface):
268
268
os .makedirs (scripts_folder )
269
269
return
270
270
271
- def list_all_files (root_dir ) -> list [str ]:
271
+ def list_all_files (root_dir ) -> List [str ]:
272
272
# 显示一个文件夹及子文件夹中的所有yaml文件
273
- _files_in_a_folder : list [str ] = []
273
+ _files_in_a_folder : List [str ] = []
274
274
275
275
for file in os .listdir (root_dir ):
276
276
file_path = os .path .join (root_dir , file )
0 commit comments