webtap-tool 0.3.0__py3-none-any.whl → 0.5.0__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.
Potentially problematic release.
This version of webtap-tool might be problematic. Click here for more details.
- webtap/api.py +318 -9
- webtap/app.py +15 -9
- webtap/cdp/session.py +101 -1
- webtap/commands/DEVELOPER_GUIDE.md +108 -22
- webtap/commands/TIPS.md +24 -1
- webtap/commands/_builders.py +139 -1
- webtap/commands/body.py +1 -2
- webtap/commands/connection.py +1 -2
- webtap/commands/console.py +1 -2
- webtap/commands/events.py +1 -2
- webtap/commands/fetch.py +1 -2
- webtap/commands/filters.py +95 -62
- webtap/commands/inspect.py +1 -2
- webtap/commands/javascript.py +41 -26
- webtap/commands/navigation.py +1 -2
- webtap/commands/network.py +11 -7
- webtap/commands/selections.py +129 -0
- webtap/commands/server.py +19 -0
- webtap/filters.py +116 -56
- webtap/services/dom.py +512 -0
- webtap/services/main.py +14 -0
- {webtap_tool-0.3.0.dist-info → webtap_tool-0.5.0.dist-info}/METADATA +2 -2
- {webtap_tool-0.3.0.dist-info → webtap_tool-0.5.0.dist-info}/RECORD +25 -24
- webtap/commands/_errors.py +0 -108
- {webtap_tool-0.3.0.dist-info → webtap_tool-0.5.0.dist-info}/WHEEL +0 -0
- {webtap_tool-0.3.0.dist-info → webtap_tool-0.5.0.dist-info}/entry_points.txt +0 -0
webtap/commands/_errors.py
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
"""Unified error handling for WebTap commands."""
|
|
2
|
-
|
|
3
|
-
from typing import Optional
|
|
4
|
-
from replkit2.textkit import markdown
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
ERRORS = {
|
|
8
|
-
"not_connected": {
|
|
9
|
-
"message": "Not connected to Chrome",
|
|
10
|
-
"details": "Use `connect()` to connect to a page",
|
|
11
|
-
"help": [
|
|
12
|
-
"Run `pages()` to see available tabs",
|
|
13
|
-
"Use `connect(0)` to connect to first tab",
|
|
14
|
-
"Or `connect(page_id='...')` for specific tab",
|
|
15
|
-
],
|
|
16
|
-
},
|
|
17
|
-
"fetch_disabled": {
|
|
18
|
-
"message": "Fetch interception not enabled",
|
|
19
|
-
"details": "Enable with `fetch(enable=True)` to pause requests",
|
|
20
|
-
},
|
|
21
|
-
"no_data": {"message": "No data available", "details": "The requested data is not available"},
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def check_connection(state) -> Optional[dict]:
|
|
26
|
-
"""Check CDP connection and return error response if not connected.
|
|
27
|
-
|
|
28
|
-
Args:
|
|
29
|
-
state: Application state containing CDP session.
|
|
30
|
-
"""
|
|
31
|
-
if not (state.cdp and state.cdp.is_connected):
|
|
32
|
-
return error_response("not_connected")
|
|
33
|
-
return None
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def error_response(error_key: str, custom_message: str | None = None, **kwargs) -> dict:
|
|
37
|
-
"""Build consistent error response in markdown.
|
|
38
|
-
|
|
39
|
-
Args:
|
|
40
|
-
error_key: Key from error templates or custom identifier.
|
|
41
|
-
custom_message: Override default message.
|
|
42
|
-
**kwargs: Additional context to add to error response.
|
|
43
|
-
"""
|
|
44
|
-
error_info = ERRORS.get(error_key, {})
|
|
45
|
-
message = custom_message or error_info.get("message", "Error occurred")
|
|
46
|
-
|
|
47
|
-
builder = markdown().element("alert", message=message, level="error")
|
|
48
|
-
|
|
49
|
-
if details := error_info.get("details"):
|
|
50
|
-
builder.text(details)
|
|
51
|
-
|
|
52
|
-
if help_items := error_info.get("help"):
|
|
53
|
-
builder.text("**How to fix:**")
|
|
54
|
-
builder.list_(help_items)
|
|
55
|
-
|
|
56
|
-
for key, value in kwargs.items():
|
|
57
|
-
if value:
|
|
58
|
-
builder.text(f"_{key}: {value}_")
|
|
59
|
-
|
|
60
|
-
return builder.build()
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def warning_response(message: str, details: str | None = None) -> dict:
|
|
64
|
-
"""Build warning response for non-fatal issues.
|
|
65
|
-
|
|
66
|
-
Args:
|
|
67
|
-
message: Warning message text.
|
|
68
|
-
details: Additional details.
|
|
69
|
-
"""
|
|
70
|
-
builder = markdown().element("alert", message=message, level="warning")
|
|
71
|
-
if details:
|
|
72
|
-
builder.text(details)
|
|
73
|
-
return builder.build()
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
def invalid_options_error(message: str, expected: dict = None) -> dict: # pyright: ignore[reportArgumentType]
|
|
77
|
-
"""Create error response for invalid options dict.
|
|
78
|
-
|
|
79
|
-
Args:
|
|
80
|
-
message: Error message describing the issue.
|
|
81
|
-
expected: Optional example of expected format.
|
|
82
|
-
"""
|
|
83
|
-
builder = markdown().element("alert", message=message, level="error")
|
|
84
|
-
|
|
85
|
-
if expected:
|
|
86
|
-
builder.text("**Expected format:**")
|
|
87
|
-
import json
|
|
88
|
-
|
|
89
|
-
builder.code_block(json.dumps(expected, indent=2), language="json")
|
|
90
|
-
|
|
91
|
-
return builder.build()
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def missing_param_error(param: str, command: str = None) -> dict: # pyright: ignore[reportArgumentType]
|
|
95
|
-
"""Create error response for missing required parameter.
|
|
96
|
-
|
|
97
|
-
Args:
|
|
98
|
-
param: Name of the missing parameter.
|
|
99
|
-
command: Optional command name for context.
|
|
100
|
-
"""
|
|
101
|
-
message = f"Required parameter '{param}' not provided"
|
|
102
|
-
if command:
|
|
103
|
-
message = f"{command}: {message}"
|
|
104
|
-
|
|
105
|
-
builder = markdown().element("alert", message=message, level="error")
|
|
106
|
-
builder.text(f"The '{param}' parameter is required for this operation")
|
|
107
|
-
|
|
108
|
-
return builder.build()
|
|
File without changes
|
|
File without changes
|