pdit 0.7.0__py3-none-any.whl → 0.7.0a1__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.
- pdit/exporter.py +4 -39
- {pdit-0.7.0.dist-info → pdit-0.7.0a1.dist-info}/METADATA +1 -1
- {pdit-0.7.0.dist-info → pdit-0.7.0a1.dist-info}/RECORD +7 -7
- {pdit-0.7.0.dist-info → pdit-0.7.0a1.dist-info}/WHEEL +0 -0
- {pdit-0.7.0.dist-info → pdit-0.7.0a1.dist-info}/entry_points.txt +0 -0
- {pdit-0.7.0.dist-info → pdit-0.7.0a1.dist-info}/licenses/LICENSE +0 -0
- {pdit-0.7.0.dist-info → pdit-0.7.0a1.dist-info}/top_level.txt +0 -0
pdit/exporter.py
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
"""Export functionality for pdit scripts."""
|
|
2
2
|
|
|
3
|
-
import asyncio
|
|
4
3
|
import json
|
|
5
4
|
from pathlib import Path
|
|
6
|
-
from
|
|
7
|
-
from typing import Any, Callable, Coroutine
|
|
5
|
+
from typing import Any
|
|
8
6
|
|
|
9
7
|
from .ipython_executor import IPythonExecutor
|
|
10
8
|
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
def execute_script(script_content: str, script_name: str) -> list[dict[str, Any]]:
|
|
13
11
|
"""Execute a script and return expressions in frontend format.
|
|
14
12
|
|
|
15
13
|
Args:
|
|
@@ -24,7 +22,7 @@ async def _execute_script_async(script_content: str, script_name: str) -> list[d
|
|
|
24
22
|
expression_id = 0
|
|
25
23
|
|
|
26
24
|
try:
|
|
27
|
-
|
|
25
|
+
for event in executor.execute_script(script_content, script_name=script_name):
|
|
28
26
|
# Skip the expressions list event
|
|
29
27
|
if event.get("type") == "expressions":
|
|
30
28
|
continue
|
|
@@ -42,44 +40,11 @@ async def _execute_script_async(script_content: str, script_name: str) -> list[d
|
|
|
42
40
|
})
|
|
43
41
|
expression_id += 1
|
|
44
42
|
finally:
|
|
45
|
-
|
|
43
|
+
executor.shutdown()
|
|
46
44
|
|
|
47
45
|
return expressions
|
|
48
46
|
|
|
49
47
|
|
|
50
|
-
def _run_async(
|
|
51
|
-
async_fn: Callable[..., Coroutine[Any, Any, Any]],
|
|
52
|
-
*args: Any,
|
|
53
|
-
**kwargs: Any,
|
|
54
|
-
) -> Any:
|
|
55
|
-
try:
|
|
56
|
-
asyncio.get_running_loop()
|
|
57
|
-
except RuntimeError:
|
|
58
|
-
return asyncio.run(async_fn(*args, **kwargs))
|
|
59
|
-
|
|
60
|
-
result: dict[str, Any] = {}
|
|
61
|
-
error: dict[str, BaseException] = {}
|
|
62
|
-
|
|
63
|
-
def runner() -> None:
|
|
64
|
-
try:
|
|
65
|
-
result["value"] = asyncio.run(async_fn(*args, **kwargs))
|
|
66
|
-
except BaseException as exc:
|
|
67
|
-
error["value"] = exc
|
|
68
|
-
|
|
69
|
-
thread = Thread(target=runner, daemon=True)
|
|
70
|
-
thread.start()
|
|
71
|
-
thread.join()
|
|
72
|
-
|
|
73
|
-
if "value" in error:
|
|
74
|
-
raise error["value"]
|
|
75
|
-
return result["value"]
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
def execute_script(script_content: str, script_name: str) -> list[dict[str, Any]]:
|
|
79
|
-
"""Execute a script and return expressions in frontend format."""
|
|
80
|
-
return _run_async(_execute_script_async, script_content, script_name)
|
|
81
|
-
|
|
82
|
-
|
|
83
48
|
def generate_html(script_content: str, expressions: list[dict[str, Any]]) -> str:
|
|
84
49
|
"""Generate self-contained HTML from script and execution results.
|
|
85
50
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
pdit/__init__.py,sha256=QpiMnN_x5G3QaeWMXQlCRUtCo35IEYZLPj-cz87WG_g,185
|
|
2
2
|
pdit/_demo.py,sha256=SMOGoiHBdMDq8pXRVK-uuTRFCFbRd47diUyRR8Y3wZY,2026
|
|
3
3
|
pdit/cli.py,sha256=3YkWz2Sg3-OszRssWkXbPEu3dDQAXMS8Z0c07bZ7gx8,9634
|
|
4
|
-
pdit/exporter.py,sha256=
|
|
4
|
+
pdit/exporter.py,sha256=i2emLqRQNPW92vFBTamLZyOhUTDU45_0QnOWG7PcIu8,2811
|
|
5
5
|
pdit/file_watcher.py,sha256=1WlqKWjLCdgMZLdN836MEeWTisGCtZmvgRdOFN-jns8,5200
|
|
6
6
|
pdit/ipython_executor.py,sha256=KMBFg4Xl5M2iiV8kkpSFJUURv9XjKYl5Nf1y5HzivxQ,17244
|
|
7
7
|
pdit/server.py,sha256=V5uFMqPle7JGeMHWRjniiN0m1z7rK-pOBZ1tiPNPU5E,14566
|
|
@@ -9,9 +9,9 @@ pdit/_static/export.html,sha256=ITKX3MKoWQYoR8EqkMTfsEYjpNWfhVVi-Mdmw_jpxoY,3323
|
|
|
9
9
|
pdit/_static/index.html,sha256=iDl5_lp8ailmLfeKWcGvEDY_wI6_hS5uMnDGRGEu1-o,450
|
|
10
10
|
pdit/_static/assets/index-WLaVrqLo.js,sha256=6g0aNVXaBOwAISafLYvgP-0bpEVL-YuQs026ebsFE4w,815277
|
|
11
11
|
pdit/_static/assets/index-rS96z8hq.css,sha256=0EMq2r0to1VxGznyp18tWCd97_sSZhGVC3YF7QdBXEU,22855
|
|
12
|
-
pdit-0.7.
|
|
13
|
-
pdit-0.7.
|
|
14
|
-
pdit-0.7.
|
|
15
|
-
pdit-0.7.
|
|
16
|
-
pdit-0.7.
|
|
17
|
-
pdit-0.7.
|
|
12
|
+
pdit-0.7.0a1.dist-info/licenses/LICENSE,sha256=Y9tvBURRu-1aHUHY-tnbsDpPBTRYKWpIInVmaoOUkME,1071
|
|
13
|
+
pdit-0.7.0a1.dist-info/METADATA,sha256=GgBtM98v5nZut490VHAKH928rXK1ELe9OfKtkcRvyp0,1861
|
|
14
|
+
pdit-0.7.0a1.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
15
|
+
pdit-0.7.0a1.dist-info/entry_points.txt,sha256=n9I4wGD7M0NQrPWJcTWOsJAzeS6bQJbTnUP8C3Sl-iY,39
|
|
16
|
+
pdit-0.7.0a1.dist-info/top_level.txt,sha256=wk6vel1ecJS4EZZ3U6Xue9OwDq-Tw8Pbvq_TRQz9eIQ,5
|
|
17
|
+
pdit-0.7.0a1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|