from pathlib import Path
p=Path('/opt/struktur/social-media-radar/sma_core/production.py'); s=p.read_text()
old=''' if source["mas_relevant"] != 1 or source["content_blocked"] != 0:
raise ProductionError("mas_content_gate_blocked", "source signal is not content-eligible", retryable=False)
'''
new=''' source_keys = set(source.keys())
if {"mas_relevant", "content_blocked"}.issubset(source_keys):
if source["mas_relevant"] != 1 or source["content_blocked"] != 0:
raise ProductionError("mas_content_gate_blocked", "source signal is not content-eligible", retryable=False)
elif self.database_path.resolve() == Path("/var/lib/sma-data/signals.db").resolve():
raise ProductionError("mas_content_gate_missing", "MAS source schema has no content gate", retryable=False)
'''
assert old in s
p.write_text(s.replace(old,new))