kenenet 0.5.5__py3-none-any.whl → 0.5.6__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 +14 -16
- {kenenet-0.5.5.dist-info → kenenet-0.5.6.dist-info}/METADATA +1 -1
- kenenet-0.5.6.dist-info/RECORD +5 -0
- kenenet-0.5.5.dist-info/RECORD +0 -5
- {kenenet-0.5.5.dist-info → kenenet-0.5.6.dist-info}/WHEEL +0 -0
- {kenenet-0.5.5.dist-info → kenenet-0.5.6.dist-info}/top_level.txt +0 -0
kenenet/__init__.py
CHANGED
@@ -57,38 +57,37 @@ class Config:
|
|
57
57
|
SHOW_TIMESTAMPS = True
|
58
58
|
EXCLUDE_INTERNALS = True
|
59
59
|
|
60
|
-
|
61
60
|
# ==========================================================================
|
62
61
|
# CORE TRACKING FUNCTIONALITY
|
63
62
|
# ==========================================================================
|
64
63
|
|
65
64
|
class VariableTracker:
|
66
65
|
_instance = None
|
67
|
-
|
66
|
+
|
68
67
|
@classmethod
|
69
68
|
def get_instance(cls):
|
70
69
|
if cls._instance is None:
|
71
70
|
cls._instance = VariableTracker()
|
72
71
|
return cls._instance
|
73
|
-
|
72
|
+
|
74
73
|
def __init__(self):
|
75
74
|
self.active = False
|
76
75
|
self.frame_locals = {}
|
77
76
|
self.global_vars = {}
|
78
|
-
|
77
|
+
|
79
78
|
def format_value(self, value):
|
80
79
|
try:
|
81
80
|
return repr(value)
|
82
81
|
except:
|
83
82
|
return f"<{type(value).__name__} object>"
|
84
|
-
|
83
|
+
|
85
84
|
def print_change(self, name, old, new, scope="Global"):
|
86
85
|
timestamp = f"[{datetime.datetime.now().strftime('%H:%M:%S.%f')[:-3]}] " if Config.SHOW_TIMESTAMPS else ""
|
87
86
|
print(f"{timestamp}{scope} '{name}' changed from {self.format_value(old)} to {self.format_value(new)}")
|
88
|
-
|
87
|
+
|
89
88
|
def _should_track(self, name):
|
90
89
|
return not (name.startswith('_') and name not in ('__name__', '__file__')) and name not in Config.EXCLUDED_NAMES
|
91
|
-
|
90
|
+
|
92
91
|
def start_tracking(self, module_name):
|
93
92
|
if self.active: return
|
94
93
|
module = sys.modules[module_name]
|
@@ -96,7 +95,7 @@ class VariableTracker:
|
|
96
95
|
sys.settrace(track_frame)
|
97
96
|
self.active = True
|
98
97
|
print(f"Variable tracking started at {datetime.datetime.now().strftime('%H:%M:%S.%f')[:-3]}")
|
99
|
-
|
98
|
+
|
100
99
|
def stop_tracking(self):
|
101
100
|
if not self.active: return
|
102
101
|
sys.settrace(None)
|
@@ -105,7 +104,6 @@ class VariableTracker:
|
|
105
104
|
self.active = False
|
106
105
|
print(f"Variable tracking stopped at {datetime.datetime.now().strftime('%H:%M:%S.%f')[:-3]}")
|
107
106
|
|
108
|
-
|
109
107
|
# ==========================================================================
|
110
108
|
# TRACE FUNCTION
|
111
109
|
# ==========================================================================
|
@@ -115,7 +113,7 @@ def track_frame(frame, event, arg):
|
|
115
113
|
if not tracker.active or event != 'line': return track_frame
|
116
114
|
scope = "Global" if frame.f_code.co_name == '<module>' else f"Local in '{frame.f_code.co_name}'"
|
117
115
|
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
|
-
|
116
|
+
|
119
117
|
if scope == "Global":
|
120
118
|
for name, value in current_vars.items():
|
121
119
|
if name not in tracker.global_vars:
|
@@ -138,30 +136,30 @@ def track_frame(frame, event, arg):
|
|
138
136
|
if event == 'return' and scope != "Global": del tracker.frame_locals[id(frame)]
|
139
137
|
return track_frame
|
140
138
|
|
141
|
-
|
142
139
|
# ==========================================================================
|
143
140
|
# PUBLIC API
|
144
141
|
# ==========================================================================
|
145
142
|
|
143
|
+
debug_mode = False # Global variable to track if debugging is enabled
|
146
144
|
|
147
|
-
def
|
145
|
+
def track_variables():
|
148
146
|
caller_frame = inspect.currentframe().f_back
|
149
147
|
module_name = caller_frame.f_globals['__name__']
|
150
148
|
tracker = VariableTracker.get_instance()
|
151
149
|
tracker.start_tracking(module_name)
|
152
150
|
caller_frame.f_trace = track_frame
|
153
151
|
|
154
|
-
def
|
152
|
+
def stop_tracking():
|
155
153
|
VariableTracker.get_instance().stop_tracking()
|
156
|
-
|
154
|
+
|
157
155
|
def debug():
|
158
156
|
global debug_mode
|
159
157
|
if not debug_mode:
|
160
158
|
debug_mode = True
|
161
|
-
|
159
|
+
track_variables()
|
162
160
|
else:
|
163
161
|
debug_mode = False
|
164
|
-
|
162
|
+
stop_tracking()
|
165
163
|
|
166
164
|
def pp(msg='caca', subdir=None, pps=3):
|
167
165
|
import os, subprocess
|
@@ -0,0 +1,5 @@
|
|
1
|
+
kenenet/__init__.py,sha256=q2j8V3Lo-xxhoWdVPdtHJKB3pKcYeufp8K6quRuVN5g,8937
|
2
|
+
kenenet-0.5.6.dist-info/METADATA,sha256=VtbLZ5__iQ54DtZm9ixzcuHTrOLeyLsHo9Fqg4xN8II,633
|
3
|
+
kenenet-0.5.6.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
4
|
+
kenenet-0.5.6.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
+
kenenet-0.5.6.dist-info/RECORD,,
|
kenenet-0.5.5.dist-info/RECORD
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
kenenet/__init__.py,sha256=GtOqZSuMhBCe-yD44-H1CGZ5FI1oquvCXowv3-GwKd8,8891
|
2
|
-
kenenet-0.5.5.dist-info/METADATA,sha256=ErNyvBrwaNUKjMvufOQW7R_GvgYccy2SWDIdEYxgNpg,633
|
3
|
-
kenenet-0.5.5.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
4
|
-
kenenet-0.5.5.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
-
kenenet-0.5.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|