scripts.generate_sample_images   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 6

1 Function

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