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
Copy file name to clipboardExpand all lines: Games Collection Manager/main.py
+61-45Lines changed: 61 additions & 45 deletions
Original file line number
Diff line number
Diff line change
@@ -110,7 +110,7 @@ class BackgroundColors: # Colors for the terminal
110
110
FIXED_METADATA_BLOCK_STRIPPED=tuple(line.strip() forlineinFIXED_METADATA_BLOCK) # Stripped version for safe parser comparisons
111
111
112
112
# Regex Constants:
113
-
GAME_LINE_REGEX=re.compile(r"^-\s+(.+?)\s+(\d{4})\.\s*(✅|❓|📀|📦)?$") # Pattern matching a valid normalized game line
113
+
GAME_LINE_REGEX=re.compile(r"^-\s+(.+?)\s+(\d{4})\.\s*((?:✅|❓|📀|🧹|📦)(?:\s+(?:✅|❓|📀|🧹|📦))*)?$") # Pattern matching a valid normalized game line with optional multi-icon suffix
114
114
YEAR_EXTRACT_REGEX=re.compile(r"(\d{4})") # Pattern extracting a 4-digit year from raw text
print(f"{BackgroundColors.YELLOW}Warning: Missing game name in entry — skipping. File: {BackgroundColors.CYAN}{filepath}{BackgroundColors.YELLOW}, Console: {BackgroundColors.CYAN}{console_name}{BackgroundColors.YELLOW}, Line: {BackgroundColors.CYAN}{raw_line.strip()}{Style.RESET_ALL}") # Log warning with context
486
487
return""# Return empty to signal skip
487
488
488
-
ificon: # Build normalized line with icon when present
489
-
returnf"- {game_name}{year}. {icon}"# Return canonical format with icon
489
+
ificons: # Build normalized line with icon suffix when present
490
+
returnf"- {game_name}{year}. {' '.join(icons)}"# Return canonical format with multi-icon suffix
490
491
returnf"- {game_name}{year}."# Return canonical format without icon
491
492
492
493
exceptExceptionase: # Catch unexpected errors during normalization
493
494
print(f"{BackgroundColors.RED}Error normalizing game line {BackgroundColors.CYAN}{raw_line.strip()}{BackgroundColors.RED}: {e}{Style.RESET_ALL}") # Log error
494
495
return""# Return empty to signal skip
495
496
496
497
498
+
defparse_game_icons(normalized_line: str) ->list:
499
+
"""
500
+
Extract all icons from an already-normalized game line.
501
+
502
+
:param normalized_line: A normalized game line in canonical format.
503
+
:return: List of icon strings in appearance order, or empty list if absent.
504
+
"""
505
+
506
+
try: # Wrap extraction logic to ensure safe parsing behavior
507
+
if"."notinnormalized_line: # Verify canonical delimiter exists before parsing tail tokens
508
+
return [] # Return empty when no canonical suffix can exist
509
+
510
+
suffix=normalized_line.split(".", 1)[1].strip() # Extract suffix region after canonical year delimiter
511
+
512
+
ifsuffix=="": # Verify suffix contains at least one token
513
+
return [] # Return empty when no icon suffix is present
514
+
515
+
tokens=suffix.split() # Split suffix into whitespace-separated tokens
516
+
return [tokenfortokenintokensiftokeninVALID_ICONS] # Return all valid icon tokens preserving order
0 commit comments