kenenet 0.5.8__py3-none-any.whl → 0.6.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.
- kenenet/__init__.py +32 -44
- {kenenet-0.5.8.dist-info → kenenet-0.6.0.dist-info}/METADATA +1 -1
- kenenet-0.6.0.dist-info/RECORD +5 -0
- kenenet-0.5.8.dist-info/RECORD +0 -5
- {kenenet-0.5.8.dist-info → kenenet-0.6.0.dist-info}/WHEEL +0 -0
- {kenenet-0.5.8.dist-info → kenenet-0.6.0.dist-info}/top_level.txt +0 -0
kenenet/__init__.py
CHANGED
@@ -11,7 +11,6 @@ def quick_print(message, l=None):
|
|
11
11
|
if l: sys.stdout.write(f"\033[38;2;0;255;26m{l} || {message}\033[0m\n")
|
12
12
|
else: sys.stdout.write(f"\033[38;2;0;255;26m {message}\033[0m\n")
|
13
13
|
|
14
|
-
|
15
14
|
def get_pos(key='f10', kill=False):
|
16
15
|
coord_rgb = []
|
17
16
|
coords = []
|
@@ -48,8 +47,7 @@ def timer(clock=1):
|
|
48
47
|
else:
|
49
48
|
timings[clock] = time.time()
|
50
49
|
|
51
|
-
|
52
|
-
class Config:
|
50
|
+
class _Config:
|
53
51
|
EXCLUDED_NAMES = {'Config', 'VariableTracker', 'track_variables', 'stop_tracking',
|
54
52
|
'track_frame', 'sys', 'inspect', 'types', 'datetime',
|
55
53
|
'self', 'cls', 'args', 'kwargs', '__class__'}
|
@@ -57,18 +55,13 @@ class Config:
|
|
57
55
|
SHOW_TIMESTAMPS = True
|
58
56
|
EXCLUDE_INTERNALS = True
|
59
57
|
|
60
|
-
|
61
|
-
# ==========================================================================
|
62
|
-
# CORE TRACKING FUNCTIONALITY
|
63
|
-
# ==========================================================================
|
64
|
-
|
65
|
-
class VariableTracker:
|
58
|
+
class _VariableTracker:
|
66
59
|
_instance = None
|
67
60
|
|
68
61
|
@classmethod
|
69
|
-
def
|
62
|
+
def _get_instance(cls):
|
70
63
|
if cls._instance is None:
|
71
|
-
cls._instance =
|
64
|
+
cls._instance = _VariableTracker()
|
72
65
|
return cls._instance
|
73
66
|
|
74
67
|
def __init__(self):
|
@@ -76,72 +69,67 @@ class VariableTracker:
|
|
76
69
|
self.frame_locals = {}
|
77
70
|
self.global_vars = {}
|
78
71
|
|
79
|
-
def
|
72
|
+
def _format_value(self, value):
|
80
73
|
try:
|
81
74
|
return repr(value)
|
82
75
|
except:
|
83
76
|
return f"<{type(value).__name__} object>"
|
84
77
|
|
85
|
-
def
|
86
|
-
|
87
|
-
|
78
|
+
def _print_change(self, name, old, new, scope="Global"):
|
79
|
+
frame = inspect.currentframe().f_back
|
80
|
+
lineno = frame.f_lineno
|
81
|
+
quick_print(f"{scope} '{name}' changed from {self._format_value(old)} -> {self._format_value(new)}", lineno)
|
88
82
|
|
89
83
|
def _should_track(self, name):
|
90
|
-
return not (name.startswith('_') and name not in ('__name__', '__file__')) and name not in
|
84
|
+
return not (name.startswith('_') and name not in ('__name__', '__file__')) and name not in _Config.EXCLUDED_NAMES
|
91
85
|
|
92
|
-
def
|
86
|
+
def _start_tracking(self, module_name):
|
93
87
|
if self.active: return
|
94
88
|
module = sys.modules[module_name]
|
95
89
|
self.global_vars = {name: value for name, value in module.__dict__.items() if self._should_track(name)}
|
96
|
-
sys.settrace(
|
90
|
+
sys.settrace(_track_frame)
|
97
91
|
self.active = True
|
98
|
-
|
92
|
+
frame = inspect.currentframe().f_back
|
93
|
+
lineno = frame.f_lineno
|
94
|
+
quick_print(f"Started debugging", lineno)
|
99
95
|
|
100
|
-
def
|
96
|
+
def _stop_tracking(self):
|
101
97
|
if not self.active: return
|
102
98
|
sys.settrace(None)
|
103
99
|
self.frame_locals.clear()
|
104
100
|
self.global_vars.clear()
|
105
101
|
self.active = False
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
# ==========================================================================
|
110
|
-
# TRACE FUNCTION
|
111
|
-
# ==========================================================================
|
102
|
+
frame = inspect.currentframe().f_back
|
103
|
+
lineno = frame.f_lineno
|
104
|
+
quick_print(f"Stopped debugging", lineno)
|
112
105
|
|
113
|
-
def
|
114
|
-
tracker =
|
115
|
-
if not tracker.active or event != 'line': return
|
106
|
+
def _track_frame(frame, event, arg):
|
107
|
+
tracker = _VariableTracker._get_instance()
|
108
|
+
if not tracker.active or event != 'line': return _track_frame
|
116
109
|
scope = "Global" if frame.f_code.co_name == '<module>' else f"Local in '{frame.f_code.co_name}'"
|
117
110
|
current_vars = {name: value for name, value in (frame.f_locals if scope != "Global" else frame.f_globals).items() if tracker._should_track(name)}
|
118
111
|
|
119
112
|
if scope == "Global":
|
120
113
|
for name, value in current_vars.items():
|
121
114
|
if name not in tracker.global_vars:
|
122
|
-
tracker.
|
115
|
+
tracker._print_change(name, None, value, scope)
|
123
116
|
elif tracker.global_vars[name] != value:
|
124
|
-
tracker.
|
117
|
+
tracker._print_change(name, tracker.global_vars[name], value, scope)
|
125
118
|
tracker.global_vars.update(current_vars)
|
126
119
|
else:
|
127
120
|
frame_id = id(frame)
|
128
121
|
if frame_id not in tracker.frame_locals:
|
129
122
|
for name, value in current_vars.items():
|
130
|
-
tracker.
|
123
|
+
tracker._print_change(name, None, value, scope)
|
131
124
|
else:
|
132
125
|
for name, value in current_vars.items():
|
133
126
|
if name not in tracker.frame_locals[frame_id]:
|
134
|
-
tracker.
|
127
|
+
tracker._print_change(name, None, value, scope)
|
135
128
|
elif tracker.frame_locals[frame_id][name] != value:
|
136
|
-
tracker.
|
129
|
+
tracker._print_change(name, tracker.frame_locals[frame_id][name], value, scope)
|
137
130
|
tracker.frame_locals[frame_id] = current_vars
|
138
131
|
if event == 'return' and scope != "Global": del tracker.frame_locals[id(frame)]
|
139
|
-
return
|
140
|
-
|
141
|
-
|
142
|
-
# ==========================================================================
|
143
|
-
# PUBLIC API
|
144
|
-
# ==========================================================================
|
132
|
+
return _track_frame
|
145
133
|
|
146
134
|
def debug():
|
147
135
|
global debug_mode
|
@@ -149,12 +137,12 @@ def debug():
|
|
149
137
|
debug_mode = True
|
150
138
|
caller_frame = inspect.currentframe().f_back
|
151
139
|
module_name = caller_frame.f_globals['__name__']
|
152
|
-
tracker =
|
153
|
-
tracker.
|
154
|
-
caller_frame.f_trace =
|
140
|
+
tracker = _VariableTracker._get_instance()
|
141
|
+
tracker._start_tracking(module_name)
|
142
|
+
caller_frame.f_trace = _track_frame
|
155
143
|
else:
|
156
144
|
debug_mode = False
|
157
|
-
|
145
|
+
_VariableTracker._get_instance()._stop_tracking()
|
158
146
|
|
159
147
|
def pp(msg='caca', subdir=None, pps=3):
|
160
148
|
import os, subprocess
|
@@ -0,0 +1,5 @@
|
|
1
|
+
kenenet/__init__.py,sha256=HJO0bt8-HQS9tz4eR6AlvLF8jOtygHnITBhCPW1d4dM,8328
|
2
|
+
kenenet-0.6.0.dist-info/METADATA,sha256=k8nNkFwqc8UCU6vV-Bnl_GNWinykkuwnihiPMpkIJZs,633
|
3
|
+
kenenet-0.6.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
4
|
+
kenenet-0.6.0.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
+
kenenet-0.6.0.dist-info/RECORD,,
|
kenenet-0.5.8.dist-info/RECORD
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
kenenet/__init__.py,sha256=ns2VCwN8GcUMfZ83Mb_v7Dxaq-3O2LnjCC0Lki9kGhI,8823
|
2
|
-
kenenet-0.5.8.dist-info/METADATA,sha256=j7LXBBf4u8DJNOLv6zuNpCiKs-CbKaMY6UejBQyvkzY,633
|
3
|
-
kenenet-0.5.8.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
4
|
-
kenenet-0.5.8.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
-
kenenet-0.5.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|