kenenet 1.0.6__py3-none-any.whl → 1.0.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 +4 -27
- {kenenet-1.0.6.dist-info → kenenet-1.0.8.dist-info}/METADATA +1 -1
- kenenet-1.0.8.dist-info/RECORD +5 -0
- kenenet-1.0.6.dist-info/RECORD +0 -5
- {kenenet-1.0.6.dist-info → kenenet-1.0.8.dist-info}/WHEEL +0 -0
- {kenenet-1.0.6.dist-info → kenenet-1.0.8.dist-info}/top_level.txt +0 -0
    
        kenenet/__init__.py
    CHANGED
    
    | @@ -40,7 +40,7 @@ def get_pos(key='f10', kill=False): | |
| 40 40 | 
             
                        if kill:
         | 
| 41 41 | 
             
                            quick_print('killing process')
         | 
| 42 42 | 
             
                            zhmiscellany.misc.die()
         | 
| 43 | 
            -
                quick_print(f'Press {key} when ever you want the location')
         | 
| 43 | 
            +
                quick_print(f'Press {key} when ever you want the location, automatically copies coords/rgb to clipboard')
         | 
| 44 44 | 
             
                frame = inspect.currentframe().f_back
         | 
| 45 45 | 
             
                lineno = frame.f_lineno
         | 
| 46 46 | 
             
                _get_pos(key, kill)
         | 
| @@ -51,9 +51,9 @@ def timer(clock=1): | |
| 51 51 | 
             
                    frame = inspect.currentframe().f_back
         | 
| 52 52 | 
             
                    lineno = frame.f_lineno
         | 
| 53 53 | 
             
                    if clock == 1:
         | 
| 54 | 
            -
                        quick_print(f'Timer took \033[97m{elapsed}\033[0m seconds', f'{ | 
| 54 | 
            +
                        quick_print(f'Timer took \033[97m{elapsed}\033[0m seconds', f'{timings[clock][1]}-{lineno}')
         | 
| 55 55 | 
             
                    else:
         | 
| 56 | 
            -
                        quick_print(f'Timer {clock} took \033[97m{elapsed}\033[0m seconds', f'{ | 
| 56 | 
            +
                        quick_print(f'Timer {clock} took \033[97m{elapsed}\033[0m seconds', f'{timings[clock][1]}-{lineno}')
         | 
| 57 57 | 
             
                    del timings[clock]
         | 
| 58 58 | 
             
                    return elapsed
         | 
| 59 59 | 
             
                else:
         | 
| @@ -286,7 +286,7 @@ _block_timings = defaultdict(float) | |
| 286 286 | 
             
            _current_context = None
         | 
| 287 287 | 
             
            _line_start_time = None
         | 
| 288 288 | 
             
            _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' | 
| 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'}
         | 
| 290 290 | 
             
            _seen_lines = set()  # Track lines we've already processed
         | 
| 291 291 | 
             
            _current_function = None
         | 
| 292 292 | 
             
            _function_lines = defaultdict(set)  # Track which lines belong to which function
         | 
| @@ -359,15 +359,12 @@ def time_code(label=None): | |
| 359 359 | 
             
                    _seen_lines.clear()  # Reset seen lines
         | 
| 360 360 | 
             
                    _function_lines.clear()  # Reset function lines mapping
         | 
| 361 361 |  | 
| 362 | 
            -
                    # Define the trace function
         | 
| 363 362 | 
             
                    def trace_function(frame, event, arg):
         | 
| 364 363 | 
             
                        global _line_start_time, _stack, _seen_lines, _current_function, _function_lines
         | 
| 365 364 |  | 
| 366 | 
            -
                        # Skip tracking for package code
         | 
| 367 365 | 
             
                        if _is_package_code(frame.f_code.co_filename):
         | 
| 368 366 | 
             
                            return trace_function
         | 
| 369 367 |  | 
| 370 | 
            -
                        # Track function calls and returns
         | 
| 371 368 | 
             
                        if event == 'call':
         | 
| 372 369 | 
             
                            func_name = frame.f_code.co_name
         | 
| 373 370 |  | 
| @@ -384,12 +381,10 @@ def time_code(label=None): | |
| 384 381 | 
             
                            if _stack:
         | 
| 385 382 | 
             
                                func_name, start_time = _stack.pop()
         | 
| 386 383 |  | 
| 387 | 
            -
                                # Skip recording generated constructs
         | 
| 388 384 | 
             
                                if not _is_generated_construct(func_name):
         | 
| 389 385 | 
             
                                    elapsed = time.time() - start_time
         | 
| 390 386 | 
             
                                    _block_timings[f"Function: {func_name}"] += elapsed
         | 
| 391 387 |  | 
| 392 | 
            -
                                # Reset current function if we're returning from it
         | 
| 393 388 | 
             
                                if _current_function == func_name and _stack:
         | 
| 394 389 | 
             
                                    _current_function = _stack[-1][0]
         | 
| 395 390 | 
             
                                elif not _stack:
         | 
| @@ -397,37 +392,28 @@ def time_code(label=None): | |
| 397 392 | 
             
                            return None
         | 
| 398 393 |  | 
| 399 394 | 
             
                        elif event == 'line':
         | 
| 400 | 
            -
                            # Get current line information
         | 
| 401 395 | 
             
                            lineno = frame.f_lineno
         | 
| 402 396 | 
             
                            line_content = linecache.getline(frame.f_code.co_filename, lineno).strip()
         | 
| 403 397 | 
             
                            line_id = f"{lineno}:{line_content}"
         | 
| 404 398 |  | 
| 405 | 
            -
                            # Skip empty lines or comments
         | 
| 406 399 | 
             
                            if not line_content or line_content.startswith('#'):
         | 
| 407 400 | 
             
                                return trace_function
         | 
| 408 401 |  | 
| 409 | 
            -
                            # Check if we should stop tracing
         | 
| 410 402 | 
             
                            if "time_code" in line_content and _current_context is not None:
         | 
| 411 | 
            -
                                # This might be the ending call, let's continue execution
         | 
| 412 403 | 
             
                                return trace_function
         | 
| 413 404 |  | 
| 414 | 
            -
                            # Skip recording if we're in a generated construct
         | 
| 415 405 | 
             
                            if _current_function and _is_generated_construct(_current_function):
         | 
| 416 406 | 
             
                                return trace_function
         | 
| 417 407 |  | 
| 418 | 
            -
                            # Record elapsed time since last line
         | 
| 419 408 | 
             
                            current_time = time.time()
         | 
| 420 409 | 
             
                            if _line_start_time is not None:
         | 
| 421 410 | 
             
                                elapsed = current_time - _line_start_time
         | 
| 422 411 |  | 
| 423 | 
            -
                                # Track relationship between current function and lines
         | 
| 424 412 | 
             
                                if _current_function:
         | 
| 425 413 | 
             
                                    _function_lines[_current_function].add(line_id)
         | 
| 426 414 |  | 
| 427 | 
            -
                                # For timing, we always record all executions to get accurate timing
         | 
| 428 415 | 
             
                                _timings[_current_context].append((lineno, line_content, elapsed, line_id in _seen_lines))
         | 
| 429 416 |  | 
| 430 | 
            -
                                # For loop timings, first check if it's a loop
         | 
| 431 417 | 
             
                                if re.match(r'\s*(for|while)\s+', line_content):
         | 
| 432 418 | 
             
                                    loop_id = f"Loop at line {lineno}: {line_content[:40]}{'...' if len(line_content) > 40 else ''}"
         | 
| 433 419 | 
             
                                    _block_timings[loop_id] += elapsed
         | 
| @@ -435,12 +421,10 @@ def time_code(label=None): | |
| 435 421 | 
             
                                # Mark this line as seen
         | 
| 436 422 | 
             
                                _seen_lines.add(line_id)
         | 
| 437 423 |  | 
| 438 | 
            -
                            # Set new start time for next line
         | 
| 439 424 | 
             
                            _line_start_time = current_time
         | 
| 440 425 |  | 
| 441 426 | 
             
                        return trace_function
         | 
| 442 427 |  | 
| 443 | 
            -
                    # Start tracing
         | 
| 444 428 | 
             
                    sys.settrace(trace_function)
         | 
| 445 429 |  | 
| 446 430 | 
             
                else:
         | 
| @@ -453,7 +437,6 @@ def time_code(label=None): | |
| 453 437 | 
             
                        quick_print(f"No times recorded: {context}")
         | 
| 454 438 | 
             
                        return
         | 
| 455 439 |  | 
| 456 | 
            -
                    # Process timings to aggregate by line but only show first occurrence
         | 
| 457 440 | 
             
                    aggregated_timings = defaultdict(float)
         | 
| 458 441 | 
             
                    first_occurrences = {}
         | 
| 459 442 |  | 
| @@ -461,18 +444,15 @@ def time_code(label=None): | |
| 461 444 | 
             
                        line_id = f"{lineno}:{line_content}"
         | 
| 462 445 | 
             
                        aggregated_timings[line_id] += elapsed
         | 
| 463 446 |  | 
| 464 | 
            -
                        # Store the first occurrence information
         | 
| 465 447 | 
             
                        if line_id not in first_occurrences:
         | 
| 466 448 | 
             
                            first_occurrences[line_id] = (lineno, line_content, elapsed)
         | 
| 467 449 |  | 
| 468 | 
            -
                    # Create sorted list of first occurrences with total time
         | 
| 469 450 | 
             
                    display_timings = [
         | 
| 470 451 | 
             
                        (lineno, line_content, aggregated_timings[f"{lineno}:{line_content}"])
         | 
| 471 452 | 
             
                        for lineno, line_content, _ in first_occurrences.values()
         | 
| 472 453 | 
             
                        if line_content not in _ignore_line
         | 
| 473 454 | 
             
                    ]
         | 
| 474 455 |  | 
| 475 | 
            -
                    # Sort by elapsed time (descending)
         | 
| 476 456 | 
             
                    sorted_timings = sorted(display_timings, key=lambda x: x[2], reverse=True)
         | 
| 477 457 |  | 
| 478 458 | 
             
                    quick_print(f"\nTime spent on each line: {context}")
         | 
| @@ -493,11 +473,9 @@ def time_code(label=None): | |
| 493 473 | 
             
                        quick_print(f"{'Chunks':^40} | {'Time':>12} | {'% of Time Spent':>10}")
         | 
| 494 474 | 
             
                        quick_print("-" * 80)
         | 
| 495 475 |  | 
| 496 | 
            -
                        # Sort block timings by time
         | 
| 497 476 | 
             
                        sorted_blocks = sorted(_block_timings.items(), key=lambda x: x[1], reverse=True)
         | 
| 498 477 |  | 
| 499 478 | 
             
                        for block, elapsed in sorted_blocks:
         | 
| 500 | 
            -
                            # Filter out generated constructs and ignored lines
         | 
| 501 479 | 
             
                            if (not any(ignore in block for ignore in _ignore_line) and
         | 
| 502 480 | 
             
                                    not any(pattern in block for pattern in _ignore_function_patterns)):
         | 
| 503 481 | 
             
                                percentage = (elapsed / total_time) * 100 if total_time > 0 else 0
         | 
| @@ -505,7 +483,6 @@ def time_code(label=None): | |
| 505 483 |  | 
| 506 484 | 
             
                        quick_print("-" * 80)
         | 
| 507 485 |  | 
| 508 | 
            -
                    # Clear the timing data for this context
         | 
| 509 486 | 
             
                    del _timings[context]
         | 
| 510 487 | 
             
                    _block_timings.clear()
         | 
| 511 488 | 
             
                    _seen_lines.clear()
         | 
| @@ -0,0 +1,5 @@ | |
| 1 | 
            +
            kenenet/__init__.py,sha256=oC4cUSYUIAFkI15eYO98XTFtFWM8-t_2h0mQc4ueG7c,20122
         | 
| 2 | 
            +
            kenenet-1.0.8.dist-info/METADATA,sha256=V5C3p7SASz7s7tb9KCyAkwe9b7mUgyqHNVkzPmMDRnM,1693
         | 
| 3 | 
            +
            kenenet-1.0.8.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
         | 
| 4 | 
            +
            kenenet-1.0.8.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
         | 
| 5 | 
            +
            kenenet-1.0.8.dist-info/RECORD,,
         | 
    
        kenenet-1.0.6.dist-info/RECORD
    DELETED
    
    | @@ -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,,
         | 
| 
            File without changes
         | 
| 
            File without changes
         |