Passed
Pull Request — master (#451)
by Jace
01:11
created

scripts.generate_sample_images.create_image()   A

Complexity

Conditions 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nop 4
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
#!/usr/bin/env python
2
3
import log
4
import background
0 ignored issues
show
introduced by
Unable to import 'background'
Loading history...
5
6
from memegen.settings import ProductionConfig
7
from memegen.factory import create_app
8
from memegen.domain import Text
9
10
11
def main():
12
    log.info("Generating sample images...")
13
14
    app = create_app(ProductionConfig)
15
16
    with app.app_context():
17
18
        for template in app.template_service.all():
19
            for text in [Text("_"), template.sample_text]:
20
                for watermark in ["", "memegen.link"]:
21
                    create_image(app, template, text, watermark)
22
23
24
def create_image(app, template, text, watermark):
25
26
    @background.task
27
    def run():
28
        app.image_service.create(template, text, watermark=watermark)
29
30
    run()
31
32
33
if __name__ == '__main__':
34
    main()
35