| Total Complexity | 6 |
| Total Lines | 26 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | """Prerender common images used in the application.""" |
||
| 2 | |||
| 3 | |||
| 4 | from memegen.settings import ProductionConfig |
||
| 5 | from memegen.factory import create_app |
||
| 6 | from memegen.domain import Text |
||
| 7 | |||
| 8 | |||
| 9 | def run(): |
||
| 10 | app = create_app(ProductionConfig) |
||
| 11 | with app.app_context(): |
||
| 12 | |||
| 13 | options = [] |
||
| 14 | for template in app.template_service.all(): |
||
| 15 | for text in [Text("_"), template.sample_text]: |
||
| 16 | for watermark in ["", "memegen.link"]: |
||
| 17 | options.append((template, text, watermark)) |
||
| 18 | |||
| 19 | print(f"Generating {len(options)} sample images...") |
||
| 20 | for template, text, watermark in options: |
||
| 21 | app.image_service.create(template, text, watermark=watermark) |
||
| 22 | |||
| 23 | |||
| 24 | if __name__ == '__main__': |
||
| 25 | run() |
||
| 26 |