kenenet 0.2.4__py3-none-any.whl → 0.2.7__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 +99 -9
- {kenenet-0.2.4.dist-info → kenenet-0.2.7.dist-info}/METADATA +1 -1
- kenenet-0.2.7.dist-info/RECORD +5 -0
- kenenet-0.2.4.dist-info/RECORD +0 -5
- {kenenet-0.2.4.dist-info → kenenet-0.2.7.dist-info}/WHEEL +0 -0
- {kenenet-0.2.4.dist-info → kenenet-0.2.7.dist-info}/top_level.txt +0 -0
kenenet/__init__.py
CHANGED
@@ -1,15 +1,10 @@
|
|
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
|
-
def adding(a, b):
|
6
|
-
return a + b
|
7
4
|
|
8
5
|
def _quick_print(message, l=None):
|
9
|
-
if l:
|
10
|
-
|
11
|
-
else:
|
12
|
-
sys.stdout.write(f"\033[38;2;0;255;26m {message}\033[0m\n")
|
6
|
+
if l: sys.stdout.write(f"\033[38;2;0;255;26m{l} || {message}\033[0m\n")
|
7
|
+
else: sys.stdout.write(f"\033[38;2;0;255;26m {message}\033[0m\n")
|
13
8
|
|
14
9
|
|
15
10
|
def get_pos(key='f10', kill=False):
|
@@ -31,7 +26,7 @@ def get_pos(key='f10', kill=False):
|
|
31
26
|
lineno = frame.f_lineno
|
32
27
|
zhmiscellany.processing.start_daemon(target=_get_pos, args=(key, lineno, ))
|
33
28
|
|
34
|
-
def
|
29
|
+
def timer(clock=1):
|
35
30
|
if clock in timings:
|
36
31
|
elapsed = time.time() - timings[clock]
|
37
32
|
frame = inspect.currentframe().f_back
|
@@ -41,7 +36,102 @@ def time_it(clock=1):
|
|
41
36
|
else:
|
42
37
|
timings[clock] = time.time()
|
43
38
|
|
39
|
+
|
40
|
+
def _make_trace_function(ignore_special_vars=False, ignore_functions=False, ignore_classes=False, ignore_modules=False, ignore_file_path=False):
|
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
|
+
"""
|
52
|
+
special_vars = {
|
53
|
+
"__name__", "__doc__", "__package__", "__loader__",
|
54
|
+
"__spec__", "__annotations__", "__file__", "__cached__"
|
55
|
+
}
|
56
|
+
|
57
|
+
def trace_lines(frame, event, arg):
|
58
|
+
if event == 'line':
|
59
|
+
filename = frame.f_code.co_filename
|
60
|
+
lineno = frame.f_lineno
|
61
|
+
code_line = linecache.getline(filename, lineno).strip()
|
62
|
+
# Header for readability.
|
63
|
+
header = f"Executing line {lineno}:" if ignore_file_path else f"Executing {filename}:{lineno}:"
|
64
|
+
_quick_print("=" * 60)
|
65
|
+
_quick_print(header, lineno)
|
66
|
+
_quick_print(f" {code_line}", lineno)
|
67
|
+
_quick_print("-" * 60, lineno)
|
68
|
+
_quick_print("Local Variables:", lineno)
|
69
|
+
for var, value in frame.f_locals.items():
|
70
|
+
if ignore_special_vars and var in special_vars:
|
71
|
+
continue
|
72
|
+
if ignore_modules and isinstance(value, types.ModuleType):
|
73
|
+
continue
|
74
|
+
if ignore_functions and isinstance(value, types.FunctionType):
|
75
|
+
continue
|
76
|
+
if ignore_classes and isinstance(value, type):
|
77
|
+
continue
|
78
|
+
_quick_print(f" {var} = {value}", lineno)
|
79
|
+
_quick_print("=" * 60, lineno)
|
80
|
+
return trace_lines
|
44
81
|
|
82
|
+
return trace_lines
|
83
|
+
|
84
|
+
|
85
|
+
def dbug(ignore_special_vars=True, ignore_functions=True, ignore_classes=True, ignore_modules=True, ignore_file_path=True):
|
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(
|
97
|
+
ignore_special_vars=ignore_special_vars,
|
98
|
+
ignore_functions=ignore_functions,
|
99
|
+
ignore_classes=ignore_classes,
|
100
|
+
ignore_modules=ignore_modules,
|
101
|
+
ignore_file_path=ignore_file_path
|
102
|
+
)
|
103
|
+
sys.settrace(trace_func)
|
104
|
+
# Force the current (global) frame to be traced.
|
105
|
+
sys._getframe().f_trace = trace_func
|
106
|
+
_quick_print("Tracing activated.")
|
107
|
+
|
108
|
+
|
109
|
+
def dbug_stop():
|
110
|
+
"""Deactivates the tracing."""
|
111
|
+
sys.settrace(None)
|
112
|
+
_quick_print("Tracing deactivated.")
|
113
|
+
|
114
|
+
def pp(msg='caca', subdir=None, pps=3):
|
115
|
+
import os, subprocess
|
116
|
+
os_current = os.getcwd()
|
117
|
+
os.chdir(os.path.dirname(__file__))
|
118
|
+
if subdir: os.chdir(subdir)
|
119
|
+
def push(message):
|
120
|
+
os.system('git add .')
|
121
|
+
os.system(f'git commit -m "{message}"')
|
122
|
+
os.system('git push -u origin master')
|
123
|
+
def pull():
|
124
|
+
os.system('git pull origin master')
|
125
|
+
def push_pull(message):
|
126
|
+
push(message)
|
127
|
+
pull()
|
128
|
+
result = subprocess.run(['git', 'rev-list', '--count', '--all'], capture_output=True, text=True)
|
129
|
+
result = int(result.stdout.strip()) + 1
|
130
|
+
for i in range(pps):
|
131
|
+
push_pull(msg)
|
132
|
+
_quick_print('PP finished B======D')
|
133
|
+
os.chdir(os_current)
|
134
|
+
|
45
135
|
class k:
|
46
136
|
pass
|
47
137
|
|
@@ -0,0 +1,5 @@
|
|
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,,
|
kenenet-0.2.4.dist-info/RECORD
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
kenenet/__init__.py,sha256=TA46WAqRKSmxUt2IgtF0o0Fb8IAnCZ2jBjbN5n2MiTc,1819
|
2
|
-
kenenet-0.2.4.dist-info/METADATA,sha256=_VhwsXfqtHY-E31j_Cux-zJED8zcJFlVcPVuo8PIXm0,513
|
3
|
-
kenenet-0.2.4.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
4
|
-
kenenet-0.2.4.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
-
kenenet-0.2.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|