kenenet 1.0.6__py3-none-any.whl → 1.0.9__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,14 +1,9 @@
1
- import inspect, sys, zhmiscellany, keyboard, mss, time, linecache, types, os, random, pyperclip, inspect, datetime, atexit, re
1
+ import sys, zhmiscellany, keyboard, mss, time, linecache, os, random, pyperclip, inspect, re
2
2
  import numpy as np
3
3
  from PIL import Image
4
4
  from collections import defaultdict
5
-
6
- from pydub import AudioSegment
7
- from pydub.playback import play
8
- import random
9
5
  import threading
10
6
  import pyaudio
11
- import time
12
7
  from pydub import AudioSegment
13
8
  from zhmiscellany._processing_supportfuncs import _ray_init_thread
14
9
  import zhmiscellany.processing
@@ -40,7 +35,7 @@ def get_pos(key='f10', kill=False):
40
35
  if kill:
41
36
  quick_print('killing process')
42
37
  zhmiscellany.misc.die()
43
- quick_print(f'Press {key} when ever you want the location')
38
+ quick_print(f'Press {key} when ever you want the location, automatically copies coords/rgb to clipboard')
44
39
  frame = inspect.currentframe().f_back
45
40
  lineno = frame.f_lineno
46
41
  _get_pos(key, kill)
@@ -51,9 +46,9 @@ def timer(clock=1):
51
46
  frame = inspect.currentframe().f_back
52
47
  lineno = frame.f_lineno
53
48
  if clock == 1:
54
- quick_print(f'Timer took \033[97m{elapsed}\033[0m seconds', f'{lineno}-{timings[clock][1]}')
49
+ quick_print(f'Timer took \033[97m{elapsed}\033[0m seconds', f'{timings[clock][1]}-{lineno}')
55
50
  else:
56
- quick_print(f'Timer {clock} took \033[97m{elapsed}\033[0m seconds', f'{lineno}-{timings[clock][1]}')
51
+ quick_print(f'Timer {clock} took \033[97m{elapsed}\033[0m seconds', f'{timings[clock][1]}-{lineno}')
57
52
  del timings[clock]
58
53
  return elapsed
59
54
  else:
@@ -286,7 +281,7 @@ _block_timings = defaultdict(float)
286
281
  _current_context = None
287
282
  _line_start_time = None
288
283
  _stack = []
289
- _ignore_line = {'frame = inspect.currentframe().f_back', 'filename = frame.f_code.co_filename', 'if _current_context is None:', 'sys.settrace(None)', 'Function: currentframe', 'return sys._getframe(1) if hasattr(sys, "_getframe") else None', ' Function: recurser', 'Function: <listcomp>', 'Function: here', 'Function: _array_repr_implementation', 'Function: wrapper', 'Function: array2string', 'Function: _array2string', 'Function: _formatArray', 'Function: _extendLine_pretty', 'Function: _extendLine', 'Function: __call__', 'Function: _var', 'Function: _std', 'Function: std', 'Function: _leading_trailing', 'Function: __init__'}
284
+ _ignore_line = {'frame = inspect.currentframe().f_back', 'filename = frame.f_code.co_filename', 'if _current_context is None:', 'sys.settrace(None)', 'Function: currentframe', 'return sys._getframe(1) if hasattr(sys, "_getframe") else None'}
290
285
  _seen_lines = set() # Track lines we've already processed
291
286
  _current_function = None
292
287
  _function_lines = defaultdict(set) # Track which lines belong to which function
@@ -303,14 +298,6 @@ _ignore_function_patterns = {
303
298
  '<module>'
304
299
  }
305
300
 
306
- # Initialize site-packages directories
307
- import sys
308
- import os
309
- import inspect
310
- import time
311
- import re
312
- import linecache
313
- from collections import defaultdict
314
301
 
315
302
  # Get site-packages directories from sys.path
316
303
  for path in sys.path:
@@ -359,15 +346,12 @@ def time_code(label=None):
359
346
  _seen_lines.clear() # Reset seen lines
360
347
  _function_lines.clear() # Reset function lines mapping
361
348
 
362
- # Define the trace function
363
349
  def trace_function(frame, event, arg):
364
350
  global _line_start_time, _stack, _seen_lines, _current_function, _function_lines
365
351
 
366
- # Skip tracking for package code
367
352
  if _is_package_code(frame.f_code.co_filename):
368
353
  return trace_function
369
354
 
370
- # Track function calls and returns
371
355
  if event == 'call':
372
356
  func_name = frame.f_code.co_name
373
357
 
@@ -384,12 +368,10 @@ def time_code(label=None):
384
368
  if _stack:
385
369
  func_name, start_time = _stack.pop()
386
370
 
387
- # Skip recording generated constructs
388
371
  if not _is_generated_construct(func_name):
389
372
  elapsed = time.time() - start_time
390
373
  _block_timings[f"Function: {func_name}"] += elapsed
391
374
 
392
- # Reset current function if we're returning from it
393
375
  if _current_function == func_name and _stack:
394
376
  _current_function = _stack[-1][0]
395
377
  elif not _stack:
@@ -397,37 +379,28 @@ def time_code(label=None):
397
379
  return None
398
380
 
399
381
  elif event == 'line':
400
- # Get current line information
401
382
  lineno = frame.f_lineno
402
383
  line_content = linecache.getline(frame.f_code.co_filename, lineno).strip()
403
384
  line_id = f"{lineno}:{line_content}"
404
385
 
405
- # Skip empty lines or comments
406
386
  if not line_content or line_content.startswith('#'):
407
387
  return trace_function
408
388
 
409
- # Check if we should stop tracing
410
389
  if "time_code" in line_content and _current_context is not None:
411
- # This might be the ending call, let's continue execution
412
390
  return trace_function
413
391
 
414
- # Skip recording if we're in a generated construct
415
392
  if _current_function and _is_generated_construct(_current_function):
416
393
  return trace_function
417
394
 
418
- # Record elapsed time since last line
419
395
  current_time = time.time()
420
396
  if _line_start_time is not None:
421
397
  elapsed = current_time - _line_start_time
422
398
 
423
- # Track relationship between current function and lines
424
399
  if _current_function:
425
400
  _function_lines[_current_function].add(line_id)
426
401
 
427
- # For timing, we always record all executions to get accurate timing
428
402
  _timings[_current_context].append((lineno, line_content, elapsed, line_id in _seen_lines))
429
403
 
430
- # For loop timings, first check if it's a loop
431
404
  if re.match(r'\s*(for|while)\s+', line_content):
432
405
  loop_id = f"Loop at line {lineno}: {line_content[:40]}{'...' if len(line_content) > 40 else ''}"
433
406
  _block_timings[loop_id] += elapsed
@@ -435,12 +408,10 @@ def time_code(label=None):
435
408
  # Mark this line as seen
436
409
  _seen_lines.add(line_id)
437
410
 
438
- # Set new start time for next line
439
411
  _line_start_time = current_time
440
412
 
441
413
  return trace_function
442
414
 
443
- # Start tracing
444
415
  sys.settrace(trace_function)
445
416
 
446
417
  else:
@@ -453,7 +424,6 @@ def time_code(label=None):
453
424
  quick_print(f"No times recorded: {context}")
454
425
  return
455
426
 
456
- # Process timings to aggregate by line but only show first occurrence
457
427
  aggregated_timings = defaultdict(float)
458
428
  first_occurrences = {}
459
429
 
@@ -461,18 +431,15 @@ def time_code(label=None):
461
431
  line_id = f"{lineno}:{line_content}"
462
432
  aggregated_timings[line_id] += elapsed
463
433
 
464
- # Store the first occurrence information
465
434
  if line_id not in first_occurrences:
466
435
  first_occurrences[line_id] = (lineno, line_content, elapsed)
467
436
 
468
- # Create sorted list of first occurrences with total time
469
437
  display_timings = [
470
438
  (lineno, line_content, aggregated_timings[f"{lineno}:{line_content}"])
471
439
  for lineno, line_content, _ in first_occurrences.values()
472
440
  if line_content not in _ignore_line
473
441
  ]
474
442
 
475
- # Sort by elapsed time (descending)
476
443
  sorted_timings = sorted(display_timings, key=lambda x: x[2], reverse=True)
477
444
 
478
445
  quick_print(f"\nTime spent on each line: {context}")
@@ -493,11 +460,9 @@ def time_code(label=None):
493
460
  quick_print(f"{'Chunks':^40} | {'Time':>12} | {'% of Time Spent':>10}")
494
461
  quick_print("-" * 80)
495
462
 
496
- # Sort block timings by time
497
463
  sorted_blocks = sorted(_block_timings.items(), key=lambda x: x[1], reverse=True)
498
464
 
499
465
  for block, elapsed in sorted_blocks:
500
- # Filter out generated constructs and ignored lines
501
466
  if (not any(ignore in block for ignore in _ignore_line) and
502
467
  not any(pattern in block for pattern in _ignore_function_patterns)):
503
468
  percentage = (elapsed / total_time) * 100 if total_time > 0 else 0
@@ -505,7 +470,6 @@ def time_code(label=None):
505
470
 
506
471
  quick_print("-" * 80)
507
472
 
508
- # Clear the timing data for this context
509
473
  del _timings[context]
510
474
  _block_timings.clear()
511
475
  _seen_lines.clear()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kenenet
3
- Version: 1.0.6
3
+ Version: 1.0.9
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=yOaRSn4iUD4CGESEdd05q6xFKnCAzjw9zLG5h8gEthk,19835
2
+ kenenet-1.0.9.dist-info/METADATA,sha256=k4fJLSyeDiBUL8sPAeCOEkdRYRpNFDMr3KV_-Y6wl0k,1693
3
+ kenenet-1.0.9.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
4
+ kenenet-1.0.9.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
5
+ kenenet-1.0.9.dist-info/RECORD,,
@@ -1,5 +0,0 @@
1
- kenenet/__init__.py,sha256=9-wRVH9wkUX6ivZSU5qp1bmW3zLQ5uzOOs9Fz-wiwhM,21796
2
- kenenet-1.0.6.dist-info/METADATA,sha256=eAlg0SPPCd5loqaHciquo2WsrHeoJSwlOVOFO0M7e0Y,1693
3
- kenenet-1.0.6.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
4
- kenenet-1.0.6.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
5
- kenenet-1.0.6.dist-info/RECORD,,