jules / patch_dedupe.py
GraziePrego's picture
Upload folder using huggingface_hub
34450be verified
with open("server.js", "r") as f:
content = f.read()
# Since I ran the patch twice (once successfully with the first script despite the warning, and once with the second), it might be duplicated.
# Let's remove the block if it exists multiple times.
import re
# Find how many times it exists
pattern = r"// Utility to extract variables from template content.*?// POST /api/sessions/from-template.*?\n\}\);"
matches = re.findall(pattern, content, flags=re.DOTALL)
if len(matches) > 1:
print(f"Found {len(matches)} duplications. Removing all but the first.")
content = content.replace(matches[0], "")
with open("server.js", "w") as f:
f.write(content)