grantforge-api / backend /add_keys.py
GrantForge Bot
Deploy to Hugging Face
afd56bc
import os
import glob
import re
directory = "/home/user/PROGRAMY/DOTACJE/backend/core/search/sources"
files = glob.glob(os.path.join(directory, "*_source.py"))
for file_path in files:
with open(file_path, "r", encoding="utf-8") as f:
content = f.read()
# We want to insert 'last_verified': '2026-05-23' and 'verified_by': 'manual'
# before the "source": line in the dictionaries.
# Pattern to find: "source": "something",
pattern = r'("source":\s*"[^"]+",)'
replacement = r'"last_verified": "2026-05-23",\n "verified_by": "manual",\n \1'
new_content = re.sub(pattern, replacement, content)
if new_content != content:
with open(file_path, "w", encoding="utf-8") as f:
f.write(new_content)
print(f"Zaktualizowano: {file_path}")