@@ -88,58 +88,38 @@ def update_readme(stats):
8888 'HackerEarth' : ('HackerEarth' , 'blue' ),
8989 }
9090
91+ # Platform patterns for updating counts in README table
92+ PLATFORM_PATTERNS = {
93+ 'Codeforces' : r'(🔴\s+Codeforces.*?<td align="center"><strong>)[^<]+' ,
94+ 'LeetCode' : r'(🟢\s+LeetCode.*?<td align="center"><strong>)[^<]+' ,
95+ 'Vjudge' : r'(🟣\s+Vjudge.*?<td align="center"><strong>)[^<]+' ,
96+ 'AtCoder' : r'(🟠\s+AtCoder.*?<td align="center"><strong>)[^<]+' ,
97+ 'CodeChef' : r'(🟤\s+CodeChef.*?<td align="center"><strong>)[^<]+' ,
98+ 'CSES' : r'(⚪\s+CSES.*?<td align="center"><strong>)[^<]+' ,
99+ 'Toph' : r'(🔵\s+Toph.*?<td align="center"><strong>)[^<]+' ,
100+ 'LightOJ' : r'(🟡\s+LightOJ.*?<td align="center"><strong>)[^<]+' ,
101+ 'SPOJ' : r'(🟩\s+SPOJ.*?<td align="center"><strong>)[^<]+' ,
102+ 'HackerRank' : r'(💚\s+HackerRank.*?<td align="center"><strong>)[^<]+' ,
103+ 'UVa' : r'(🔷\s+UVa.*?<td align="center"><strong>)[^<]+' ,
104+ 'HackerEarth' : r'(🌐\s+HackerEarth.*?<td align="center"><strong>)[^<]+' ,
105+ }
106+
91107 # Update individual platform counts
92108 for platform , count in stats .items ():
93- platform_name , color = platform_mapping .get (platform , (platform , 'blue' ))
94-
95109 if count is None :
96110 # Handle failed fetches - mark as "Will be updated manually"
97- # Update solved count in table to show it couldn't be fetched
98- platform_patterns = {
99- 'Codeforces' : r'(🔴\s+Codeforces.*?<td align="center"><strong>)[^<]+' ,
100- 'LeetCode' : r'(🟢\s+LeetCode.*?<td align="center"><strong>)[^<]+' ,
101- 'Vjudge' : r'(🟣\s+Vjudge.*?<td align="center"><strong>)[^<]+' ,
102- 'AtCoder' : r'(🟠\s+AtCoder.*?<td align="center"><strong>)[^<]+' ,
103- 'CodeChef' : r'(🟤\s+CodeChef.*?<td align="center"><strong>)[^<]+' ,
104- 'CSES' : r'(⚪\s+CSES.*?<td align="center"><strong>)[^<]+' ,
105- 'Toph' : r'(🔵\s+Toph.*?<td align="center"><strong>)[^<]+' ,
106- 'LightOJ' : r'(🟡\s+LightOJ.*?<td align="center"><strong>)[^<]+' ,
107- 'SPOJ' : r'(🟩\s+SPOJ.*?<td align="center"><strong>)[^<]+' ,
108- 'HackerRank' : r'(💚\s+HackerRank.*?<td align="center"><strong>)[^<]+' ,
109- 'UVa' : r'(🔷\s+UVa.*?<td align="center"><strong>)[^<]+' ,
110- 'HackerEarth' : r'(🌐\s+HackerEarth.*?<td align="center"><strong>)[^<]+' ,
111- }
112-
113- if platform in platform_patterns :
114- pattern = platform_patterns [platform ]
111+ if platform in PLATFORM_PATTERNS :
112+ pattern = PLATFORM_PATTERNS [platform ]
115113 replacement = rf'\g<1>⏳ Will be updated manually'
116114 readme_content = re .sub (pattern , replacement , readme_content , flags = re .DOTALL )
117115 continue
118116
117+ platform_name , color = platform_mapping .get (platform , (platform , 'blue' ))
119118 percentage = calculate_percentage (count , total )
120119
121120 # Update solved count in table
122- # Pattern: <td align="center"><strong>NUMBER</strong></td>
123- # We need to find the row for this platform and update the count
124-
125- # Different platforms have different emoji markers
126- platform_patterns = {
127- 'Codeforces' : r'(🔴\s+Codeforces.*?<td align="center"><strong>)[^<]+' ,
128- 'LeetCode' : r'(🟢\s+LeetCode.*?<td align="center"><strong>)[^<]+' ,
129- 'Vjudge' : r'(🟣\s+Vjudge.*?<td align="center"><strong>)[^<]+' ,
130- 'AtCoder' : r'(🟠\s+AtCoder.*?<td align="center"><strong>)[^<]+' ,
131- 'CodeChef' : r'(🟤\s+CodeChef.*?<td align="center"><strong>)[^<]+' ,
132- 'CSES' : r'(⚪\s+CSES.*?<td align="center"><strong>)[^<]+' ,
133- 'Toph' : r'(🔵\s+Toph.*?<td align="center"><strong>)[^<]+' ,
134- 'LightOJ' : r'(🟡\s+LightOJ.*?<td align="center"><strong>)[^<]+' ,
135- 'SPOJ' : r'(🟩\s+SPOJ.*?<td align="center"><strong>)[^<]+' ,
136- 'HackerRank' : r'(💚\s+HackerRank.*?<td align="center"><strong>)[^<]+' ,
137- 'UVa' : r'(🔷\s+UVa.*?<td align="center"><strong>)[^<]+' ,
138- 'HackerEarth' : r'(🌐\s+HackerEarth.*?<td align="center"><strong>)[^<]+' ,
139- }
140-
141- if platform in platform_patterns :
142- pattern = platform_patterns [platform ]
121+ if platform in PLATFORM_PATTERNS :
122+ pattern = PLATFORM_PATTERNS [platform ]
143123 replacement = rf'\g<1>{ count } '
144124 readme_content = re .sub (pattern , replacement , readme_content , flags = re .DOTALL )
145125
0 commit comments