quantalogic 0.61.2__py3-none-any.whl → 0.80__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.
- quantalogic/agent.py +0 -1
- quantalogic/codeact/TODO.md +14 -0
- quantalogic/codeact/agent.py +400 -421
- quantalogic/codeact/cli.py +42 -224
- quantalogic/codeact/cli_commands/__init__.py +0 -0
- quantalogic/codeact/cli_commands/create_toolbox.py +45 -0
- quantalogic/codeact/cli_commands/install_toolbox.py +20 -0
- quantalogic/codeact/cli_commands/list_executor.py +15 -0
- quantalogic/codeact/cli_commands/list_reasoners.py +15 -0
- quantalogic/codeact/cli_commands/list_toolboxes.py +47 -0
- quantalogic/codeact/cli_commands/task.py +215 -0
- quantalogic/codeact/cli_commands/tool_info.py +24 -0
- quantalogic/codeact/cli_commands/uninstall_toolbox.py +43 -0
- quantalogic/codeact/config.yaml +21 -0
- quantalogic/codeact/constants.py +1 -1
- quantalogic/codeact/events.py +12 -5
- quantalogic/codeact/examples/README.md +342 -0
- quantalogic/codeact/examples/agent_sample.yaml +29 -0
- quantalogic/codeact/executor.py +186 -0
- quantalogic/codeact/history_manager.py +94 -0
- quantalogic/codeact/llm_util.py +3 -22
- quantalogic/codeact/plugin_manager.py +92 -0
- quantalogic/codeact/prompts/generate_action.j2 +65 -14
- quantalogic/codeact/prompts/generate_program.j2 +32 -19
- quantalogic/codeact/react_agent.py +318 -0
- quantalogic/codeact/reasoner.py +185 -0
- quantalogic/codeact/templates/toolbox/README.md.j2 +10 -0
- quantalogic/codeact/templates/toolbox/pyproject.toml.j2 +16 -0
- quantalogic/codeact/templates/toolbox/tools.py.j2 +6 -0
- quantalogic/codeact/templates.py +7 -0
- quantalogic/codeact/tools_manager.py +242 -119
- quantalogic/codeact/utils.py +16 -89
- quantalogic/codeact/xml_utils.py +126 -0
- quantalogic/flow/flow.py +151 -41
- quantalogic/flow/flow_extractor.py +61 -1
- quantalogic/flow/flow_generator.py +34 -6
- quantalogic/flow/flow_manager.py +64 -25
- quantalogic/flow/flow_manager_schema.py +32 -0
- quantalogic/tools/action_gen.py +1 -1
- quantalogic/tools/action_gen_safe.py +340 -0
- quantalogic/tools/tool.py +531 -109
- quantalogic/tools/write_file_tool.py +7 -8
- {quantalogic-0.61.2.dist-info → quantalogic-0.80.dist-info}/METADATA +3 -2
- {quantalogic-0.61.2.dist-info → quantalogic-0.80.dist-info}/RECORD +47 -42
- {quantalogic-0.61.2.dist-info → quantalogic-0.80.dist-info}/WHEEL +1 -1
- quantalogic-0.80.dist-info/entry_points.txt +3 -0
- quantalogic/python_interpreter/__init__.py +0 -23
- quantalogic/python_interpreter/assignment_visitors.py +0 -63
- quantalogic/python_interpreter/base_visitors.py +0 -20
- quantalogic/python_interpreter/class_visitors.py +0 -22
- quantalogic/python_interpreter/comprehension_visitors.py +0 -172
- quantalogic/python_interpreter/context_visitors.py +0 -59
- quantalogic/python_interpreter/control_flow_visitors.py +0 -88
- quantalogic/python_interpreter/exception_visitors.py +0 -109
- quantalogic/python_interpreter/exceptions.py +0 -39
- quantalogic/python_interpreter/execution.py +0 -202
- quantalogic/python_interpreter/function_utils.py +0 -386
- quantalogic/python_interpreter/function_visitors.py +0 -209
- quantalogic/python_interpreter/import_visitors.py +0 -28
- quantalogic/python_interpreter/interpreter_core.py +0 -358
- quantalogic/python_interpreter/literal_visitors.py +0 -74
- quantalogic/python_interpreter/misc_visitors.py +0 -148
- quantalogic/python_interpreter/operator_visitors.py +0 -108
- quantalogic/python_interpreter/scope.py +0 -10
- quantalogic/python_interpreter/visit_handlers.py +0 -110
- quantalogic-0.61.2.dist-info/entry_points.txt +0 -6
- {quantalogic-0.61.2.dist-info → quantalogic-0.80.dist-info}/LICENSE +0 -0
@@ -10,10 +10,10 @@ from quantalogic.tools.tool import Tool, ToolArgument
|
|
10
10
|
|
11
11
|
|
12
12
|
class WriteFileTool(Tool):
|
13
|
-
"""Tool for writing a text file
|
13
|
+
"""Tool for writing a text file to a specified path."""
|
14
14
|
|
15
15
|
name: str = "write_file_tool"
|
16
|
-
description: str = "Writes a file
|
16
|
+
description: str = "Writes a file to the specified path. The tool will fail if the file already exists when not used in append mode."
|
17
17
|
need_validation: bool = True
|
18
18
|
|
19
19
|
disable_ensure_tmp_path: bool = Field(default=False)
|
@@ -25,7 +25,7 @@ class WriteFileTool(Tool):
|
|
25
25
|
arg_type="string",
|
26
26
|
description="The path to the file to write. By default, paths will be forced to /tmp directory unless disable_ensure_tmp_path is enabled. Can include subdirectories.",
|
27
27
|
required=True,
|
28
|
-
example="/tmp/myfile.txt or myfile.txt",
|
28
|
+
example="/tmp/myfile.txt or ./myfile.txt",
|
29
29
|
),
|
30
30
|
ToolArgument(
|
31
31
|
name="content",
|
@@ -107,11 +107,8 @@ class WriteFileTool(Tool):
|
|
107
107
|
# Ensure path is in /tmp and normalize it
|
108
108
|
if not self.disable_ensure_tmp_path:
|
109
109
|
file_path = self._ensure_tmp_path(file_path)
|
110
|
-
|
111
|
-
|
112
|
-
parent_dir = os.path.dirname(file_path)
|
113
|
-
if parent_dir.startswith("/tmp/"):
|
114
|
-
os.makedirs(parent_dir, exist_ok=True)
|
110
|
+
if not file_path.startswith('/tmp/'):
|
111
|
+
raise ValueError('File path must be under /tmp when disable_ensure_tmp_path is False')
|
115
112
|
|
116
113
|
# Determine file write mode based on append_mode
|
117
114
|
mode = "a" if append_mode_bool else "w"
|
@@ -122,6 +119,8 @@ class WriteFileTool(Tool):
|
|
122
119
|
f"File {file_path} already exists. Set append_mode=True to append or overwrite=True to overwrite."
|
123
120
|
)
|
124
121
|
|
122
|
+
os.makedirs(os.path.dirname(file_path), exist_ok=True)
|
123
|
+
|
125
124
|
with open(file_path, mode, encoding="utf-8") as f:
|
126
125
|
f.write(content)
|
127
126
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.3
|
2
2
|
Name: quantalogic
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.80
|
4
4
|
Summary: QuantaLogic ReAct Agents
|
5
5
|
Author: Raphaël MANSUY
|
6
6
|
Author-email: raphael.mansuy@gmail.com
|
@@ -34,6 +34,7 @@ Requires-Dist: psutil (>=7.0.0,<8.0.0)
|
|
34
34
|
Requires-Dist: pydantic (>=2.10.4,<3.0.0)
|
35
35
|
Requires-Dist: pytest-asyncio (>=0.25.3,<0.26.0)
|
36
36
|
Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
|
37
|
+
Requires-Dist: quantalogic-pythonbox (>=0.9.7,<0.10.0)
|
37
38
|
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
38
39
|
Requires-Dist: rich (>=13.9.4,<14.0.0)
|
39
40
|
Requires-Dist: serpapi (>=0.1.5,<0.2.0)
|
@@ -1,19 +1,42 @@
|
|
1
1
|
quantalogic/__init__.py,sha256=qFbvfHOd_chAu536pH816E3uo6CdyAgXCpQOwMXXVnY,1076
|
2
|
-
quantalogic/agent.py,sha256=
|
2
|
+
quantalogic/agent.py,sha256=y0ncyZCL9VPRFD6tLNOCCo3GD6okGEoFYjUfVtJHn-g,75060
|
3
3
|
quantalogic/agent_config.py,sha256=HNXHmu3BiT4q9i-L2wJKUh6PuiZ_ryTNaB7ga24kaJo,8334
|
4
4
|
quantalogic/agent_factory.py,sha256=soActorasOqs5g6NmlyeEjRYbJceIGGg7wuUS-vA898,6878
|
5
|
+
quantalogic/codeact/TODO.md,sha256=TfKjRGUz-8q0pLrLATxleMW-E8pw4sOJP0nu82QlpMA,335
|
5
6
|
quantalogic/codeact/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
quantalogic/codeact/agent.py,sha256=
|
7
|
-
quantalogic/codeact/cli.py,sha256=
|
8
|
-
quantalogic/codeact/
|
9
|
-
quantalogic/codeact/
|
10
|
-
quantalogic/codeact/
|
7
|
+
quantalogic/codeact/agent.py,sha256=WRDQ2FXxGXoECcMU6zR8yHUC4JEB00nGAypyyslZHBw,24092
|
8
|
+
quantalogic/codeact/cli.py,sha256=jIpxaLmEjFjl9lER4-ccNDn4mranKRpwA6oGihp1njY,2193
|
9
|
+
quantalogic/codeact/cli_commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
10
|
+
quantalogic/codeact/cli_commands/create_toolbox.py,sha256=Z__5XbcN6h4Z67IkHRh09ZaJLKrMxjPa_3oS5QHYI-Y,1680
|
11
|
+
quantalogic/codeact/cli_commands/install_toolbox.py,sha256=-ZGT2RSpG_TmQGzglHPgd3F9zCPBIibmHenTXMKSLfI,643
|
12
|
+
quantalogic/codeact/cli_commands/list_executor.py,sha256=Dt09zerX-2W8dhxKJxfUvpmLanTj4YmPBUatFLucGMs,418
|
13
|
+
quantalogic/codeact/cli_commands/list_reasoners.py,sha256=CFLrXOgfapN0o8HvhkZmrT2tGhmsC7RMfSGdouV29mE,418
|
14
|
+
quantalogic/codeact/cli_commands/list_toolboxes.py,sha256=3z_UHNdbVniQcpm6k9i-D6bsMspmmL4oCZZtv4ueKmw,1837
|
15
|
+
quantalogic/codeact/cli_commands/task.py,sha256=K48Ne52dq_J8ydwX6diyyAB9oxbIxdBs4dFbwGeGyVo,9583
|
16
|
+
quantalogic/codeact/cli_commands/tool_info.py,sha256=6YAxMvMsuvs72rVeJ1UqvUOxjR40MOWvClLIMNtUNrk,977
|
17
|
+
quantalogic/codeact/cli_commands/uninstall_toolbox.py,sha256=Spf7Jou6PIzvSDEDnShivTunMpxUK2sv2b2NgqRNXqc,1833
|
18
|
+
quantalogic/codeact/config.yaml,sha256=-L1P3Du2pGHRGsMf-cgGM46H2dUHE8UpZheFBkpakWc,357
|
19
|
+
quantalogic/codeact/constants.py,sha256=izE67Yie2QO6qnpV2mQSrlqKOprkf_0_1P7cOBHqURk,244
|
20
|
+
quantalogic/codeact/events.py,sha256=fjVQEDpf-8tAmPQpnlX_kj9UtmW3A-Si3iBVEeFY0Bs,1622
|
21
|
+
quantalogic/codeact/examples/README.md,sha256=RvwhCaaCiBj13w7rFg3AtLL-SqnYZkau1W5Vq7QHsm4,9286
|
22
|
+
quantalogic/codeact/examples/agent_sample.yaml,sha256=K2bo48rgI7DxFzWgJiN5NrfIdSTTDqqJx7_ZzpnSU2Q,672
|
23
|
+
quantalogic/codeact/executor.py,sha256=tbYJgezlikfkedpiRnzNxxt4T6yaPca-uaoSRuTbyAM,8166
|
24
|
+
quantalogic/codeact/history_manager.py,sha256=eKbE9vYcZ7PC1zXlPqYrFXq62H2ihYDJg6fXZ-WUuXw,3920
|
25
|
+
quantalogic/codeact/llm_util.py,sha256=LgnCZXSkwB2QEOfXFmJLDyFHnRtFKCrIN31rv_vCAz8,1849
|
26
|
+
quantalogic/codeact/plugin_manager.py,sha256=l-Bg8JeRDtjhsWAYINAPc_NvNBkXnzLSawzdnoTJsV8,3697
|
11
27
|
quantalogic/codeact/prompts/error_format.j2,sha256=_8fNWxDr3U1Fq8SdzwRIBNsNG1WvPL9IAaos9Enf1C0,258
|
12
|
-
quantalogic/codeact/prompts/generate_action.j2,sha256=
|
13
|
-
quantalogic/codeact/prompts/generate_program.j2,sha256=
|
28
|
+
quantalogic/codeact/prompts/generate_action.j2,sha256=WD2SZNrYlmzCHhkYiOaQE9zRw8qvl_Hf-budABpSIKU,4934
|
29
|
+
quantalogic/codeact/prompts/generate_program.j2,sha256=YO-ubsk87ki60-4BNxYOd-rEDxwfd0qWrSHGC79HxNY,3234
|
14
30
|
quantalogic/codeact/prompts/response_format.j2,sha256=TwO43dEG-3justNigpX4yyzGR1TGS3YDlpJQq8Z5Vf4,355
|
15
|
-
quantalogic/codeact/
|
16
|
-
quantalogic/codeact/
|
31
|
+
quantalogic/codeact/react_agent.py,sha256=OyUF-6iShASMn0bkk5btMwpP15BPyLwgzXxjws18bxA,14020
|
32
|
+
quantalogic/codeact/reasoner.py,sha256=qZ0Td7PFEaZONg0pVzM6dbCEQU-rEk4rCP4jUAn33yM,6827
|
33
|
+
quantalogic/codeact/templates/toolbox/README.md.j2,sha256=gBkMp806acce7rIkEFoqgc8mgJqIpBTpQ64B96gzhPo,94
|
34
|
+
quantalogic/codeact/templates/toolbox/pyproject.toml.j2,sha256=6JkxVjsq0wK-f5HtgifYYWcDHZ4kF6ww6WYMpE5Zh0k,388
|
35
|
+
quantalogic/codeact/templates/toolbox/tools.py.j2,sha256=G7gOBYlTqqOIYf22eIYVZr5qvYO2gxv2Cu4V6BpniSM,176
|
36
|
+
quantalogic/codeact/templates.py,sha256=bpMOKfN512CT0dmAT6trMmlrk0qifLeTs3s5N4G4vL8,327
|
37
|
+
quantalogic/codeact/tools_manager.py,sha256=1WrNWWYiRKFY8tjw5MlIPpyTsvjftMDg8dsNcu9aSZw,11684
|
38
|
+
quantalogic/codeact/utils.py,sha256=qkxIj9-uOu988I-4J7rVnpANs9nhQ6a44c4yenflva8,2295
|
39
|
+
quantalogic/codeact/xml_utils.py,sha256=RgJfjw-RhCK2LAqI-7FeP2bIqhanUlMDsbici9uKDvY,5584
|
17
40
|
quantalogic/coding_agent.py,sha256=WFfabRwwPZFV3Pw3seLKpSrFE9Li4pz8Z8mCdsUIDi8,5532
|
18
41
|
quantalogic/config.py,sha256=bmPI2rvQ9M8Zdl1H7K588JgJdnkxSE0L5_i5aBqsagA,564
|
19
42
|
quantalogic/console_print_events.py,sha256=yDtfOr7s5r_gLTgwkl_XoKSkUqNRZhqqq4hwR_oJsUw,2050
|
@@ -22,11 +45,11 @@ quantalogic/create_custom_agent.py,sha256=g9qh6w436wkiOYVii6f3SPRRY0wyPQ_bL07WnD
|
|
22
45
|
quantalogic/docs_cli.py,sha256=Ie6NwKQuxLKwVQ-cjhFMCttXeiHDjGhNY4hSmMtc0Qg,1664
|
23
46
|
quantalogic/event_emitter.py,sha256=wxzXrNhGiXAaa4EX7qTZEa81i3Mn4JKaU_T6E05QclE,16805
|
24
47
|
quantalogic/flow/__init__.py,sha256=MD5FAdD6jnVnTPMIOmToKjFxHBQvLmOCT0VeaWhASBc,1295
|
25
|
-
quantalogic/flow/flow.py,sha256=
|
26
|
-
quantalogic/flow/flow_extractor.py,sha256=
|
27
|
-
quantalogic/flow/flow_generator.py,sha256=
|
28
|
-
quantalogic/flow/flow_manager.py,sha256=
|
29
|
-
quantalogic/flow/flow_manager_schema.py,sha256=
|
48
|
+
quantalogic/flow/flow.py,sha256=4430Fzhsua-0SLtnf3zEsc9WXdJW2JBwgp1MfkZpCb4,46374
|
49
|
+
quantalogic/flow/flow_extractor.py,sha256=BkG2_XRnHtgOsH1RocunN-O2Z821ApzfcwR6f3HsFi0,36954
|
50
|
+
quantalogic/flow/flow_generator.py,sha256=pAGGo99hq5VeAMAcoCnVjXX2ziJJ1jWKBLUPKJmWOW8,17368
|
51
|
+
quantalogic/flow/flow_manager.py,sha256=orztXcxDCKZ0p7SUX2p8V4_HvKOba-ufX5MfuW9p8xs,31523
|
52
|
+
quantalogic/flow/flow_manager_schema.py,sha256=0G6Oojuo_NacK0TKrNyB6DKkkTxmOQfBvh3hhVdAlqU,11539
|
30
53
|
quantalogic/flow/flow_mermaid.py,sha256=TvQyobLK6Idg5q0rQH1Vr_XmuovwxbFKsdZaIxEJqwY,16242
|
31
54
|
quantalogic/flow/flow_validator.py,sha256=6T4XUPjiHX_oKQVY_dXmRK8aICHnvQCKcyXAaomXtWY,23581
|
32
55
|
quantalogic/flow/flow_yaml.linkedin.md,sha256=OH1Hoij5ijRZqDju7aaP2GbbTvOcPotBlkaBMajc4UM,1040
|
@@ -57,25 +80,6 @@ quantalogic/prompts/task_summary_prompt.j2,sha256=fcjV96nqi6jsfR8l6uyep20rCaOi-z
|
|
57
80
|
quantalogic/prompts/tools_prompt.j2,sha256=ZjvTAZtAk-FmzDb1QuyDJg1hzo-FqayQ7wN_ytHAi2s,385
|
58
81
|
quantalogic/prompts/variables_prompt.j2,sha256=N3OsMbzy3PfEUqYZVF_34wVidhh2ghVToSgdRCv2qgM,231
|
59
82
|
quantalogic/prompts.py,sha256=zqmyosq4hdYpzHI-FG0m5CKV2wQnjgyMJf6Vo1ZaLW4,1982
|
60
|
-
quantalogic/python_interpreter/__init__.py,sha256=cNYxH9jy5QEAPZo44zmJzy3Kci14e0lL2h20Cbrs7RQ,675
|
61
|
-
quantalogic/python_interpreter/assignment_visitors.py,sha256=t6ttdYuwjcz8VtqJS5vMaaUUG6GbEhoNmnNDUj8dZiI,2771
|
62
|
-
quantalogic/python_interpreter/base_visitors.py,sha256=aD1pc3DbdlPdjQ3yJTYhBqNpN6tant7NOHXShts8coo,765
|
63
|
-
quantalogic/python_interpreter/class_visitors.py,sha256=FUgBVg_TmpAdLdLlYlPnruSm8iViijW3gTBQveJjkpI,862
|
64
|
-
quantalogic/python_interpreter/comprehension_visitors.py,sha256=AdPn047QUeoG5D1VD4wU2JuXS2KBTwLOIGbApmx9s7A,8468
|
65
|
-
quantalogic/python_interpreter/context_visitors.py,sha256=_4-Xfk0wzsla2rSIJZYEyYK4yIK7yRZWX6-HNBFSWTs,2137
|
66
|
-
quantalogic/python_interpreter/control_flow_visitors.py,sha256=trJ0Led1pPWKyseQF7BbIF5LFopkOiRDSVHz9Hi7-hI,3662
|
67
|
-
quantalogic/python_interpreter/exception_visitors.py,sha256=dbRuk2CaEZN-tYrzcRxZQh_UdLfpcW7wwrG8iQoGeE8,4571
|
68
|
-
quantalogic/python_interpreter/exceptions.py,sha256=mL4G9a0PZrvW_hAjkweMohvN8ryZsZOiIOolZUDSq9Y,1296
|
69
|
-
quantalogic/python_interpreter/execution.py,sha256=bggzv-GMnFe0Pkt00T4IlPUnDMsuqcHO1Qo0Wq6rEbs,8420
|
70
|
-
quantalogic/python_interpreter/function_utils.py,sha256=1LCEqCDt0p0uBTeC6rcre84r_j06jc6HuWLZ5Fc8m8M,18133
|
71
|
-
quantalogic/python_interpreter/function_visitors.py,sha256=WcGBWXZ_A7vekkrejL2XTuVPyqsKymK4svJr6-kR-OI,11317
|
72
|
-
quantalogic/python_interpreter/import_visitors.py,sha256=AgqFM8SO1wuJluDRsDGBwm-FQ5K374pQrXgbXXEBgPI,1331
|
73
|
-
quantalogic/python_interpreter/interpreter_core.py,sha256=PV_XFx0xhUG9ACvhz3FGat2FSaXK3C031HjRizHbox0,16646
|
74
|
-
quantalogic/python_interpreter/literal_visitors.py,sha256=TX9-02rn093OFTDvKkhp0PbTsXqIU1voBfbxs-TXfu0,3715
|
75
|
-
quantalogic/python_interpreter/misc_visitors.py,sha256=_olOaGD04icqKDqeEFUPIY5Nq0cH5pdGkq-8T6xbilM,6758
|
76
|
-
quantalogic/python_interpreter/operator_visitors.py,sha256=WTf4EfwE88lMoTKjuL8UBNpbwJ8Z6DTdrwvVffVw-Ic,4048
|
77
|
-
quantalogic/python_interpreter/scope.py,sha256=HSSbtDAMeDbE5LjSckTHvFlhcOUGv8UzxpI4NgUbp5U,257
|
78
|
-
quantalogic/python_interpreter/visit_handlers.py,sha256=dGh7BxwGArnBnmwxVzpV6l_uXQ5J6esUm2xKtXne30M,2610
|
79
83
|
quantalogic/quantlitellm.py,sha256=nf-awyOxP0ANoAPGHNvHfdLu8gNn65L39gl7x4saIQc,5550
|
80
84
|
quantalogic/search_agent.py,sha256=tr0cwscJ4wu_G1aumjFyvGHQ0eQv5OL5sxj17s6Ocls,2470
|
81
85
|
quantalogic/server/__init__.py,sha256=8sz_PYAUCrkM6JM5EAUeIzNM4NPW6j6UT72JVkc21WQ,91
|
@@ -90,7 +94,8 @@ quantalogic/task_file_reader.py,sha256=oPcB4vTxJ__Y8o7VVABIPOkVw3tGDMdQYwdK27PER
|
|
90
94
|
quantalogic/task_runner.py,sha256=NB7TqNuwCstCAsTkjGcJSQRapNk8-iXe7d_2qf-fs1s,15815
|
91
95
|
quantalogic/tool_manager.py,sha256=vNA7aBKgdU3wpw_goom6i9rg_64pNZapNxvg4cUhhCI,6983
|
92
96
|
quantalogic/tools/__init__.py,sha256=NU_M6VYYaAbSUtb2Qdu1lsYaDh0G3f_8jnrZTsBD0eY,2390
|
93
|
-
quantalogic/tools/action_gen.py,sha256=
|
97
|
+
quantalogic/tools/action_gen.py,sha256=7vnmyYMGecClPNuIYZjFTnWmVO3DDs2Ur2vZOGNG3KI,15590
|
98
|
+
quantalogic/tools/action_gen_safe.py,sha256=7doUtPnV9oxBc02N_N-xcMxmfT9Nd6gHfkNU7MtwVUk,13996
|
94
99
|
quantalogic/tools/agent_tool.py,sha256=MXCXxWHRch7VK4UWhtRP1jeI8Np9Ne2CUGo8vm1oZiM,3064
|
95
100
|
quantalogic/tools/composio/__init__.py,sha256=Yo9ygNx0qQILVhIfRgqpO8fgnCgp5WoZMd3Hm5D20GY,429
|
96
101
|
quantalogic/tools/composio/composio.py,sha256=icVHA_Scr1pViBhahGGBGBRBl9JSB3hGSqpgQzAIUH8,17627
|
@@ -173,7 +178,7 @@ quantalogic/tools/serpapi_search_tool.py,sha256=sX-Noch77kGP2XiwislPNFyy3_4TH6Tw
|
|
173
178
|
quantalogic/tools/sql_query_tool.py,sha256=jEDZLlxOsB2bzsWlEqsqvTKiyovnRuk0XvgtwW7-WSQ,6055
|
174
179
|
quantalogic/tools/task_complete_tool.py,sha256=L8tuyVoN07Q2hOsxx17JTW0C5Jd_N-C0i_0PtCUQUKU,929
|
175
180
|
quantalogic/tools/terminal_capture_tool.py,sha256=I3Ik9JSgHUPb5eV7ArZv9PISofkWWLh_7fCqX4RJRAg,10567
|
176
|
-
quantalogic/tools/tool.py,sha256
|
181
|
+
quantalogic/tools/tool.py,sha256=-IEfQzXT5t38GwEB3xjlcsmKCmDnMgfYjn97tpQg2DI,37678
|
177
182
|
quantalogic/tools/unified_diff_tool.py,sha256=o7OiYnCM5MjbPlQTpB2OmkMQRI9zjdToQmgVkhiTvOI,14148
|
178
183
|
quantalogic/tools/utilities/__init__.py,sha256=cOsQLYzJDnTY7mUjYaMSF_jmb5kez34MQc9xCWxm2NE,733
|
179
184
|
quantalogic/tools/utilities/csv_processor_tool.py,sha256=Mu_EPVj6iYAclNaVX_vbkekxcNwPYwy7dW1SCY22EwY,9023
|
@@ -188,7 +193,7 @@ quantalogic/tools/utils/generate_database_report.py,sha256=IU_XGTDNXfJXxzpHR1F4c
|
|
188
193
|
quantalogic/tools/web_navigation/__init__.py,sha256=O7SkVqbGwN4zt8Sm3H8AHF9451FSgI5h0J3fDj1rFS4,142
|
189
194
|
quantalogic/tools/web_navigation/web_tool.py,sha256=AxAxQLUNwCElqxP2ceOOjHVY80ck-Md-uNsjHdR9ErA,4721
|
190
195
|
quantalogic/tools/wikipedia_search_tool.py,sha256=LXQSPH8961Efw2QNxKe-cD5ZiIYD3ufEgrxH4y5uB74,5180
|
191
|
-
quantalogic/tools/write_file_tool.py,sha256=
|
196
|
+
quantalogic/tools/write_file_tool.py,sha256=cOheTr2ZTWNbPHlB1PRhc1btJ2mW8TvE5PLQFIdbUb8,5578
|
192
197
|
quantalogic/utils/__init__.py,sha256=E442CJQuTohKzgI0Wrd4NZEpKascFjz6F4Vy8Y1c_0Y,634
|
193
198
|
quantalogic/utils/ask_user_validation.py,sha256=kSr7TXPTpsLR9zgwpGWgvffx8-cKAC_rdFRdLqwC22A,1176
|
194
199
|
quantalogic/utils/async_utils.py,sha256=FOizWRbHdsZwoD36dNErzunfwPlE7zDprS6RXcWuWSo,963
|
@@ -209,8 +214,8 @@ quantalogic/version_check.py,sha256=JyQFTNMDWtpHCLnN-BiakzB2cyXf6kUFsTjvmSruZi4,
|
|
209
214
|
quantalogic/welcome_message.py,sha256=o4tHdgabNuIV9kbIDPgS3_2yzJhayK30oKad2UouYDc,3020
|
210
215
|
quantalogic/xml_parser.py,sha256=bLLwIwO-VEHWF3heNS7nuPC8wgdYw9F_fVZZNW1figY,11728
|
211
216
|
quantalogic/xml_tool_parser.py,sha256=hGHA1q20JUoTNTbZYmi4FTdA5I25-AGEIP8DwZgQCNA,3897
|
212
|
-
quantalogic-0.
|
213
|
-
quantalogic-0.
|
214
|
-
quantalogic-0.
|
215
|
-
quantalogic-0.
|
216
|
-
quantalogic-0.
|
217
|
+
quantalogic-0.80.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
218
|
+
quantalogic-0.80.dist-info/METADATA,sha256=yRzUTVeu_Ju2Ciz1QzjIyitUijBfRd_f9yoITrqEqS4,33028
|
219
|
+
quantalogic-0.80.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
|
220
|
+
quantalogic-0.80.dist-info/entry_points.txt,sha256=wgSq5SRU98yvlRHGEZD1Xn7sS5CSjH2RfUtTa6Qy28Q,52
|
221
|
+
quantalogic-0.80.dist-info/RECORD,,
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# quantalogic/utils/__init__.py
|
2
|
-
from .exceptions import BreakException, ContinueException, ReturnException, WrappedException, has_await
|
3
|
-
from .execution import AsyncExecutionResult, execute_async, interpret_ast, interpret_code
|
4
|
-
from .function_utils import AsyncFunction, Function, LambdaFunction
|
5
|
-
from .interpreter_core import ASTInterpreter
|
6
|
-
from .scope import Scope
|
7
|
-
|
8
|
-
__all__ = [
|
9
|
-
'ASTInterpreter',
|
10
|
-
'execute_async',
|
11
|
-
'interpret_ast',
|
12
|
-
'interpret_code',
|
13
|
-
'AsyncExecutionResult',
|
14
|
-
'ReturnException',
|
15
|
-
'BreakException',
|
16
|
-
'ContinueException',
|
17
|
-
'WrappedException',
|
18
|
-
'has_await',
|
19
|
-
'Function',
|
20
|
-
'AsyncFunction',
|
21
|
-
'LambdaFunction',
|
22
|
-
'Scope',
|
23
|
-
]
|
@@ -1,63 +0,0 @@
|
|
1
|
-
import ast
|
2
|
-
from typing import Any
|
3
|
-
|
4
|
-
from .interpreter_core import ASTInterpreter
|
5
|
-
|
6
|
-
async def visit_Assign(self: ASTInterpreter, node: ast.Assign, wrap_exceptions: bool = True) -> None:
|
7
|
-
value: Any = await self.visit(node.value, wrap_exceptions=wrap_exceptions)
|
8
|
-
for target in node.targets:
|
9
|
-
if isinstance(target, ast.Subscript):
|
10
|
-
obj = await self.visit(target.value, wrap_exceptions=wrap_exceptions)
|
11
|
-
key = await self.visit(target.slice, wrap_exceptions=wrap_exceptions)
|
12
|
-
obj[key] = value
|
13
|
-
else:
|
14
|
-
await self.assign(target, value)
|
15
|
-
|
16
|
-
async def visit_AugAssign(self: ASTInterpreter, node: ast.AugAssign, wrap_exceptions: bool = True) -> Any:
|
17
|
-
if isinstance(node.target, ast.Name):
|
18
|
-
current_val: Any = self.get_variable(node.target.id)
|
19
|
-
else:
|
20
|
-
current_val: Any = await self.visit(node.target, wrap_exceptions=wrap_exceptions)
|
21
|
-
right_val: Any = await self.visit(node.value, wrap_exceptions=wrap_exceptions)
|
22
|
-
op = node.op
|
23
|
-
if isinstance(op, ast.Add):
|
24
|
-
result: Any = current_val + right_val
|
25
|
-
elif isinstance(op, ast.Sub):
|
26
|
-
result = current_val - right_val
|
27
|
-
elif isinstance(op, ast.Mult):
|
28
|
-
result = current_val * right_val
|
29
|
-
elif isinstance(op, ast.Div):
|
30
|
-
result = current_val / right_val
|
31
|
-
elif isinstance(op, ast.FloorDiv):
|
32
|
-
result = current_val // right_val
|
33
|
-
elif isinstance(op, ast.Mod):
|
34
|
-
result = current_val % right_val
|
35
|
-
elif isinstance(op, ast.Pow):
|
36
|
-
result = current_val**right_val
|
37
|
-
elif isinstance(op, ast.BitAnd):
|
38
|
-
result = current_val & right_val
|
39
|
-
elif isinstance(op, ast.BitOr):
|
40
|
-
result = current_val | right_val
|
41
|
-
elif isinstance(op, ast.BitXor):
|
42
|
-
result = current_val ^ right_val
|
43
|
-
elif isinstance(op, ast.LShift):
|
44
|
-
result = current_val << right_val
|
45
|
-
elif isinstance(op, ast.RShift):
|
46
|
-
result = current_val >> right_val
|
47
|
-
else:
|
48
|
-
raise Exception("Unsupported augmented operator: " + str(op))
|
49
|
-
await self.assign(node.target, result)
|
50
|
-
return result
|
51
|
-
|
52
|
-
async def visit_AnnAssign(self: ASTInterpreter, node: ast.AnnAssign, wrap_exceptions: bool = True) -> None:
|
53
|
-
value = await self.visit(node.value, wrap_exceptions=wrap_exceptions) if node.value else None
|
54
|
-
annotation = await self.visit(node.annotation, wrap_exceptions=True)
|
55
|
-
if isinstance(node.target, ast.Name):
|
56
|
-
self.type_hints[node.target.id] = annotation
|
57
|
-
if value is not None or node.simple:
|
58
|
-
await self.assign(node.target, value)
|
59
|
-
|
60
|
-
async def visit_NamedExpr(self: ASTInterpreter, node: ast.NamedExpr, wrap_exceptions: bool = True) -> Any:
|
61
|
-
value = await self.visit(node.value, wrap_exceptions=wrap_exceptions)
|
62
|
-
await self.assign(node.target, value)
|
63
|
-
return value
|
@@ -1,20 +0,0 @@
|
|
1
|
-
import ast
|
2
|
-
from typing import Any
|
3
|
-
|
4
|
-
from .exceptions import WrappedException
|
5
|
-
from .interpreter_core import ASTInterpreter
|
6
|
-
|
7
|
-
async def visit_Module(self: ASTInterpreter, node: ast.Module, wrap_exceptions: bool = True) -> Any:
|
8
|
-
last_value = None
|
9
|
-
for stmt in node.body:
|
10
|
-
last_value = await self.visit(stmt, wrap_exceptions=True)
|
11
|
-
return last_value
|
12
|
-
|
13
|
-
async def visit_Expr(self: ASTInterpreter, node: ast.Expr, wrap_exceptions: bool = True) -> Any:
|
14
|
-
return await self.visit(node.value, wrap_exceptions=wrap_exceptions)
|
15
|
-
|
16
|
-
async def visit_Pass(self: ASTInterpreter, node: ast.Pass, wrap_exceptions: bool = True) -> None:
|
17
|
-
return None
|
18
|
-
|
19
|
-
async def visit_TypeIgnore(self: ASTInterpreter, node: ast.TypeIgnore, wrap_exceptions: bool = True) -> None:
|
20
|
-
pass
|
@@ -1,22 +0,0 @@
|
|
1
|
-
import ast
|
2
|
-
from typing import Any, Dict, List
|
3
|
-
|
4
|
-
from .function_utils import Function
|
5
|
-
from .interpreter_core import ASTInterpreter
|
6
|
-
|
7
|
-
async def visit_ClassDef(self: ASTInterpreter, node: ast.ClassDef, wrap_exceptions: bool = True) -> Any:
|
8
|
-
base_frame = {}
|
9
|
-
self.env_stack.append(base_frame)
|
10
|
-
bases = [await self.visit(base, wrap_exceptions=True) for base in node.bases]
|
11
|
-
try:
|
12
|
-
for stmt in node.body:
|
13
|
-
await self.visit(stmt, wrap_exceptions=True)
|
14
|
-
class_dict = {k: v for k, v in self.env_stack[-1].items() if k not in ["__builtins__"]}
|
15
|
-
cls = type(node.name, tuple(bases), class_dict)
|
16
|
-
for name, value in class_dict.items():
|
17
|
-
if isinstance(value, Function):
|
18
|
-
value.defining_class = cls
|
19
|
-
self.env_stack[-2][node.name] = cls
|
20
|
-
return cls
|
21
|
-
finally:
|
22
|
-
self.env_stack.pop()
|
@@ -1,172 +0,0 @@
|
|
1
|
-
import ast
|
2
|
-
from typing import Any, Dict, List
|
3
|
-
|
4
|
-
from .interpreter_core import ASTInterpreter
|
5
|
-
from .exceptions import WrappedException
|
6
|
-
|
7
|
-
async def visit_ListComp(self: ASTInterpreter, node: ast.ListComp, wrap_exceptions: bool = True) -> List[Any]:
|
8
|
-
result = []
|
9
|
-
base_frame = self.env_stack[-1].copy()
|
10
|
-
self.env_stack.append(base_frame)
|
11
|
-
|
12
|
-
async def rec(gen_idx: int):
|
13
|
-
if gen_idx == len(node.generators):
|
14
|
-
element = await self.visit(node.elt, wrap_exceptions=wrap_exceptions)
|
15
|
-
result.append(element)
|
16
|
-
else:
|
17
|
-
comp = node.generators[gen_idx]
|
18
|
-
iterable = await self.visit(comp.iter, wrap_exceptions=wrap_exceptions)
|
19
|
-
if hasattr(iterable, '__aiter__'):
|
20
|
-
async for item in iterable:
|
21
|
-
new_frame = self.env_stack[-1].copy()
|
22
|
-
self.env_stack.append(new_frame)
|
23
|
-
await self.assign(comp.target, item)
|
24
|
-
conditions = [await self.visit(if_clause, wrap_exceptions=True) for if_clause in comp.ifs]
|
25
|
-
if all(conditions):
|
26
|
-
await rec(gen_idx + 1)
|
27
|
-
self.env_stack.pop()
|
28
|
-
else:
|
29
|
-
try:
|
30
|
-
for item in iterable:
|
31
|
-
new_frame = self.env_stack[-1].copy()
|
32
|
-
self.env_stack.append(new_frame)
|
33
|
-
await self.assign(comp.target, item)
|
34
|
-
conditions = [await self.visit(if_clause, wrap_exceptions=True) for if_clause in comp.ifs]
|
35
|
-
if all(conditions):
|
36
|
-
await rec(gen_idx + 1)
|
37
|
-
self.env_stack.pop()
|
38
|
-
except TypeError as e:
|
39
|
-
lineno = getattr(node, "lineno", 1)
|
40
|
-
col = getattr(node, "col_offset", 0)
|
41
|
-
context_line = self.source_lines[lineno - 1] if self.source_lines and lineno <= len(self.source_lines) else ""
|
42
|
-
raise WrappedException(f"Object {iterable} is not iterable", e, lineno, col, context_line) from e
|
43
|
-
|
44
|
-
await rec(0)
|
45
|
-
self.env_stack.pop()
|
46
|
-
return result
|
47
|
-
|
48
|
-
async def visit_DictComp(self: ASTInterpreter, node: ast.DictComp, wrap_exceptions: bool = True) -> Dict[Any, Any]:
|
49
|
-
result = {}
|
50
|
-
base_frame = self.env_stack[-1].copy()
|
51
|
-
self.env_stack.append(base_frame)
|
52
|
-
|
53
|
-
async def rec(gen_idx: int):
|
54
|
-
if gen_idx == len(node.generators):
|
55
|
-
key = await self.visit(node.key, wrap_exceptions=True)
|
56
|
-
val = await self.visit(node.value, wrap_exceptions=True)
|
57
|
-
result[key] = val
|
58
|
-
else:
|
59
|
-
comp = node.generators[gen_idx]
|
60
|
-
iterable = await self.visit(comp.iter, wrap_exceptions=wrap_exceptions)
|
61
|
-
if hasattr(iterable, '__aiter__'):
|
62
|
-
async for item in iterable:
|
63
|
-
new_frame = self.env_stack[-1].copy()
|
64
|
-
self.env_stack.append(new_frame)
|
65
|
-
await self.assign(comp.target, item)
|
66
|
-
conditions = [await self.visit(if_clause, wrap_exceptions=True) for if_clause in comp.ifs]
|
67
|
-
if all(conditions):
|
68
|
-
await rec(gen_idx + 1)
|
69
|
-
self.env_stack.pop()
|
70
|
-
else:
|
71
|
-
try:
|
72
|
-
for item in iterable:
|
73
|
-
new_frame = self.env_stack[-1].copy()
|
74
|
-
self.env_stack.append(new_frame)
|
75
|
-
await self.assign(comp.target, item)
|
76
|
-
conditions = [await self.visit(if_clause, wrap_exceptions=True) for if_clause in comp.ifs]
|
77
|
-
if all(conditions):
|
78
|
-
await rec(gen_idx + 1)
|
79
|
-
self.env_stack.pop()
|
80
|
-
except TypeError as e:
|
81
|
-
lineno = getattr(node, "lineno", 1)
|
82
|
-
col = getattr(node, "col_offset", 0)
|
83
|
-
context_line = self.source_lines[lineno - 1] if self.source_lines and lineno <= len(self.source_lines) else ""
|
84
|
-
raise WrappedException(f"Object {iterable} is not iterable", e, lineno, col, context_line) from e
|
85
|
-
|
86
|
-
await rec(0)
|
87
|
-
self.env_stack.pop()
|
88
|
-
return result
|
89
|
-
|
90
|
-
async def visit_SetComp(self: ASTInterpreter, node: ast.SetComp, wrap_exceptions: bool = True) -> set:
|
91
|
-
result = set()
|
92
|
-
base_frame = self.env_stack[-1].copy()
|
93
|
-
self.env_stack.append(base_frame)
|
94
|
-
|
95
|
-
async def rec(gen_idx: int):
|
96
|
-
if gen_idx == len(node.generators):
|
97
|
-
result.add(await self.visit(node.elt, wrap_exceptions=True))
|
98
|
-
else:
|
99
|
-
comp = node.generators[gen_idx]
|
100
|
-
iterable = await self.visit(comp.iter, wrap_exceptions=wrap_exceptions)
|
101
|
-
if hasattr(iterable, '__aiter__'):
|
102
|
-
async for item in iterable:
|
103
|
-
new_frame = self.env_stack[-1].copy()
|
104
|
-
self.env_stack.append(new_frame)
|
105
|
-
await self.assign(comp.target, item)
|
106
|
-
conditions = [await self.visit(if_clause, wrap_exceptions=True) for if_clause in comp.ifs]
|
107
|
-
if all(conditions):
|
108
|
-
await rec(gen_idx + 1)
|
109
|
-
self.env_stack.pop()
|
110
|
-
else:
|
111
|
-
try:
|
112
|
-
for item in iterable:
|
113
|
-
new_frame = self.env_stack[-1].copy()
|
114
|
-
self.env_stack.append(new_frame)
|
115
|
-
await self.assign(comp.target, item)
|
116
|
-
conditions = [await self.visit(if_clause, wrap_exceptions=True) for if_clause in comp.ifs]
|
117
|
-
if all(conditions):
|
118
|
-
await rec(gen_idx + 1)
|
119
|
-
self.env_stack.pop()
|
120
|
-
except TypeError as e:
|
121
|
-
lineno = getattr(node, "lineno", 1)
|
122
|
-
col = getattr(node, "col_offset", 0)
|
123
|
-
context_line = self.source_lines[lineno - 1] if self.source_lines and lineno <= len(self.source_lines) else ""
|
124
|
-
raise WrappedException(f"Object {iterable} is not iterable", e, lineno, col, context_line) from e
|
125
|
-
|
126
|
-
await rec(0)
|
127
|
-
self.env_stack.pop()
|
128
|
-
return result
|
129
|
-
|
130
|
-
async def visit_GeneratorExp(self: ASTInterpreter, node: ast.GeneratorExp, wrap_exceptions: bool = True) -> Any:
|
131
|
-
base_frame: Dict[str, Any] = self.env_stack[-1].copy()
|
132
|
-
self.env_stack.append(base_frame)
|
133
|
-
|
134
|
-
async def gen():
|
135
|
-
async def rec(gen_idx: int):
|
136
|
-
if gen_idx == len(node.generators):
|
137
|
-
yield await self.visit(node.elt, wrap_exceptions=True)
|
138
|
-
else:
|
139
|
-
comp = node.generators[gen_idx]
|
140
|
-
iterable = await self.visit(comp.iter, wrap_exceptions=wrap_exceptions)
|
141
|
-
if hasattr(iterable, '__aiter__'):
|
142
|
-
async for item in iterable:
|
143
|
-
new_frame = self.env_stack[-1].copy()
|
144
|
-
self.env_stack.append(new_frame)
|
145
|
-
await self.assign(comp.target, item)
|
146
|
-
conditions = [await self.visit(if_clause, wrap_exceptions=True) for if_clause in comp.ifs]
|
147
|
-
if all(conditions):
|
148
|
-
async for val in rec(gen_idx + 1):
|
149
|
-
yield val
|
150
|
-
self.env_stack.pop()
|
151
|
-
else:
|
152
|
-
try:
|
153
|
-
for item in iterable:
|
154
|
-
new_frame = self.env_stack[-1].copy()
|
155
|
-
self.env_stack.append(new_frame)
|
156
|
-
await self.assign(comp.target, item)
|
157
|
-
conditions = [await self.visit(if_clause, wrap_exceptions=True) for if_clause in comp.ifs]
|
158
|
-
if all(conditions):
|
159
|
-
async for val in rec(gen_idx + 1):
|
160
|
-
yield val
|
161
|
-
self.env_stack.pop()
|
162
|
-
except TypeError as e:
|
163
|
-
lineno = getattr(node, "lineno", 1)
|
164
|
-
col = getattr(node, "col_offset", 0)
|
165
|
-
context_line = self.source_lines[lineno - 1] if self.source_lines and lineno <= len(self.source_lines) else ""
|
166
|
-
raise WrappedException(f"Object {iterable} is not iterable", e, lineno, col, context_line) from e
|
167
|
-
|
168
|
-
async for val in rec(0):
|
169
|
-
yield val
|
170
|
-
|
171
|
-
self.env_stack.pop()
|
172
|
-
return gen()
|
@@ -1,59 +0,0 @@
|
|
1
|
-
import ast
|
2
|
-
from typing import Any
|
3
|
-
|
4
|
-
from .exceptions import ReturnException
|
5
|
-
from .interpreter_core import ASTInterpreter
|
6
|
-
|
7
|
-
async def visit_With(self: ASTInterpreter, node: ast.With, wrap_exceptions: bool = True) -> Any:
|
8
|
-
result = None
|
9
|
-
contexts = []
|
10
|
-
for item in node.items:
|
11
|
-
ctx = await self.visit(item.context_expr, wrap_exceptions=wrap_exceptions)
|
12
|
-
val = ctx.__enter__()
|
13
|
-
contexts.append((ctx, val))
|
14
|
-
if item.optional_vars:
|
15
|
-
await self.assign(item.optional_vars, val)
|
16
|
-
try:
|
17
|
-
for stmt in node.body:
|
18
|
-
result = await self.visit(stmt, wrap_exceptions=wrap_exceptions)
|
19
|
-
except ReturnException as ret:
|
20
|
-
for ctx, _ in reversed(contexts):
|
21
|
-
ctx.__exit__(None, None, None)
|
22
|
-
raise ret
|
23
|
-
except Exception as e:
|
24
|
-
exc_type, exc_value, tb = type(e), e, e.__traceback__
|
25
|
-
for ctx, _ in reversed(contexts):
|
26
|
-
if not ctx.__exit__(exc_type, exc_value, tb):
|
27
|
-
raise
|
28
|
-
raise
|
29
|
-
else:
|
30
|
-
for ctx, _ in reversed(contexts):
|
31
|
-
ctx.__exit__(None, None, None)
|
32
|
-
return result
|
33
|
-
|
34
|
-
async def visit_AsyncWith(self: ASTInterpreter, node: ast.AsyncWith, wrap_exceptions: bool = True) -> Any:
|
35
|
-
result = None
|
36
|
-
contexts = []
|
37
|
-
for item in node.items:
|
38
|
-
ctx = await self.visit(item.context_expr, wrap_exceptions=wrap_exceptions)
|
39
|
-
val = await ctx.__aenter__()
|
40
|
-
contexts.append((ctx, val))
|
41
|
-
if item.optional_vars:
|
42
|
-
await self.assign(item.optional_vars, val)
|
43
|
-
try:
|
44
|
-
for stmt in node.body:
|
45
|
-
result = await self.visit(stmt, wrap_exceptions=wrap_exceptions)
|
46
|
-
except ReturnException as ret:
|
47
|
-
for ctx, _ in reversed(contexts):
|
48
|
-
await ctx.__aexit__(None, None, None)
|
49
|
-
raise ret
|
50
|
-
except Exception as e:
|
51
|
-
exc_type, exc_value, tb = type(e), e, e.__traceback__
|
52
|
-
for ctx, _ in reversed(contexts):
|
53
|
-
if not await ctx.__aexit__(exc_type, exc_value, tb):
|
54
|
-
raise
|
55
|
-
raise
|
56
|
-
else:
|
57
|
-
for ctx, _ in reversed(contexts):
|
58
|
-
await ctx.__aexit__(None, None, None)
|
59
|
-
return result
|