memegen.stores.image.ImageStore.exists()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
crap 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