kenenet 0.2.5__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 +63 -2
- {kenenet-0.2.5.dist-info → kenenet-0.2.8.dist-info}/METADATA +1 -1
- kenenet-0.2.8.dist-info/RECORD +5 -0
- kenenet-0.2.5.dist-info/RECORD +0 -5
- {kenenet-0.2.5.dist-info → kenenet-0.2.8.dist-info}/WHEEL +0 -0
- {kenenet-0.2.5.dist-info → kenenet-0.2.8.dist-info}/top_level.txt +0 -0
kenenet/__init__.py
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
import inspect, sys, zhmiscellany, keyboard, mss, time,
|
2
|
-
|
1
|
+
import inspect, sys, zhmiscellany, keyboard, mss, time, linecache, types
|
3
2
|
global timings
|
4
3
|
timings = {}
|
5
4
|
|
@@ -37,6 +36,68 @@ def timer(clock=1):
|
|
37
36
|
else:
|
38
37
|
timings[clock] = time.time()
|
39
38
|
|
39
|
+
|
40
|
+
def make_trace_function(ignore_special_vars=True, ignore_functions=True, ignore_classes=True, ignore_modules=True, ignore_file_path=True):
|
41
|
+
special_vars = {
|
42
|
+
"__name__", "__doc__", "__package__", "__loader__",
|
43
|
+
"__spec__", "__annotations__", "__file__", "__cached__"
|
44
|
+
}
|
45
|
+
|
46
|
+
def trace_lines(frame, event, arg):
|
47
|
+
if event == 'line':
|
48
|
+
filename = frame.f_code.co_filename
|
49
|
+
lineno = frame.f_lineno
|
50
|
+
code_line = linecache.getline(filename, lineno).strip()
|
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
|
+
|
56
|
+
header = f"Executing line {lineno}:" if ignore_file_path else f"Executing {filename}:{lineno}:"
|
57
|
+
_quick_print("=" * 60)
|
58
|
+
_quick_print(header, lineno)
|
59
|
+
_quick_print(f" {code_line}", lineno)
|
60
|
+
_quick_print("-" * 60, lineno)
|
61
|
+
_quick_print("Local Variables:", lineno)
|
62
|
+
|
63
|
+
for var, value in frame.f_locals.items():
|
64
|
+
if ignore_special_vars and var in special_vars:
|
65
|
+
continue
|
66
|
+
if ignore_modules and isinstance(value, types.ModuleType):
|
67
|
+
continue
|
68
|
+
if ignore_functions and isinstance(value, types.FunctionType):
|
69
|
+
continue
|
70
|
+
if ignore_classes and isinstance(value, type):
|
71
|
+
continue
|
72
|
+
try:
|
73
|
+
_quick_print(f" {var} = {repr(value)}", lineno)
|
74
|
+
except (AttributeError, TypeError, Exception):
|
75
|
+
_quick_print(f" {var} = [unreadable]", lineno)
|
76
|
+
|
77
|
+
_quick_print("=" * 60, lineno)
|
78
|
+
|
79
|
+
return trace_lines
|
80
|
+
|
81
|
+
return trace_lines
|
82
|
+
|
83
|
+
|
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(
|
86
|
+
ignore_special_vars=ignore_special_vars,
|
87
|
+
ignore_functions=ignore_functions,
|
88
|
+
ignore_classes=ignore_classes,
|
89
|
+
ignore_modules=ignore_modules,
|
90
|
+
ignore_file_path=ignore_file_path
|
91
|
+
)
|
92
|
+
sys.settrace(trace_func)
|
93
|
+
sys._getframe().f_trace = trace_func
|
94
|
+
_quick_print("Tracing activated.")
|
95
|
+
|
96
|
+
|
97
|
+
def deactivate_tracing():
|
98
|
+
sys.settrace(None)
|
99
|
+
_quick_print("Tracing deactivated.")
|
100
|
+
|
40
101
|
def pp(msg='caca', subdir=None, pps=3):
|
41
102
|
import os, subprocess
|
42
103
|
os_current = os.getcwd()
|
@@ -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.5.dist-info/RECORD
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
kenenet/__init__.py,sha256=4s6SRN2YKzN8rC54qcwS7DKa7ZBmSiPy9zpO4_Qtr6k,2478
|
2
|
-
kenenet-0.2.5.dist-info/METADATA,sha256=unx9dXlxg8CXe8ZVZhM-KnO89d4jIk1xwADR68LKOnk,513
|
3
|
-
kenenet-0.2.5.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
4
|
-
kenenet-0.2.5.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
-
kenenet-0.2.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|