scripts.generate_sample_images.run()   B
last analyzed

Complexity

Conditions 6

Size

Total Lines 13
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 11
nop 0
dl 0
loc 13
rs 8.6666
c 0
b 0
f 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