Completed
Pull Request — master (#391)
by Jace
08:05
created

ImageStore.exists()   A

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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