Skip to content

Commit c5c9859

Browse files
committed
fix: python 3.8
1 parent 739222e commit c5c9859

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

hooks/__init__.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22
import os
3-
from typing import Union, Any
3+
from typing import Union, Any, Dict, List
44

55
from ruamel import yaml
66

@@ -17,7 +17,7 @@
1717
scripts_folder: str = ''
1818

1919

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):
2121
if not cfg.config.automatically:
2222
return
2323

@@ -29,7 +29,7 @@ def trigger_hooks(hook: mount.Hooks, server: PluginServerInterface, objects_dict
2929

3030

3131
@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):
3333
logger.debug(f'Triggering hooks {hook.value}', server)
3434

3535
# 初始化最终变量字典
@@ -129,7 +129,7 @@ def man_run_task(task: str, env_str: str, src: CommandSource, server: PluginServ
129129
return
130130

131131
try:
132-
env_dict: dict[str, str] = dict(json.loads(env_str))
132+
env_dict: Dict[str, str] = dict(json.loads(env_str))
133133
except Exception as e:
134134
src.reply(RTextMCDRTranslation('hooks.man_run.illegal_env_json', e))
135135
return
@@ -175,7 +175,7 @@ def _parse_and_apply_scripts(script: str, server: PluginServerInterface):
175175
# 读取
176176
_yml = yaml.YAML()
177177
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)
179179

180180
if content is not None:
181181
if content.get('tasks') is not None:
@@ -268,9 +268,9 @@ def load_scripts(server: PluginServerInterface):
268268
os.makedirs(scripts_folder)
269269
return
270270

271-
def list_all_files(root_dir) -> list[str]:
271+
def list_all_files(root_dir) -> List[str]:
272272
# 显示一个文件夹及子文件夹中的所有yaml文件
273-
_files_in_a_folder: list[str] = []
273+
_files_in_a_folder: List[str] = []
274274

275275
for file in os.listdir(root_dir):
276276
file_path = os.path.join(root_dir, file)

hooks/config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List, Any
1+
from typing import List, Any, Dict
22

33
from mcdreforged.api.all import Serializable
44

@@ -37,11 +37,11 @@ def __init__(self):
3737
self.task = {}
3838
self.scripts_list = {}
3939

40-
hooks: dict[str, List[str]]
40+
hooks: Dict[str, List[str]]
4141

42-
task: dict[str, Any]
42+
task: Dict[str, Any]
4343

44-
scripts_list: dict[str, str]
44+
scripts_list: Dict[str, str]
4545

4646
schedule_daemon_threads: list = list()
4747

0 commit comments

Comments
 (0)