From 19f26ce0dca28dbc7c898fb7f07b653fa90e1eb7 Mon Sep 17 00:00:00 2001 From: ChrisColeTech Date: Tue, 11 Mar 2025 20:07:21 -0400 Subject: [PATCH] handle index out of bounds errors --- line_counter.py | 9 ++++++--- pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/line_counter.py b/line_counter.py index 1b3109d..df336c8 100644 --- a/line_counter.py +++ b/line_counter.py @@ -180,12 +180,15 @@ class TextFileLineReader: if mode == "index": # Use the provided index directly if index < 0 or index >= len(lines): - print(f"Invalid line index `{index}`. Using index 0.") - index = 0 + print(f"Index `{index}` is out of bounds. Resetting to 0.") + index = 0 # Reset to 0 if out of bounds line_text = lines[index] else: # Automatic mode: use the current_index and increment it - line_text = lines[self.current_index % len(lines)] + if self.current_index >= len(lines): + print("Reached the end of the file. Resetting to 0.") + self.current_index = 0 # Reset to 0 if at the end + line_text = lines[self.current_index] self.current_index += 1 # Increment the index for the next run return (line_text,) diff --git a/pyproject.toml b/pyproject.toml index 7ac2df8..be695b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-line-counter" description = "This custom node package for ComfyUI is designed to streamline your workflow with powerful file-counting capabilities." -version = "1.0.6" +version = "1.0.7" license = {file = "LICENSE"} [project.urls]