memegen.stores.image   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 92.31%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 21
rs 10
c 0
b 0
f 0
ccs 12
cts 13
cp 0.9231
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 1
import os
2 1
3
4 1
class ImageStore:
5
6
    def __init__(self, root, config):
7 1
        self.root = root
8
        self.regenerate_images = config.get('REGENERATE_IMAGES', False)
9 1
10 1
    def exists(self, image):
11 1
        image.root = self.root
12
        # TODO: add a way to determine if the styled image was already generated
13 1
        return os.path.isfile(image.path) and not image.style
14 1
15
    def create(self, image):
16 1
        if self.exists(image) and not self.regenerate_images:
17
            return
18 1
19 1
        image.root = self.root
20
        image.save()
21