Explorer
/proc/21/root/tmp/patch_template_aa014.py
← Zurück ↓ Download
from pathlib import Path
p=Path('/opt/struktur/social-media-agent/templates/publication_packages.html')
s=p.read_text()
old='''      <div class="media-status {% if p.image_status == 'present' %}present{% elif p.image_status == 'error' %}error{% else %}idea{% endif %}">{% if p.image_status == 'present' %}Bild vorhanden{% elif p.image_status == 'error' %}Bildfehler{% elif p.image_prompt %}Bildidee vorhanden{% else %}Kein Bild{% endif %}</div>
      {% if p.media_source_type %}<div class="pp-meta">Bildquelle: {{ p.media_source_type }}{% if p.media_source_ref %} · {{ p.media_source_ref }}{% endif %}</div>{% endif %}'''
new='''      <div class="media-status {% if p.image_status == 'present' %}present{% elif p.image_status == 'error' %}error{% else %}idea{% endif %}">{% if p.image_status == 'present' %}Bild vorhanden{% elif p.image_status == 'error' %}Bildfehler{% elif p.image_prompt %}Bildidee vorhanden{% else %}Kein Bild{% endif %}</div>
      <div class="pp-meta">Manuelle KI-Bilderzeugung: Codex built-in image_gen · kein OpenAI-API-Key</div>
      {% if p.media_source_type %}<div class="pp-meta">Bildquelle: {{ p.media_source_type }}{% if p.media_source_ref %} · {{ p.media_source_ref }}{% endif %}</div>{% endif %}'''
assert s.count(old)==1
s=s.replace(old,new)
old2='''      {% if p.image_error %}<div class="pp-warning">{{ p.image_error }}</div>{% endif %}'''
new2='''      {% if p.image_error %}<div class="pp-warning">{% if 'OpenAI API Credential erforderlich' in p.image_error %}Historischer Direct-API-Versuch fehlgeschlagen; der aktuelle manuelle Bildpfad verwendet Codex built-in image_gen.{% else %}{{ p.image_error }}{% endif %}</div>{% endif %}'''
assert s.count(old2)==1
s=s.replace(old2,new2)
p.write_text(s)
print('patched template')