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

scripts.generate_sample_images   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 6

2 Functions

Rating   Name   Duplication   Size   Complexity  
A create_image() 0 7 1
A main() 0 11 5
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