kenenet 0.5.4__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 CHANGED
@@ -1,10 +1,10 @@
1
1
  import inspect, sys, zhmiscellany, keyboard, mss, time, linecache, types, os, random, pyperclip, inspect, datetime, atexit
2
2
  import numpy as np
3
3
  from PIL import Image
4
- global timings, ospid
5
4
  from pydub import AudioSegment
6
5
  from pydub.playback import play
7
- ospid = None
6
+ global timings, ospid, debug_mode
7
+ ospid, debug_mode = None, False
8
8
  timings = {}
9
9
 
10
10
  def quick_print(message, l=None):
@@ -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,22 +136,31 @@ 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
 
146
- def debug():
143
+ debug_mode = False # Global variable to track if debugging is enabled
144
+
145
+ def track_variables():
147
146
  caller_frame = inspect.currentframe().f_back
148
147
  module_name = caller_frame.f_globals['__name__']
149
148
  tracker = VariableTracker.get_instance()
150
149
  tracker.start_tracking(module_name)
151
150
  caller_frame.f_trace = track_frame
152
151
 
153
-
154
- def stop_debug():
152
+ def stop_tracking():
155
153
  VariableTracker.get_instance().stop_tracking()
156
154
 
155
+ def debug():
156
+ global debug_mode
157
+ if not debug_mode:
158
+ debug_mode = True
159
+ track_variables()
160
+ else:
161
+ debug_mode = False
162
+ stop_tracking()
163
+
157
164
  def pp(msg='caca', subdir=None, pps=3):
158
165
  import os, subprocess
159
166
  os_current = os.getcwd()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kenenet
3
- Version: 0.5.4
3
+ Version: 0.5.6
4
4
  Summary: dude what the fuck even is this package
5
5
  Home-page: https://www.youtube.com/@KiddyKene
6
6
  Author: kiddykene
@@ -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,,
@@ -1,5 +0,0 @@
1
- kenenet/__init__.py,sha256=GS824qMEe9UAtIhawdibaE7w1vAgh99xjTcRytwnt7A,8678
2
- kenenet-0.5.4.dist-info/METADATA,sha256=YisdJRTL7i5prYfL02AHZ1iZCww5vLDyLycZGVGhflM,633
3
- kenenet-0.5.4.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
4
- kenenet-0.5.4.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
5
- kenenet-0.5.4.dist-info/RECORD,,