From d225c7b618dd65bc424a323defcd9daef846cd65 Mon Sep 17 00:00:00 2001 From: wiktorlaskowski <117634264+wiktorlaskowski@users.noreply.github.com> Date: Tue, 20 May 2025 18:26:19 +0200 Subject: [PATCH 1/5] Delete ReadMe --- README.md | 26 -------------------------- X | 1 + 2 files changed, 1 insertion(+), 26 deletions(-) delete mode 100644 README.md create mode 100644 X diff --git a/README.md b/README.md deleted file mode 100644 index 04d0d70..0000000 --- a/README.md +++ /dev/null @@ -1,26 +0,0 @@ -![minitrace_light](https://github.com/user-attachments/assets/8033396d-e759-4df6-ba4c-d14a493b4be5) -# Minitrace Python Library -Shorten those verbose Python tracebacks to something more compact, comes with saving! - -Ever seen thove __long__ tracebacks? Welp, this is for you! -There are requirements: -# REQUIREMENTS -- __Colorama__ colorcodes the line with the error. -- __Tkinter__ for the file dialouge, probably installed but best to check. -# SETUP -1. First import the library. ___DO NOT USE `import minitrace` USE `from minitrace import MiniTrace`___ -2. Initialize the library using the init function - `MiniTrace.init()` -# `Full script`: - ```Python - from minitrace import MiniTrace - MiniTrace.init() - ``` -# HOW TO CUSTOMIZE -Use `MiniTrace.settracelengthto()` to set the length -### Example: -```Python -MiniTrace.settracelengthto(10) -``` -# NOTES: -Pip does not support minitrace, you will need to download the file from raw code to activate it. diff --git a/X b/X new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/X @@ -0,0 +1 @@ + From 7a5ce3c17b4668d8e62126e9ed6e85f71df738ed Mon Sep 17 00:00:00 2001 From: wiktorlaskowski <117634264+wiktorlaskowski@users.noreply.github.com> Date: Tue, 20 May 2025 18:28:04 +0200 Subject: [PATCH 2/5] Delete --- XX | 1 + minitrace.py | 72 ---------------------------------------------------- 2 files changed, 1 insertion(+), 72 deletions(-) create mode 100644 XX delete mode 100644 minitrace.py diff --git a/XX b/XX new file mode 100644 index 0000000..d3f5a12 --- /dev/null +++ b/XX @@ -0,0 +1 @@ + diff --git a/minitrace.py b/minitrace.py deleted file mode 100644 index c2745b2..0000000 --- a/minitrace.py +++ /dev/null @@ -1,72 +0,0 @@ -import sys -import traceback -from colorama import Fore, Style, init -from tkinter import Tk, filedialog - -init(autoreset=True) - -class MiniTrace: - _trace_length = 5 - - @classmethod - def settracelengthto(cls, length): - if not isinstance(length, int) or length <= 0: - raise ValueError("Trace length must be a positive integer.") - cls._trace_length = length - - @classmethod - def format_traceback(cls, exc_type, exc_value, tb): - trace_lines = traceback.extract_tb(tb)[-cls._trace_length:] - formatted_lines = [] - - for idx, line in enumerate(reversed(trace_lines), 1): - code_line = line.line.strip() if line.line else "No code found" - if idx == 1: - formatted_lines.append(f"{Fore.RED}{line.lineno} >>> {code_line}{Style.RESET_ALL}") - else: - formatted_lines.append(f"{line.lineno} >>> {code_line}") - - expectation = f"{Fore.RED}{exc_type.__name__}: {exc_value}{Style.RESET_ALL}" - formatted_lines.append(expectation) - formatted_traceback = "\n".join(formatted_lines) - return f"Traceback: Most recent calls\n{formatted_traceback}" - - @classmethod - def format_traceback_plain(cls, exc_type, exc_value, tb): - trace_lines = traceback.extract_tb(tb)[-cls._trace_length:] - formatted_lines = [ - f"{line.lineno} >>> {line.line.strip() if line.line else 'No code found'}" - for line in reversed(trace_lines) - ] - expectation = f"{exc_type.__name__}: {exc_value}" - return f"Traceback: Most recent calls\n" + "\n".join(formatted_lines) - - @classmethod - def init(cls): - sys.excepthook = cls.handle_exception - - @classmethod - def handle_exception(cls, exc_type, exc_value, tb): - formatted_trace = cls.format_traceback(exc_type, exc_value, tb) - print(formatted_trace, file=sys.stderr) - try: - response = input("Would you like to save this traceback to a file? (y/n): ").strip().lower() - if response == "y": - cls.save_to_file(exc_type, exc_value, tb) - except KeyboardInterrupt: - print("\nSave operation canceled due to KeyboardInterrupt.") - - @classmethod - def save_to_file(cls, exc_type, exc_value, tb): - plain_traceback = cls.format_traceback_plain(exc_type, exc_value, tb) - Tk().withdraw() - file_path = filedialog.asksaveasfilename( - defaultextension=".log", - filetypes=[("Log files", "*.log"), ("Text files", "*.txt"), ("No extension iles", ".")] - ) - if file_path: - with open(file_path, "w") as file: - file.write(plain_traceback) - print(f"Traceback saved to {file_path}") - else: - print("Save operation canceled.") From f24e6711aaba2a9f96bb9997589a00577e843f91 Mon Sep 17 00:00:00 2001 From: wiktorlaskowski <117634264+wiktorlaskowski@users.noreply.github.com> Date: Tue, 20 May 2025 18:29:14 +0200 Subject: [PATCH 3/5] Delete --- XXX | 1 + minitracelegacy1.py | 70 --------------------------------------------- 2 files changed, 1 insertion(+), 70 deletions(-) create mode 100644 XXX delete mode 100644 minitracelegacy1.py diff --git a/XXX b/XXX new file mode 100644 index 0000000..d3f5a12 --- /dev/null +++ b/XXX @@ -0,0 +1 @@ + diff --git a/minitracelegacy1.py b/minitracelegacy1.py deleted file mode 100644 index 234af63..0000000 --- a/minitracelegacy1.py +++ /dev/null @@ -1,70 +0,0 @@ -import sys -import traceback -from colorama import Fore, Style, init -from tkinter import Tk, filedialog - -init(autoreset=True) - - -class MiniTrace: - _trace_length = 5 - - @classmethod - def settracelengthto(cls, length): - if not isinstance(length, int) or length <= 0: - raise ValueError("Trace length must be a positive integer.") - cls._trace_length = length - - @classmethod - def format_traceback(cls, exc_type, exc_value, tb): - trace_lines = traceback.extract_tb(tb)[-cls._trace_length:] - formatted_lines = [] - - for idx, line in enumerate(reversed(trace_lines), 1): - code_line = line.line.strip() if line.line else "No code found" - if idx == 1: - formatted_lines.append(f"{Fore.RED}{line.lineno} >>> {code_line}{Style.RESET_ALL}") - else: - formatted_lines.append(f"{line.lineno} >>> {code_line}") - - expectation = f"{Fore.RED}{exc_type.__name__}: {exc_value}{Style.RESET_ALL}" - formatted_lines.append(expectation) - formatted_traceback = "\n".join(formatted_lines) - return f"Traceback: Most recent calls\n{formatted_traceback}" - - @classmethod - def format_traceback_plain(cls, exc_type, exc_value, tb): - trace_lines = traceback.extract_tb(tb)[-cls._trace_length:] - formatted_lines = [ - f"{line.lineno} >>> {line.line.strip() if line.line else 'No code found'}" - for line in reversed(trace_lines) - ] - expectation = f"{exc_type.__name__}: {exc_value}" - return f"Traceback: Most recent calls\n" + "\n".join(formatted_lines) - - @classmethod - def hook(cls): - sys.excepthook = cls.handle_exception - - @classmethod - def handle_exception(cls, exc_type, exc_value, tb): - formatted_trace = cls.format_traceback(exc_type, exc_value, tb) - print(formatted_trace, file=sys.stderr) - response = input("Would you like to save this traceback to a file? (y/n): ").strip().lower() - if response == "y": - cls.save_to_file(exc_type, exc_value, tb) - - @classmethod - def save_to_file(cls, exc_type, exc_value, tb): - plain_traceback = cls.format_traceback_plain(exc_type, exc_value, tb) - Tk().withdraw() - file_path = filedialog.asksaveasfilename( - defaultextension=".log", - filetypes=[("Log files", "*.log"), ("Text files", "*.txt"), ("All files", "*.*")] - ) - if file_path: - with open(file_path, "w") as file: - file.write(plain_traceback) - print(f"Traceback saved to {file_path}") - else: - print("Save operation canceled.") From 48536a1fb81121f23586621d41a7f26acbacef26 Mon Sep 17 00:00:00 2001 From: wiktorlaskowski <117634264+wiktorlaskowski@users.noreply.github.com> Date: Tue, 20 May 2025 18:38:00 +0200 Subject: [PATCH 4/5] Create index.html --- index.html | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 0000000..4267acc --- /dev/null +++ b/index.html @@ -0,0 +1,10 @@ + + + + The Minitrace landing page! + + +

Minitrace

+ The traceback library + + From 490e5bc18153868bf9628307c1ffc5f96bdf23c0 Mon Sep 17 00:00:00 2001 From: wiktorlaskowski <117634264+wiktorlaskowski@users.noreply.github.com> Date: Tue, 20 May 2025 22:19:58 +0200 Subject: [PATCH 5/5] Update index.html --- index.html | 209 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 201 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 4267acc..a5ceb46 100644 --- a/index.html +++ b/index.html @@ -1,10 +1,203 @@ - - - - The Minitrace landing page! - - + + + + + + Minitrace Python Library + + + + + +

Minitrace

- The traceback library - +

Minimal tracebacks. Maximum clarity.

+
+ +
+
+

About the Project

+

+ Minitrace is a focused debugging utility that compresses and simplifies Python tracebacks + so that developers can immediately spot the root cause of runtime errors. +

+

+ With built-in highlighting and optional GUI prompts, it is especially handy for developers + working across environments, from terminal sessions to small GUI-based applications. +

+
+ +
+

Features

+ +
+ +
+

Installation

+

Option 1: Clone the GitHub repository

+
+ +
git clone https://github.com/wiktorlaskowski/Minitrace-Python-Library.git
+
+

Option 2: Download the Python file directly

+
+ +
Download minitrace.py from the repository and place it in your project folder.
+
+
+ +
+

Usage Example

+

Import and initialize the library:

+
+ +
from minitrace import MiniTrace
+
+MiniTrace.init()
+# Your code here...
+
+
+ +
+

Customization

+

Adjust the length of visible traceback:

+
+ +
MiniTrace.settracelengthto(10)
+
+
+ +
+

Project Philosophy

+

+ Minitrace helps reduce noise. Instead of adding complexity, it strips Python's traceback output down + to what’s essential. Built for speed and clarity, Minitrace stays out of the way until it’s needed. +

+
+ +
+

Support and Contributions

+

+ Have a suggestion, bug report, or idea? Open an issue or submit a pull request on GitHub. +

+
+ +
+ + Explore the Code on GitHub + +
+
+ + + + +