29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
path = "/var/www/html/weval-technology-platform.html"
|
|
with open(path, "r", encoding="utf-8") as f:
|
|
c = f.read()
|
|
|
|
if "V131-WTP-ARENA" in c:
|
|
print("ALREADY")
|
|
exit(0)
|
|
|
|
# The actual line uses 2-space indent based on hexdump
|
|
marker = ' <a class="v80-quick" href="/blade-hub.html"><span class="v80-quick-icon"></span>Blade/GPU</a>'
|
|
if marker not in c:
|
|
# Try 4-space
|
|
marker = ' <a class="v80-quick" href="/blade-hub.html"><span class="v80-quick-icon"></span>Blade/GPU</a>'
|
|
if marker not in c:
|
|
# Try 6-space (as in earlier visible content)
|
|
marker = ' <a class="v80-quick" href="/blade-hub.html"><span class="v80-quick-icon"></span>Blade/GPU</a>'
|
|
if marker not in c:
|
|
print("no indent variant matches")
|
|
exit(1)
|
|
|
|
addition = marker + '\n' + marker.replace('/blade-hub.html"><span class="v80-quick-icon"></span>Blade/GPU', '/weval-arena.html" target="_blank"><span class="v80-quick-icon"></span>WEVAL Arena') + ' <!-- V131-WTP-ARENA -->'
|
|
|
|
c = c.replace(marker, addition, 1)
|
|
|
|
with open(path, "w", encoding="utf-8") as f:
|
|
f.write(c)
|
|
print(f"PATCHED size={len(c)}")
|