From fffdbdb40fafb8b39bcbae5a831ec939d5e96918 Mon Sep 17 00:00:00 2001 From: Legende <68666984+xLegende@users.noreply.github.com> Date: Sat, 12 Apr 2025 17:04:58 +0200 Subject: [PATCH] Add files via upload --- categorized_prompt_formatter.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/categorized_prompt_formatter.py b/categorized_prompt_formatter.py index 0bae6dc..dd0d5b8 100644 --- a/categorized_prompt_formatter.py +++ b/categorized_prompt_formatter.py @@ -12,13 +12,11 @@ try: import yaml except ImportError: print("PyYAML is not installed. Please run install.py or install it manually.", file=sys.stderr) - # Optionally, try to run install.py automatically if possible, - # but this can be complex depending on environment. Best to rely on user action. - # raise ImportError("PyYAML is required but not installed. Run install.py.") from None + # --- Constants --- NODE_NAME = "Categorized Prompt Formatter" -NODE_REPO = "ComfyUI-Prompt-Formatter" # For finding relative paths +NODE_REPO = "ComfyUI-Prompt-Formatter" # --- Helper Functions --- @@ -38,7 +36,7 @@ def find_yaml_file(filename): return Path(filename) else: print(f"Warning: Absolute path specified but not found: {filename}") - return None # Explicit absolute path not found + return None # 2. Check relative to the custom node's directory node_dir = get_node_directory() @@ -70,7 +68,7 @@ def find_yaml_file(filename): return input_dir_path break # Stop searching up parent = search_dir.parent - if parent == search_dir: break # Reached root + if parent == search_dir: break search_dir = parent except Exception as e: @@ -170,7 +168,7 @@ class CategorizedPromptFormatter: def format_prompt(self, prompt, category_definition_file, output_template, input_delimiter=",", output_delimiter=", ", strip_whitespace=True, - case_sensitive_matching=False, handle_weights=True, + case_sensitive_matching=False, match_underscores_spaces=True, handle_weights=True, unmatched_tag_handling="discard"): # --- 1. Load Category Definitions ---