pycoze 0.1.281__py3-none-any.whl → 0.1.283__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pycoze/api/lib/tab_cls.py +73 -69
- {pycoze-0.1.281.dist-info → pycoze-0.1.283.dist-info}/METADATA +1 -1
- {pycoze-0.1.281.dist-info → pycoze-0.1.283.dist-info}/RECORD +6 -6
- {pycoze-0.1.281.dist-info → pycoze-0.1.283.dist-info}/LICENSE +0 -0
- {pycoze-0.1.281.dist-info → pycoze-0.1.283.dist-info}/WHEEL +0 -0
- {pycoze-0.1.281.dist-info → pycoze-0.1.283.dist-info}/top_level.txt +0 -0
pycoze/api/lib/tab_cls.py
CHANGED
@@ -1,69 +1,73 @@
|
|
1
|
-
import os
|
2
|
-
from .view import ViewCls, WorkflowCls
|
3
|
-
import time
|
4
|
-
from pycoze import utils
|
5
|
-
import json
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
def
|
38
|
-
|
39
|
-
return
|
40
|
-
|
41
|
-
def
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
1
|
+
import os
|
2
|
+
from .view import ViewCls, WorkflowCls
|
3
|
+
import time
|
4
|
+
from pycoze import utils
|
5
|
+
import json
|
6
|
+
from typing import Union
|
7
|
+
|
8
|
+
|
9
|
+
socket = utils.socket
|
10
|
+
params = utils.params
|
11
|
+
|
12
|
+
|
13
|
+
class TabCls:
|
14
|
+
def open_workflow(self, workflow_id: str, wait_for_open=True) -> WorkflowCls:
|
15
|
+
item_path = os.path.join(
|
16
|
+
params["workspacePath"], "User", "Local", "workflow", workflow_id
|
17
|
+
)
|
18
|
+
if not os.path.isabs(item_path):
|
19
|
+
item_path = os.path.abspath(item_path)
|
20
|
+
info_path = os.path.join(item_path, "info.json")
|
21
|
+
with open(info_path, "r", encoding="utf-8") as f:
|
22
|
+
info = json.load(f)
|
23
|
+
location = ["LocalWorkflow", item_path]
|
24
|
+
socket.post("add-tab", {"location": location, "name": info["name"]})
|
25
|
+
if wait_for_open:
|
26
|
+
self._wait_for_tab_open(location)
|
27
|
+
return WorkflowCls(location)
|
28
|
+
|
29
|
+
def _wait_for_tab_open(self, location: Union[list[str], ViewCls]):
|
30
|
+
times = 0
|
31
|
+
while not self.is_tab_open(location):
|
32
|
+
time.sleep(0.01)
|
33
|
+
times += 1
|
34
|
+
if times > 1000:
|
35
|
+
raise Exception("Tab open timeout")
|
36
|
+
|
37
|
+
def get_active(self) -> list[str]:
|
38
|
+
result = socket.post_and_recv_result("get-active-tab", {})
|
39
|
+
return result
|
40
|
+
|
41
|
+
def get_all(self) -> list[list[str]]:
|
42
|
+
results = socket.post_and_recv_result("get-all-tabs", {})
|
43
|
+
return results
|
44
|
+
|
45
|
+
def close_tab(self, location: Union[list[str], ViewCls]):
|
46
|
+
if isinstance(location, ViewCls):
|
47
|
+
location = location.location
|
48
|
+
self.wait_for_tab_open(location)
|
49
|
+
socket.post("close-tab", {"location": location})
|
50
|
+
|
51
|
+
def switch_tab(self, location: Union[list[str], ViewCls]):
|
52
|
+
if isinstance(location, ViewCls):
|
53
|
+
location = location.location
|
54
|
+
self.wait_for_tab_open(location)
|
55
|
+
socket.post("switchTab", {"location": location})
|
56
|
+
|
57
|
+
def is_tab_open(self, location: Union[list[str], ViewCls]):
|
58
|
+
if isinstance(location, ViewCls):
|
59
|
+
location = location.location
|
60
|
+
result = socket.post_and_recv_result("is-tab-open", {"location": location})
|
61
|
+
return result
|
62
|
+
|
63
|
+
def pin_tab(self, location: Union[list[str], ViewCls]):
|
64
|
+
if isinstance(location, ViewCls):
|
65
|
+
location = location.location
|
66
|
+
self.wait_for_tab_open(location)
|
67
|
+
socket.post("pin-tab", {"location": location})
|
68
|
+
|
69
|
+
def unpin_tab(self, location: Union[list[str], ViewCls]):
|
70
|
+
if isinstance(location, ViewCls):
|
71
|
+
location = location.location
|
72
|
+
self.wait_for_tab_open(location)
|
73
|
+
socket.post("unpin-tab", {"location": location})
|
@@ -7,7 +7,7 @@ pycoze/ai/llm/text_to_image_prompt.py,sha256=0bx2C_YRvjAo7iphHGp1-pmGKsKqwur7dM0
|
|
7
7
|
pycoze/ai/llm/think.py,sha256=sUgTBdGzcZtL3r-Wx8M3lDuVUmDVz8g3qC0VU8uiKAI,5143
|
8
8
|
pycoze/api/__init__.py,sha256=GGRRRPop0ZxdXe5JRhg2XvHITGIWfNcHA25opJZ0f1w,313
|
9
9
|
pycoze/api/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
|
-
pycoze/api/lib/tab_cls.py,sha256=
|
10
|
+
pycoze/api/lib/tab_cls.py,sha256=lD2Uvylzi-zsHj-27YI1mS4ggbIGtCi3vypvGvY48gM,2619
|
11
11
|
pycoze/api/lib/view.py,sha256=_PIpTfeuTPPlMDKshMGsqFQYMq7ZiO4Hg5XwHwDoU60,7357
|
12
12
|
pycoze/api/lib/window_cls.py,sha256=Yezy-SR_EwVtUjrgXnHRC69WGgXVaXeJHjaxn09Ophg,1737
|
13
13
|
pycoze/bot/__init__.py,sha256=JxnRoCCqx_LFyVb3pLu0qYCsH8ZLuAaMXAtvVUuCHuE,78
|
@@ -35,8 +35,8 @@ pycoze/utils/arg.py,sha256=jop1tBfe5hYkHW1NSpCeaZBEznkgguBscj_7M2dWfrs,503
|
|
35
35
|
pycoze/utils/env.py,sha256=5pWlXfM1F5ZU9hhv1rHlDEanjEW5wf0nbyez9bNRqqA,559
|
36
36
|
pycoze/utils/socket.py,sha256=bZbFFRH4mfThzRqt55BAAGQ6eICx_ja4x8UGGrUdAm8,2428
|
37
37
|
pycoze/utils/text_or_file.py,sha256=gpxZVWt2DW6YiEg_MnMuwg36VNf3TX383QD_1oZNB0Y,551
|
38
|
-
pycoze-0.1.
|
39
|
-
pycoze-0.1.
|
40
|
-
pycoze-0.1.
|
41
|
-
pycoze-0.1.
|
42
|
-
pycoze-0.1.
|
38
|
+
pycoze-0.1.283.dist-info/LICENSE,sha256=QStd_Qsd0-kAam_-sOesCIp_uKrGWeoKwt9M49NVkNU,1090
|
39
|
+
pycoze-0.1.283.dist-info/METADATA,sha256=mPKe547GwDHZgsiGSXB726lGwmQsrEqGU9yqetxNHQk,755
|
40
|
+
pycoze-0.1.283.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
|
41
|
+
pycoze-0.1.283.dist-info/top_level.txt,sha256=76dPeDhKvOCleL3ZC5gl1-y4vdS1tT_U1hxWVAn7sFo,7
|
42
|
+
pycoze-0.1.283.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|