55class Raffle :
66 @classmethod
77 def INPUT_TYPES (s ):
8- print ("Initializing Raffle INPUT_TYPES" )
98 extension_path = os .path .normpath (os .path .dirname (__file__ ))
10- print (f"Extension path: { extension_path } " )
119
1210 return {
1311 "required" : {
@@ -67,10 +65,8 @@ def INPUT_TYPES(s):
6765
6866 def _load_taglist (self , filename , taglists_must_include_tags = None , exclude_tags = None , seed = 0 ):
6967 """Load a line from a file, finding taglists that match required tags"""
70- print (f"Attempting to load taglist: { filename } " )
7168 extension_path = os .path .normpath (os .path .dirname (__file__ ))
7269 filepath = os .path .join (extension_path , "lists" , filename )
73- print (f"Loading from filepath: { filepath } " )
7470
7571 try :
7672 valid_taglists = []
@@ -103,13 +99,11 @@ def _load_taglist(self, filename, taglists_must_include_tags=None, exclude_tags=
10399 return valid_taglists
104100
105101 except Exception as e :
106- print (f"Error loading { filename } : { str (e )} " )
107102 raise
108103
109104 return []
110105
111106 def normalize_tags (self , tag_string ):
112- print (f"Normalizing tag string of length: { len (tag_string )} " )
113107 """
114108 Normalize a string of tags to a consistent format:
115109 - Convert spaces to underscores within tags
@@ -153,26 +147,17 @@ def process_tags(self, exclude_taglists_containing, taglists_must_include, seed,
153147 use_general = True , use_questionable = False , use_sensitive = False , use_explicit = False ,
154148 exclude_categories = "" ):
155149
156- print ("\n === Starting Raffle Process ===" )
157- print (f"Process ID: { os .getpid ()} " )
158- print (f"Current working directory: { os .getcwd ()} " )
159-
160150 # Add directory existence check
161151 extension_path = os .path .normpath (os .path .dirname (__file__ ))
162152 lists_path = os .path .join (extension_path , "lists" )
163- print (f"Extension path: { extension_path } " )
164- print (f"Lists directory path: { lists_path } " )
165153
166154 if not os .path .exists (lists_path ):
167- print (f"ERROR: Lists directory not found at { lists_path } " )
168155 raise ValueError (f"Lists directory not found at { lists_path } " )
169156
170157 # Check for categorized tags file
171158 categorized_tags_file_path = os .path .join (lists_path , "categorized_tags.txt" )
172- print (f"Checking categorized tags file: { categorized_tags_file_path } " )
173159
174160 if not os .path .exists (categorized_tags_file_path ):
175- print (f"ERROR: Categorized tags file not found at { categorized_tags_file_path } " )
176161 raise ValueError (f"Categorized tags file not found at { categorized_tags_file_path } " )
177162
178163 # Define all available categories and handle exclusions
@@ -231,7 +216,6 @@ def process_tags(self, exclude_taglists_containing, taglists_must_include, seed,
231216 error_msg = (f"Error: Invalid category names: { ', ' .join (invalid_categories )} . "
232217 f"Please check the Debug info output for a complete list of valid categories. "
233218 f"Category names may have changed in a new version." )
234- print (error_msg )
235219 raise ValueError (error_msg )
236220
237221 # Set up categories dictionary - enable all categories except excluded ones
@@ -246,7 +230,6 @@ def process_tags(self, exclude_taglists_containing, taglists_must_include, seed,
246230 try :
247231 with open (categorized_tags_file_path , 'r' , encoding = 'utf-8' ) as f :
248232 content = f .read ()
249- print (f"Successfully read { len (content )} bytes from categorized tags file" )
250233
251234 for line in content .splitlines ():
252235 line = line .strip ()
@@ -264,20 +247,13 @@ def process_tags(self, exclude_taglists_containing, taglists_must_include, seed,
264247 allowed_tags .append (tag ) # Add the complete tag
265248
266249 except Exception as e :
267- print (f"ERROR reading categorized tags file: { str (e )} " )
268250 raise
269251
270- print (f"Loaded { len (allowed_tags )} allowed tags" )
271-
272252 # Parse exclude and include lists
273- print ("Processing exclude/include lists..." )
274253 excluded_tags = set (self .normalize_tags (exclude_taglists_containing ))
275254 included_tags = set (self .normalize_tags (taglists_must_include ))
276- print (f"Excluded tags count: { len (excluded_tags )} " )
277- print (f"Included tags count: { len (included_tags )} " )
278255
279256 # Collect all valid taglists from all enabled files
280- print ("Loading tag lists..." )
281257 all_valid_taglists = []
282258
283259 if use_general :
@@ -290,7 +266,6 @@ def process_tags(self, exclude_taglists_containing, taglists_must_include, seed,
290266 all_valid_taglists .extend (self ._load_taglist ("taglists-explicit.txt" , included_tags , excluded_tags , seed ))
291267
292268 if not all_valid_taglists :
293- print ("No valid taglists found in any enabled category!" )
294269 raise ValueError ("No tags available - no matching taglists found" )
295270
296271 # Use seed to shuffle and select from all valid taglists
@@ -305,47 +280,35 @@ def process_tags(self, exclude_taglists_containing, taglists_must_include, seed,
305280 _ , unfiltered_taglist = selected_taglist
306281 # Normalize the unfiltered taglist for consistency in output
307282 unfiltered_taglist = ', ' .join (self .normalize_tags (unfiltered_taglist ))
308- print (f"Selected taglist: { unfiltered_taglist } " )
309- print (f"Selected from { len (all_valid_taglists )} total valid taglists" )
310283
311284 # Split the taglist into individual tags and normalize them
312285 individual_tags = self .normalize_tags (unfiltered_taglist )
313286
314287 # Filter tags using allowed_tags and maintain order
315- print ("Filtering tags..." )
316288 allowed_tags_set = set (allowed_tags ) # For faster lookup
317289 filtered_tags = [tag for tag in individual_tags if tag in allowed_tags_set ]
318- print (f"Tags after allowed filter: { len (filtered_tags )} " )
319290
320291 try :
321292 filtered_tags .sort (key = lambda x : allowed_tags .index (x ) if x in allowed_tags else len (allowed_tags ))
322293 except Exception as e :
323- print (f"Error during sorting: { e } " )
324294 raise
325295
326296 # Remove excluded tags
327297 filtered_tags = [tag for tag in filtered_tags if tag not in excluded_tags ]
328- print (f"Tags after exclusion filter: { len (filtered_tags )} " )
329298
330299 # Process negative prompt tags
331- print ("Processing negative prompt..." )
332300 negative_tags = set (self .normalize_tags (negative_prompt ))
333301 filtered_tags = [tag for tag in filtered_tags if tag not in negative_tags ]
334- print (f"Final tag count: { len (filtered_tags )} " )
335302
336303 # Process negative prompt 2 tags
337- print ("Processing negative prompt 2..." )
338304 negative_tags_2 = set (self .normalize_tags (negative_prompt_2 ))
339305 filtered_tags = [tag for tag in filtered_tags if tag not in negative_tags_2 ]
340- print (f"Final tag count after negative prompt 2: { len (filtered_tags )} " )
341306
342- print ("Preparing return values..." )
343307 debug_info = f"Pool of Taglists size: { len (all_valid_taglists )} \n \n { categories_debug } "
344308 return_values = (
345309 ', ' .join (filtered_tags ),
346310 unfiltered_taglist ,
347311 debug_info
348312 )
349- print ("Process complete" )
350313
351314 return return_values
0 commit comments