Completed
Pull Request — master (#480)
by Jace
02:01
created

scripts.generate_sample_images   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 19
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 6

1 Function

Rating   Name   Duplication   Size   Complexity  
B generate_sample_images() 0 13 6
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