Skip to content

Commit 5a61d28

Browse files
committed
Refactor update dev version
Refactor update dev version
1 parent 82c7356 commit 5a61d28

File tree

14 files changed

+163
-96
lines changed

14 files changed

+163
-96
lines changed

.idea/workspace.xml

Lines changed: 2 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

je_auto_control/utils/callback/callback_function_executor.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import typing
1+
from typing import Callable, Any
22
from sys import stderr
33

44
from je_auto_control.utils.exception.exception_tags import get_bad_trigger_method, get_bad_trigger_function
@@ -122,11 +122,11 @@ def __init__(self):
122122
def callback_function(
123123
self,
124124
trigger_function_name: str,
125-
callback_function: typing.Callable,
125+
callback_function: Callable,
126126
callback_function_param: [dict, None] = None,
127127
callback_param_method: str = "kwargs",
128128
**kwargs
129-
) -> typing.Any:
129+
) -> Any:
130130
"""
131131
:param trigger_function_name: what function we want to trigger only accept function in event_dict
132132
:param callback_function: what function we want to callback
@@ -155,4 +155,3 @@ def callback_function(
155155

156156
callback_executor = CallbackFunctionExecutor()
157157
package_manager.callback_executor = callback_executor
158-

je_auto_control/utils/executor/action_executor.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import builtins
2-
import sys
32
import types
43
from inspect import getmembers, isbuiltin
4+
from typing import Any, Dict, List
55

66
from je_auto_control.utils.exception.exception_tags import action_is_null_error, add_command_exception, \
77
executor_list_error
@@ -94,7 +94,7 @@ def __init__(self):
9494
for function in getmembers(builtins, isbuiltin):
9595
self.event_dict.update({str(function[0]): function[1]})
9696

97-
def _execute_event(self, action: list):
97+
def _execute_event(self, action: list) -> Any:
9898
event = self.event_dict.get(action[0])
9999
if len(action) == 2:
100100
if isinstance(action[1], dict):
@@ -106,7 +106,7 @@ def _execute_event(self, action: list):
106106
else:
107107
raise AutoControlActionException(cant_execute_action_error + " " + str(action))
108108

109-
def execute_action(self, action_list: [list, dict]) -> dict:
109+
def execute_action(self, action_list: [list, dict]) -> Dict[str, str]:
110110
"""
111111
use to execute all action on action list(action file or program list)
112112
:param action_list the list include action
@@ -145,7 +145,7 @@ def execute_action(self, action_list: [list, dict]) -> dict:
145145
print(value, flush=True)
146146
return execute_record_dict
147147

148-
def execute_files(self, execute_files_list: list) -> list:
148+
def execute_files(self, execute_files_list: list) -> List[Dict[str, str]]:
149149
"""
150150
:param execute_files_list: list include execute files path
151151
:return: every execute detail as list
@@ -161,7 +161,7 @@ def execute_files(self, execute_files_list: list) -> list:
161161
package_manager.executor = executor
162162

163163

164-
def add_command_to_executor(command_dict: dict):
164+
def add_command_to_executor(command_dict: dict) -> None:
165165
"""
166166
:param command_dict: dict include command we want to add to event_dict
167167
"""
@@ -172,9 +172,9 @@ def add_command_to_executor(command_dict: dict):
172172
raise AutoControlAddCommandException(add_command_exception)
173173

174174

175-
def execute_action(action_list: list) -> dict:
175+
def execute_action(action_list: list) -> Dict[str, str]:
176176
return executor.execute_action(action_list)
177177

178178

179-
def execute_files(execute_files_list: list) -> list:
179+
def execute_files(execute_files_list: list) -> List[Dict[str, str]]:
180180
return executor.execute_files(execute_files_list)

je_auto_control/utils/generate_report/generate_html_report.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def generate_html() -> str:
150150
return new_html_string
151151

152152

153-
def generate_html_report(html_name: str = "default_name"):
153+
def generate_html_report(html_name: str = "default_name") -> None:
154154
auto_control_logger.info(f"generate_html_report, html_name: {html_name}")
155155
"""
156156
Output html report file

je_auto_control/utils/generate_report/generate_json_report.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import json
2-
import sys
32
from threading import Lock
43

54
from je_auto_control.utils.exception.exception_tags import cant_generate_json_report
@@ -8,7 +7,7 @@
87
from je_auto_control.utils.test_record.record_test_class import test_record_instance
98

109

11-
def generate_json():
10+
def generate_json() -> tuple[dict[str, dict[str, str]], dict[str, dict[str, str]]]:
1211
auto_control_logger.info("generate_json")
1312
"""
1413
:return: two dict {success_dict}, {failure_dict}

je_auto_control/utils/generate_report/generate_xml_report.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import sys
21
from threading import Lock
32
from xml.dom.minidom import parseString
3+
from typing import Tuple, Dict, Union
44

55
from je_auto_control.utils.generate_report.generate_json_report import generate_json
66
from je_auto_control.utils.logging.loggin_instance import auto_control_logger
77
from je_auto_control.utils.xml.change_xml_structure.change_xml_structure import dict_to_elements_tree
88

99

10-
def generate_xml():
10+
def generate_xml() -> Tuple[Union[str, bytes], Union[str, bytes]]:
1111
auto_control_logger.info("generate_xml")
1212
"""
1313
:return: two dict {success_dict}, {failure_dict}
@@ -52,4 +52,3 @@ def generate_xml_report(xml_file_name: str = "default_name"):
5252
f"failed: {repr(error)}")
5353
finally:
5454
lock.release()
55-

je_auto_control/utils/json/json_file.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
from pathlib import Path
33
from threading import Lock
4+
from typing import List, Dict
45

56
from je_auto_control.utils.exception.exception_tags import cant_find_json_error
67
from je_auto_control.utils.exception.exception_tags import cant_save_json_error
@@ -9,7 +10,7 @@
910
_lock = Lock()
1011

1112

12-
def read_action_json(json_file_path: str) -> list:
13+
def read_action_json(json_file_path: str) -> List[List[Dict[str, Dict[str, str]]]]:
1314
"""
1415
use to read action file
1516
:param json_file_path json file's path to read

je_auto_control/utils/package_manager/package_manager_class.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from importlib.util import find_spec
33
from inspect import getmembers, isfunction, isbuiltin, isclass
44
from sys import stderr
5+
from typing import Union, Callable
56

67
from je_auto_control.utils.logging.loggin_instance import auto_control_logger
78

@@ -14,7 +15,7 @@ def __init__(self):
1415
self.executor = None
1516
self.callback_executor = None
1617

17-
def check_package(self, package: str):
18+
def check_package(self, package: str) -> Union[None, dict[str, Callable]]:
1819
"""
1920
:param package: package to check exists or not
2021
:return: package if find else None
@@ -30,7 +31,7 @@ def check_package(self, package: str):
3031
print(repr(error), file=stderr)
3132
return self.installed_package_dict.get(package, None)
3233

33-
def add_package_to_executor(self, package):
34+
def add_package_to_executor(self, package) -> None:
3435
auto_control_logger.info(f"add_package_to_executor, package: {package}")
3536
"""
3637
:param package: package's function will add to executor
@@ -40,7 +41,7 @@ def add_package_to_executor(self, package):
4041
target=self.executor
4142
)
4243

43-
def add_package_to_callback_executor(self, package):
44+
def add_package_to_callback_executor(self, package) -> None:
4445
auto_control_logger.info(f"add_package_to_callback_executor, package: {package}")
4546
"""
4647
:param package: package's function will add to callback_executor
@@ -50,7 +51,7 @@ def add_package_to_callback_executor(self, package):
5051
target=self.callback_executor
5152
)
5253

53-
def get_member(self, package, predicate, target):
54+
def get_member(self, package, predicate, target) -> None:
5455
"""
5556
:param package: package we want to get member
5657
:param predicate: predicate
@@ -67,7 +68,7 @@ def get_member(self, package, predicate, target):
6768
else:
6869
print(f"Executor error {self.executor}", file=stderr)
6970

70-
def add_package_to_target(self, package, target):
71+
def add_package_to_target(self, package, target) -> None:
7172
"""
7273
:param package: package we want to get member
7374
:param target: which event_dict will be added

0 commit comments

Comments
 (0)