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

ImageStore   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 91.67%

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 17
rs 10
ccs 11
cts 12
cp 0.9167
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 6 3
A exists() 0 4 1
A __init__() 0 3 1
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