memegen.stores.image   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A ImageStore.__init__() 0 3 1
A ImageStore.create() 0 6 3
A ImageStore.exists() 0 4 1
1
import os
2
3
4
class ImageStore:
5
6
    def __init__(self, root, config):
7
        self.root = root
8
        self.regenerate_images = config.get('REGENERATE_IMAGES', False)
9
10
    def exists(self, image):
11
        image.root = self.root
12
        # TODO: add a way to determine if the styled image was already generated
13
        return os.path.isfile(image.path) and not image.style
14
15
    def create(self, image):
16
        if self.exists(image) and not self.regenerate_images:
17
            return
18
19
        image.root = self.root
20
        image.save()
21