py4web-debug-tools 1.2.1__tar.gz → 1.3.0__tar.gz
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.
- {py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/CHANGELOG.md +12 -0
- {py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/PKG-INFO +3 -3
- py4web_debug_tools-1.3.0/src/py4web_debug/__about__.py +1 -0
- {py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/src/py4web_debug/__init__.py +2 -1
- {py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/src/py4web_debug/dumping.py +39 -0
- {py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/src/py4web_debug/internals.py +5 -4
- py4web_debug_tools-1.2.1/src/py4web_debug/__about__.py +0 -1
- {py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/.gitignore +0 -0
- {py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/README.md +0 -0
- {py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/pyproject.toml +0 -0
- {py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/src/py4web_debug/_internals.py +0 -0
- {py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/src/py4web_debug/core.py +0 -0
- {py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/src/py4web_debug/debugbar.py +0 -0
- {py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/src/py4web_debug/env.py +0 -0
- {py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/src/py4web_debug/py.typed +0 -0
- {py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/src/py4web_debug/templates/debugbar.html +0 -0
- {py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/src/py4web_debug/templates/dumpdie.html +0 -0
- {py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/src/py4web_debug/templates/error_default.html +0 -0
- {py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/src/py4web_debug/templates/fancy_dumpdie.html +0 -0
- {py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/src/py4web_debug/types.py +0 -0
- {py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/src/py4web_debug/wsgi.py +0 -0
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
<!--next-version-placeholder-->
|
|
4
4
|
|
|
5
|
+
## v1.3.0 (2025-04-01)
|
|
6
|
+
|
|
7
|
+
### Feature
|
|
8
|
+
|
|
9
|
+
* Add `dbg` helper ([`b7529e3`](https://github.com/trialandsuccess/py4web-debug-tools/commit/b7529e32bcaa88a237fa505d26afe3f013d0bdf2))
|
|
10
|
+
|
|
11
|
+
## v1.2.2 (2024-11-20)
|
|
12
|
+
|
|
13
|
+
### Fix
|
|
14
|
+
|
|
15
|
+
* Replace 'self' with 'patch_py4' for better stability ([`6987942`](https://github.com/trialandsuccess/py4web-debug-tools/commit/6987942347b993cf767166b6f3dac90e75989130))
|
|
16
|
+
|
|
5
17
|
## v1.2.1 (2024-11-20)
|
|
6
18
|
|
|
7
19
|
### Fix
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: py4web-debug-tools
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: Debug Tools for py4web
|
|
5
5
|
Project-URL: Documentation, https://github.com/trialandsuccess/py4web-debug-tools#readme
|
|
6
6
|
Project-URL: Issues, https://github.com/trialandsuccess/py4web-debug-tools/issues
|
|
7
7
|
Project-URL: Source, https://github.com/trialandsuccess/py4web-debug-tools
|
|
8
8
|
Author-email: Robin van der Noord <contact@trialandsuccess.nl>
|
|
9
|
-
License: MIT
|
|
9
|
+
License-Expression: MIT
|
|
10
10
|
Classifier: Development Status :: 4 - Beta
|
|
11
11
|
Classifier: Programming Language :: Python
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.10
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.3.0"
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
from .core import tools
|
|
4
4
|
from .debugbar import catch
|
|
5
|
-
from .dumping import dd, dump
|
|
5
|
+
from .dumping import dbg, dd, dump
|
|
6
6
|
from .env import is_debug
|
|
7
7
|
from .wsgi import wsgi
|
|
8
8
|
|
|
9
9
|
__all__ = [
|
|
10
10
|
"tools",
|
|
11
11
|
"catch",
|
|
12
|
+
"dbg",
|
|
12
13
|
"dd",
|
|
13
14
|
"dump",
|
|
14
15
|
"is_debug",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import ast
|
|
1
2
|
import json
|
|
2
3
|
import sys
|
|
4
|
+
import traceback
|
|
3
5
|
import typing
|
|
4
6
|
|
|
5
7
|
import pydal.objects
|
|
@@ -152,3 +154,40 @@ def dd(*data: typing.Any, fancy: bool = True, api: bool = False) -> None:
|
|
|
152
154
|
raise FancyDumpDieError(_json)
|
|
153
155
|
else:
|
|
154
156
|
raise DumpDieError(_json)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
T = typing.TypeVar("T")
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def dbg(value: T) -> T:
|
|
163
|
+
"""
|
|
164
|
+
Helper inspired by Rust's `dbg!`.
|
|
165
|
+
|
|
166
|
+
Prints out the file, line, variable name, type and value.
|
|
167
|
+
Also returns the original value.
|
|
168
|
+
"""
|
|
169
|
+
value_type = type(value).__name__
|
|
170
|
+
|
|
171
|
+
frame = traceback.extract_stack()[-2] # Get caller frame info
|
|
172
|
+
file_name = frame.filename.split("/")[-1]
|
|
173
|
+
line_number = frame.lineno
|
|
174
|
+
|
|
175
|
+
try:
|
|
176
|
+
with open(frame.filename, "r") as f:
|
|
177
|
+
source_code = f.readlines()
|
|
178
|
+
|
|
179
|
+
line = source_code[line_number - 1].strip()
|
|
180
|
+
tree = ast.parse(line)
|
|
181
|
+
|
|
182
|
+
var_name = None
|
|
183
|
+
if isinstance(tree, ast.Module) and isinstance(tree.body[0], ast.Expr):
|
|
184
|
+
call = tree.body[0].value
|
|
185
|
+
if isinstance(call, ast.Call) and call.func.id == "dbg":
|
|
186
|
+
var_name = ast.unparse(call.args[0]) # Extract the first argument as a string
|
|
187
|
+
|
|
188
|
+
except Exception:
|
|
189
|
+
var_name = "?"
|
|
190
|
+
|
|
191
|
+
print(f"[{file_name}:{line_number}] {value_type}({var_name}) = {value}", file=sys.stderr)
|
|
192
|
+
|
|
193
|
+
return value
|
|
@@ -122,7 +122,8 @@ class patch_py4:
|
|
|
122
122
|
renderer: T_Renderer | None = None
|
|
123
123
|
logger: T_Logger | typing.Literal[False] | None = None
|
|
124
124
|
|
|
125
|
-
def __init__(
|
|
125
|
+
def __init__(_, renderer: T_Renderer = None, logger: T_Logger | bool | None = None):
|
|
126
|
+
# note: don't use self, use patch_py4 instead
|
|
126
127
|
if logger is True:
|
|
127
128
|
# use default logger:
|
|
128
129
|
logger = None
|
|
@@ -152,10 +153,10 @@ class patch_py4:
|
|
|
152
153
|
except Exception as e:
|
|
153
154
|
err_code = 500
|
|
154
155
|
snapshot = get_error_snapshot()
|
|
155
|
-
if
|
|
156
|
+
if patch_py4.logger is not False:
|
|
156
157
|
# False - don't log
|
|
157
158
|
# None - default logger
|
|
158
|
-
(
|
|
159
|
+
(patch_py4.logger or default_error_logger)(snapshot)
|
|
159
160
|
|
|
160
161
|
ticket_uuid = error_logger.log(request.app_name, snapshot) or "unknown"
|
|
161
162
|
response.status = err_code
|
|
@@ -182,4 +183,4 @@ class patch_py4:
|
|
|
182
183
|
# allows swapping renderer on the fly with tools.set_renderer():
|
|
183
184
|
patch_py4.renderer = renderer
|
|
184
185
|
_logger = getattr(patch_py4, "logger", None) or logger
|
|
185
|
-
patch_py4.logger = staticmethod(_logger) if _logger else
|
|
186
|
+
patch_py4.logger = staticmethod(_logger) if callable(_logger) else _logger
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.2.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/src/py4web_debug/templates/debugbar.html
RENAMED
|
File without changes
|
{py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/src/py4web_debug/templates/dumpdie.html
RENAMED
|
File without changes
|
{py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/src/py4web_debug/templates/error_default.html
RENAMED
|
File without changes
|
{py4web_debug_tools-1.2.1 → py4web_debug_tools-1.3.0}/src/py4web_debug/templates/fancy_dumpdie.html
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|