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