forked from ppy/osu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinal_fix.py
More file actions
31 lines (28 loc) · 1.13 KB
/
Copy pathfinal_fix.py
File metadata and controls
31 lines (28 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
import re
def patch_file(path, old, new):
if not os.path.exists(path):
return
with open(path, 'r') as f:
content = f.read()
if old in content:
with open(path, 'w') as f:
f.write(content.replace(old, new))
else:
# Try regex if literal fails
new_content = re.sub(re.escape(old).replace(r'\ ', r'\s+'), new, content, flags=re.MULTILINE | re.DOTALL)
if new_content != content:
with open(path, 'w') as f:
f.write(new_content)
else:
print(f"Warning: '{old}' not found in {path}")
# 1. Fix GameplayWarmupScreen IDE0074 (compound assignment)
gw_path = 'osu.Game/Screens/OnlinePlay/Matchmaking/RankedPlay/GameplayWarmupScreen.cs'
old_gw = """ if (card == null)
{
// Played card was not on the screen.
card = new RankedPlayCard(matchInfo.LastPlayedCard)"""
new_gw = """ card ??= new RankedPlayCard(matchInfo.LastPlayedCard)
{
// Played card was not on the screen."""
# Wait, the braces are different. Let's look at the original code.