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