Skip to content

Commit 24e01d4

Browse files
committed
Refactor code
1 parent 59edd49 commit 24e01d4

19 files changed

Lines changed: 211 additions & 366 deletions

File tree

automation_editor/automation_editor_ui/complete/complete_extend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def complete_extend_package(main_window: AutomationEditor) -> None:
1919
:return: None
2020
"""
2121
widget = main_window.tab_widget.currentWidget()
22-
if type(widget) is EditorWidget:
22+
if isinstance(widget, EditorWidget):
2323
for package in package_manager.syntax_check_list:
2424
for word in package_keyword_list.get(package):
2525
# Complete

automation_editor/automation_editor_ui/menu/api_testka_menu/build_api_testka_menu.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
from typing import TYPE_CHECKING
44

5+
from automation_editor.automation_editor_ui.menu.menu_utils import open_web_browser
6+
57
if TYPE_CHECKING:
68
from automation_editor.automation_editor_ui.editor_main.main_ui import AutomationEditor
79
import sys
8-
import webbrowser
910

1011
from PySide6.QtGui import QAction
1112

@@ -64,7 +65,9 @@ def set_apitestka_menu(ui_we_want_to_set: AutomationEditor):
6465
ui_we_want_to_set.open_apitestka_doc_action = QAction("Open APITestka Doc")
6566
ui_we_want_to_set.open_apitestka_doc_action.triggered.connect(
6667
lambda: open_web_browser(
67-
"https://apitestka.readthedocs.io/en/latest/"
68+
ui_we_want_to_set,
69+
"https://apitestka.readthedocs.io/en/latest/",
70+
"APITestka Doc"
6871
)
6972
)
7073
ui_we_want_to_set.apitestka_help_menu.addAction(
@@ -74,7 +77,9 @@ def set_apitestka_menu(ui_we_want_to_set: AutomationEditor):
7477
ui_we_want_to_set.open_apitestka_github_action = QAction("Open APITestka GitHub")
7578
ui_we_want_to_set.open_apitestka_github_action.triggered.connect(
7679
lambda: open_web_browser(
77-
"https://github.com/Intergration-Automation-Testing/APITestka"
80+
ui_we_want_to_set,
81+
"https://github.com/Intergration-Automation-Testing/APITestka",
82+
"APITestka Github"
7883
)
7984
)
8085
ui_we_want_to_set.apitestka_help_menu.addAction(
@@ -91,10 +96,6 @@ def set_apitestka_menu(ui_we_want_to_set: AutomationEditor):
9196
)
9297

9398

94-
def open_web_browser(url: str) -> None:
95-
webbrowser.open(url=url)
96-
97-
9899
def create_project() -> None:
99100
try:
100101
import je_api_testka

automation_editor/automation_editor_ui/menu/auto_control_menu/build_autocontrol_menu.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
from je_editor import EditorWidget
66

7+
from automation_editor.automation_editor_ui.menu.menu_utils import open_web_browser
8+
79
if TYPE_CHECKING:
810
from automation_editor.automation_editor_ui.editor_main.main_ui import AutomationEditor
911
import sys
10-
import webbrowser
1112

1213
import je_auto_control
1314
from PySide6.QtGui import QAction
14-
from PySide6.QtWidgets import QPlainTextEdit
1515

1616
from automation_editor.extend.process_executor.auto_control.auto_control_process import \
1717
call_auto_control, call_auto_control_with_send, call_auto_control_multi_file, \
@@ -69,7 +69,9 @@ def set_autocontrol_menu(ui_we_want_to_set: AutomationEditor):
6969
ui_we_want_to_set.open_autocontrol_doc_action = QAction("Open AutoControl Doc")
7070
ui_we_want_to_set.open_autocontrol_doc_action.triggered.connect(
7171
lambda: open_web_browser(
72-
"https://autocontrol.readthedocs.io/en/latest/"
72+
ui_we_want_to_set,
73+
"https://autocontrol.readthedocs.io/en/latest/",
74+
"AutoControl Doc"
7375
)
7476
)
7577
ui_we_want_to_set.autocontrol_help_menu.addAction(
@@ -79,7 +81,9 @@ def set_autocontrol_menu(ui_we_want_to_set: AutomationEditor):
7981
ui_we_want_to_set.open_autocontrol_github_action = QAction("Open AutoControl GitHub")
8082
ui_we_want_to_set.open_autocontrol_github_action.triggered.connect(
8183
lambda: open_web_browser(
82-
"https://github.com/Intergration-Automation-Testing/AutoControl"
84+
ui_we_want_to_set,
85+
"https://github.com/Intergration-Automation-Testing/AutoControl",
86+
"AutoControl GitHub"
8387
)
8488
)
8589
ui_we_want_to_set.autocontrol_help_menu.addAction(
@@ -113,10 +117,6 @@ def set_autocontrol_menu(ui_we_want_to_set: AutomationEditor):
113117
)
114118

115119

116-
def open_web_browser(url: str) -> None:
117-
webbrowser.open(url=url)
118-
119-
120120
def create_project() -> None:
121121
try:
122122
import je_auto_control

automation_editor/automation_editor_ui/menu/automation_file_menu/build_automation_file_menu.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
from typing import TYPE_CHECKING
44

5+
from automation_editor.automation_editor_ui.menu.menu_utils import open_web_browser
6+
57
if TYPE_CHECKING:
68
from automation_editor.automation_editor_ui.editor_main.main_ui import AutomationEditor
79
import sys
8-
import webbrowser
910

1011
from PySide6.QtGui import QAction
1112

@@ -61,21 +62,25 @@ def set_automation_file_menu(ui_we_want_to_set: AutomationEditor):
6162
ui_we_want_to_set.run_multi_file_automation_action_with_send
6263
)
6364
ui_we_want_to_set.file_automation_help_menu = ui_we_want_to_set.automation_file_menu.addMenu("HELP")
64-
# # Open Doc
65-
# ui_we_want_to_set.open_file_automation_doc_action = QAction("Open FileAutomation Doc")
66-
# ui_we_want_to_set.open_file_automation_doc_action.triggered.connect(
67-
# lambda: open_web_browser(
68-
# "https://webrunner.readthedocs.io/en/latest/"
69-
# )
70-
# )
71-
# ui_we_want_to_set.file_automation_help_menu.addAction(
72-
# ui_we_want_to_set.open_file_automation_doc_action
73-
# )
65+
# Open Doc
66+
ui_we_want_to_set.open_file_automation_doc_action = QAction("Open FileAutomation Doc")
67+
ui_we_want_to_set.open_file_automation_doc_action.triggered.connect(
68+
lambda: open_web_browser(
69+
ui_we_want_to_set,
70+
"https://fileautomation.readthedocs.io/en/latest/",
71+
"FileAutomation Doc"
72+
)
73+
)
74+
ui_we_want_to_set.file_automation_help_menu.addAction(
75+
ui_we_want_to_set.open_file_automation_doc_action
76+
)
7477
# Open Github
7578
ui_we_want_to_set.open_file_automation_github_action = QAction("Open FileAutomation GitHub")
7679
ui_we_want_to_set.open_file_automation_github_action.triggered.connect(
7780
lambda: open_web_browser(
78-
"https://github.com/Integration-Automation/FileAutomation"
81+
ui_we_want_to_set,
82+
"https://github.com/Integration-Automation/FileAutomation",
83+
"FileAutomation GitHub"
7984
)
8085
)
8186
ui_we_want_to_set.file_automation_help_menu.addAction(
@@ -92,10 +97,6 @@ def set_automation_file_menu(ui_we_want_to_set: AutomationEditor):
9297
)
9398

9499

95-
def open_web_browser(url: str) -> None:
96-
webbrowser.open(url=url)
97-
98-
99100
def create_project() -> None:
100101
try:
101102
import file_automation

automation_editor/automation_editor_ui/menu/install_menu/build_install_menu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def install_package(package_text: str, ui_we_want_to_set: AutomationEditor) -> N
8585
else:
8686
compiler_path = shutil.which(cmd="python")
8787
widget = ui_we_want_to_set.tab_widget.currentWidget()
88-
if type(widget) is EditorWidget:
88+
if isinstance(widget, EditorWidget):
8989
shell_manager = ShellManager()
9090
shell_manager.main_window = widget
9191
shell_manager.later_init()

automation_editor/automation_editor_ui/menu/load_density_menu/build_load_density_menu.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
from typing import TYPE_CHECKING
44

5+
from automation_editor.automation_editor_ui.menu.menu_utils import open_web_browser
6+
57
if TYPE_CHECKING:
68
from automation_editor.automation_editor_ui.editor_main.main_ui import AutomationEditor
79
import sys
8-
import webbrowser
910

1011
from PySide6.QtGui import QAction
1112

@@ -65,7 +66,9 @@ def set_load_density_menu(ui_we_want_to_set: AutomationEditor):
6566
ui_we_want_to_set.open_load_density_doc_action = QAction("Open LoadDensity Doc")
6667
ui_we_want_to_set.open_load_density_doc_action.triggered.connect(
6768
lambda: open_web_browser(
68-
"https://loaddensity.readthedocs.io/en/latest/"
69+
ui_we_want_to_set,
70+
"https://loaddensity.readthedocs.io/en/latest/",
71+
"LoadDensity Doc"
6972
)
7073
)
7174
ui_we_want_to_set.load_density_help_menu.addAction(
@@ -75,7 +78,9 @@ def set_load_density_menu(ui_we_want_to_set: AutomationEditor):
7578
ui_we_want_to_set.open_load_density_github_action = QAction("Open LoadDensity GitHub")
7679
ui_we_want_to_set.open_load_density_github_action.triggered.connect(
7780
lambda: open_web_browser(
78-
"https://github.com/Intergration-Automation-Testing/LoadDensity"
81+
ui_we_want_to_set,
82+
"https://github.com/Intergration-Automation-Testing/LoadDensity",
83+
"LoadDensity GitHub"
7984
)
8085
)
8186
ui_we_want_to_set.load_density_help_menu.addAction(
@@ -92,10 +97,6 @@ def set_load_density_menu(ui_we_want_to_set: AutomationEditor):
9297
)
9398

9499

95-
def open_web_browser(url: str) -> None:
96-
webbrowser.open(url=url)
97-
98-
99100
def create_project() -> None:
100101
try:
101102
import je_load_density

automation_editor/automation_editor_ui/menu/mail_thunder_menu/build_mail_thunder_menu.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
from typing import TYPE_CHECKING
44

5+
from automation_editor.automation_editor_ui.menu.menu_utils import open_web_browser
6+
57
if TYPE_CHECKING:
68
from automation_editor.automation_editor_ui.editor_main.main_ui import AutomationEditor
79
import sys
8-
import webbrowser
910

1011
from PySide6.QtGui import QAction
1112

@@ -32,11 +33,25 @@ def set_mail_thunder_menu(ui_we_want_to_set: AutomationEditor):
3233
)
3334
# Help menu
3435
ui_we_want_to_set.mail_thunder_help_menu = ui_we_want_to_set.mail_thunder_menu.addMenu("HELP")
36+
# Open Doc
37+
ui_we_want_to_set.open_mail_thunder_doc_action = QAction("Open MailThunder Doc")
38+
ui_we_want_to_set.open_mail_thunder_doc_action.triggered.connect(
39+
lambda: open_web_browser(
40+
ui_we_want_to_set,
41+
"https://mailthunder.readthedocs.io/en/latest/",
42+
"MailThunder Doc"
43+
)
44+
)
45+
ui_we_want_to_set.mail_thunder_help_menu.addAction(
46+
ui_we_want_to_set.open_mail_thunder_doc_action
47+
)
3548
# Open Github
3649
ui_we_want_to_set.open_mail_thunder_github_action = QAction("Open MailThunder GitHub")
3750
ui_we_want_to_set.open_mail_thunder_github_action.triggered.connect(
3851
lambda: open_web_browser(
39-
"https://github.com/Integration-Automation/MailThunder"
52+
ui_we_want_to_set,
53+
"https://github.com/Integration-Automation/MailThunder",
54+
"MailThunder GitHub"
4055
)
4156
)
4257
ui_we_want_to_set.mail_thunder_help_menu.addAction(
@@ -53,10 +68,6 @@ def set_mail_thunder_menu(ui_we_want_to_set: AutomationEditor):
5368
)
5469

5570

56-
def open_web_browser(url: str) -> None:
57-
webbrowser.open(url=url)
58-
59-
6071
def create_project() -> None:
6172
try:
6273
import je_mail_thunder
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from __future__ import annotations
2+
3+
from typing import TYPE_CHECKING
4+
5+
from je_editor import JEBrowser
6+
7+
if TYPE_CHECKING:
8+
from automation_editor.automation_editor_ui.editor_main.main_ui import AutomationEditor
9+
10+
11+
def open_web_browser(
12+
automation_editor_instance: AutomationEditor, url: str, tab_name: str) -> None:
13+
automation_editor_instance.tab_widget.addTab(
14+
JEBrowser(start_url=url),
15+
f"{tab_name}{automation_editor_instance.tab_widget.count()}"
16+
)

automation_editor/automation_editor_ui/menu/web_runner_menu/build_webrunner_menu.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
from typing import TYPE_CHECKING
44

5+
from automation_editor.automation_editor_ui.menu.menu_utils import open_web_browser
6+
57
if TYPE_CHECKING:
68
from automation_editor.automation_editor_ui.editor_main.main_ui import AutomationEditor
79
import sys
8-
import webbrowser
910

1011
from PySide6.QtGui import QAction
1112

@@ -33,6 +34,7 @@ def set_web_runner_menu(ui_we_want_to_set: AutomationEditor):
3334
ui_we_want_to_set.run_web_runner_action_with_send = QAction("Run WebRunner With Send")
3435
ui_we_want_to_set.run_web_runner_action_with_send.triggered.connect(
3536
lambda: call_web_runner_test_with_send(
37+
ui_we_want_to_set
3638
)
3739
)
3840
ui_we_want_to_set.web_runner_run_menu.addAction(
@@ -63,7 +65,9 @@ def set_web_runner_menu(ui_we_want_to_set: AutomationEditor):
6365
ui_we_want_to_set.open_web_runner_doc_action = QAction("Open WebRunner Doc")
6466
ui_we_want_to_set.open_web_runner_doc_action.triggered.connect(
6567
lambda: open_web_browser(
66-
"https://webrunner.readthedocs.io/en/latest/"
68+
ui_we_want_to_set,
69+
"https://webrunner.readthedocs.io/en/latest/",
70+
"WebRunner Doc"
6771
)
6872
)
6973
ui_we_want_to_set.web_runner_help_menu.addAction(
@@ -73,7 +77,9 @@ def set_web_runner_menu(ui_we_want_to_set: AutomationEditor):
7377
ui_we_want_to_set.open_web_runner_github_action = QAction("Open WebRunner GitHub")
7478
ui_we_want_to_set.open_web_runner_github_action.triggered.connect(
7579
lambda: open_web_browser(
76-
"https://github.com/Intergration-Automation-Testing/WebRunner"
80+
ui_we_want_to_set,
81+
"https://github.com/Intergration-Automation-Testing/WebRunner",
82+
"WebRunner GitHub"
7783
)
7884
)
7985
ui_we_want_to_set.web_runner_help_menu.addAction(
@@ -90,10 +96,6 @@ def set_web_runner_menu(ui_we_want_to_set: AutomationEditor):
9096
)
9197

9298

93-
def open_web_browser(url: str) -> None:
94-
webbrowser.open(url=url)
95-
96-
9799
def create_project() -> None:
98100
try:
99101
import je_web_runner

automation_editor/automation_editor_ui/syntax/syntax_extend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
def syntax_extend_package(main_window: AutomationEditor) -> None:
2020
widget = main_window.tab_widget.currentWidget()
21-
if type(widget) is EditorWidget:
21+
if isinstance(widget, EditorWidget):
2222
for package in package_manager.syntax_check_list:
2323
text_char_format = QTextCharFormat()
2424
text_char_format.setForeground(QColor(255, 255, 0))

0 commit comments

Comments
 (0)