kenenet 0.2.7__py3-none-any.whl → 0.2.8__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.
- kenenet/__init__.py +16 -29
- {kenenet-0.2.7.dist-info → kenenet-0.2.8.dist-info}/METADATA +1 -1
- kenenet-0.2.8.dist-info/RECORD +5 -0
- kenenet-0.2.7.dist-info/RECORD +0 -5
- {kenenet-0.2.7.dist-info → kenenet-0.2.8.dist-info}/WHEEL +0 -0
- {kenenet-0.2.7.dist-info → kenenet-0.2.8.dist-info}/top_level.txt +0 -0
kenenet/__init__.py
CHANGED
@@ -37,18 +37,7 @@ def timer(clock=1):
|
|
37
37
|
timings[clock] = time.time()
|
38
38
|
|
39
39
|
|
40
|
-
def
|
41
|
-
"""
|
42
|
-
Returns a trace function that prints each executed line along with local variables.
|
43
|
-
|
44
|
-
Parameters:
|
45
|
-
ignore_special_vars (bool): If True, ignores special system variables such as:
|
46
|
-
__name__, __doc__, __package__, __loader__, __spec__, __annotations__, __file__, __cached__
|
47
|
-
ignore_functions (bool): If True, ignores function objects.
|
48
|
-
ignore_classes (bool): If True, ignores class objects.
|
49
|
-
ignore_modules (bool): If True, ignores module objects.
|
50
|
-
ignore_file_path (bool): If True, does not print the file path in the header.
|
51
|
-
"""
|
40
|
+
def make_trace_function(ignore_special_vars=True, ignore_functions=True, ignore_classes=True, ignore_modules=True, ignore_file_path=True):
|
52
41
|
special_vars = {
|
53
42
|
"__name__", "__doc__", "__package__", "__loader__",
|
54
43
|
"__spec__", "__annotations__", "__file__", "__cached__"
|
@@ -59,13 +48,18 @@ def _make_trace_function(ignore_special_vars=False, ignore_functions=False, igno
|
|
59
48
|
filename = frame.f_code.co_filename
|
60
49
|
lineno = frame.f_lineno
|
61
50
|
code_line = linecache.getline(filename, lineno).strip()
|
62
|
-
|
51
|
+
|
52
|
+
# Prevent spamming by ensuring we aren't tracing internal Python locks or infinite loops
|
53
|
+
if not code_line:
|
54
|
+
return trace_lines
|
55
|
+
|
63
56
|
header = f"Executing line {lineno}:" if ignore_file_path else f"Executing {filename}:{lineno}:"
|
64
57
|
_quick_print("=" * 60)
|
65
58
|
_quick_print(header, lineno)
|
66
59
|
_quick_print(f" {code_line}", lineno)
|
67
60
|
_quick_print("-" * 60, lineno)
|
68
61
|
_quick_print("Local Variables:", lineno)
|
62
|
+
|
69
63
|
for var, value in frame.f_locals.items():
|
70
64
|
if ignore_special_vars and var in special_vars:
|
71
65
|
continue
|
@@ -75,25 +69,20 @@ def _make_trace_function(ignore_special_vars=False, ignore_functions=False, igno
|
|
75
69
|
continue
|
76
70
|
if ignore_classes and isinstance(value, type):
|
77
71
|
continue
|
78
|
-
|
72
|
+
try:
|
73
|
+
_quick_print(f" {var} = {repr(value)}", lineno)
|
74
|
+
except (AttributeError, TypeError, Exception):
|
75
|
+
_quick_print(f" {var} = [unreadable]", lineno)
|
76
|
+
|
79
77
|
_quick_print("=" * 60, lineno)
|
78
|
+
|
80
79
|
return trace_lines
|
81
80
|
|
82
81
|
return trace_lines
|
83
82
|
|
84
83
|
|
85
|
-
def
|
86
|
-
|
87
|
-
Activates the line-by-line tracing of code execution.
|
88
|
-
|
89
|
-
Parameters:
|
90
|
-
ignore_special_vars (bool): If True, omits special variables (e.g. __name__, __doc__, etc.)
|
91
|
-
ignore_functions (bool): If True, omits function objects.
|
92
|
-
ignore_classes (bool): If True, omits class objects.
|
93
|
-
ignore_modules (bool): If True, omits module objects.
|
94
|
-
ignore_file_path (bool): If True, only the line number is shown instead of the full file path.
|
95
|
-
"""
|
96
|
-
trace_func = _make_trace_function(
|
84
|
+
def activate_tracing(ignore_special_vars=True, ignore_functions=True, ignore_classes=True, ignore_modules=True, ignore_file_path=True):
|
85
|
+
trace_func = make_trace_function(
|
97
86
|
ignore_special_vars=ignore_special_vars,
|
98
87
|
ignore_functions=ignore_functions,
|
99
88
|
ignore_classes=ignore_classes,
|
@@ -101,13 +90,11 @@ def dbug(ignore_special_vars=True, ignore_functions=True, ignore_classes=True, i
|
|
101
90
|
ignore_file_path=ignore_file_path
|
102
91
|
)
|
103
92
|
sys.settrace(trace_func)
|
104
|
-
# Force the current (global) frame to be traced.
|
105
93
|
sys._getframe().f_trace = trace_func
|
106
94
|
_quick_print("Tracing activated.")
|
107
95
|
|
108
96
|
|
109
|
-
def
|
110
|
-
"""Deactivates the tracing."""
|
97
|
+
def deactivate_tracing():
|
111
98
|
sys.settrace(None)
|
112
99
|
_quick_print("Tracing deactivated.")
|
113
100
|
|
@@ -0,0 +1,5 @@
|
|
1
|
+
kenenet/__init__.py,sha256=x8fsWkCUPf-ci1rtSiXD_Rcy8-eKqFK4RQ9_1zM2V2Y,4991
|
2
|
+
kenenet-0.2.8.dist-info/METADATA,sha256=ofjGHLi9dOwBaOU7WfNtm-pMVURVddeoAOmLC66v1uI,513
|
3
|
+
kenenet-0.2.8.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
4
|
+
kenenet-0.2.8.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
+
kenenet-0.2.8.dist-info/RECORD,,
|
kenenet-0.2.7.dist-info/RECORD
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
kenenet/__init__.py,sha256=yq2XCgPyw_zFC5RR3zJfrPR2LNFF6hWIq8rZTXwp4Ds,5783
|
2
|
-
kenenet-0.2.7.dist-info/METADATA,sha256=LNHs1CZ6wGcdoueBzq3QeM_-9TmfmRH9-npnTAtSyF8,513
|
3
|
-
kenenet-0.2.7.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
4
|
-
kenenet-0.2.7.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
-
kenenet-0.2.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|