grantforge-api / backend /extract_fallbacks.py
GrantForge Bot
Deploy to Hugging Face
afd56bc
import sys
import os
import json
from datetime import datetime, timezone
# Add backend to path so imports work
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
results = {}
for filename in os.listdir('core/search/sources'):
if filename.endswith('_source.py') and filename != 'base_source.py':
module_name = f'core.search.sources.{filename[:-3]}'
try:
import importlib
mod = importlib.import_module(module_name)
for attr_name in dir(mod):
attr = getattr(mod, attr_name)
if isinstance(attr, type) and hasattr(attr, '_get_verified_fallback'):
inst = attr()
# Patch logging inside __init__ if needed or just call fallback directly
try:
fallback = attr._get_verified_fallback(inst)
except TypeError:
fallback = attr()._get_verified_fallback()
results[filename] = fallback
except Exception as e:
results[filename] = f'Error: {e}'
print(json.dumps(results, default=str))