fix_templates.py 636 B

123456789101112131415161718
  1. import json
  2. with open('d:/00_26code/x11_template_vue/backend/data/templates.json', 'r', encoding='utf-8') as f:
  3. data = json.load(f)
  4. count = 0
  5. for item in data:
  6. if 'template_body' in item:
  7. body = item['template_body']
  8. if ']| first}}' in body:
  9. item['template_body'] = body.replace(']| first}}', ']| random}}')
  10. count += 1
  11. print(f"Modified: {item.get('id', 'unknown')}")
  12. with open('d:/00_26code/x11_template_vue/backend/data/templates.json', 'w', encoding='utf-8') as f:
  13. json.dump(data, f, ensure_ascii=False, indent=2)
  14. print(f'Total modified: {count}')