You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
current_games= [] # Reset game accumulator for the next section
397
+
398
+
header_body=stripped[3:].strip() # Extract body after "-- " prefix
399
+
console_name=header_body.split(":")[0].strip() # Extract console name before the colon
400
+
current_console=console_name# Set active console to parsed name
401
+
402
+
elifstripped.startswith("- ") or (stripped.startswith("-") andnotstripped.startswith("--")): # Detect game entry line
403
+
ifcurrent_consoleisNone: # Skip orphaned game lines without a parent console section
404
+
print(f"{BackgroundColors.YELLOW}Warning: Game line found before any console section — skipping. File: {BackgroundColors.CYAN}{filepath}{BackgroundColors.YELLOW}, Line: {BackgroundColors.CYAN}{stripped}{Style.RESET_ALL}") # Log warning
405
+
continue# Skip orphaned line
406
+
407
+
normalized=normalize_game_line(stripped, filepath, current_console) # Normalize and validate game line
408
+
409
+
ifnormalized: # Append only valid normalized game lines
410
+
current_games.append(normalized) # Accumulate valid game line
411
+
412
+
ifcurrent_consoleisnotNone: # Flush final console section after loop ends
413
+
sections.append({"name": current_console, "games": current_games}) # Append last section
414
+
415
+
forsectioninsections: # Sort games alphabetically within each console section
416
+
section["games"] =sorted(section["games"], key=lambdaline: line[2:].lower()) # Sort by game name case-insensitively
417
+
418
+
returnsections# Return fully parsed and sorted sections
0 commit comments