Completed
Push — master ( 079863...3f9dd1 )
by Jace
03:11
created

ImageStore   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%
Metric Value
dl 0
loc 24
ccs 17
cts 17
cp 1
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __init__() 0 2 1
A latest() 0 3 1
A exists() 0 4 1
A create() 0 8 2
1 1
import os
2
3
4 1
class ImageStore:
5
6 1
    LATEST = "latest.jpg"
7
8 1
    def __init__(self, root):
9 1
        self.root = root
10
11 1
    @property
12
    def latest(self):
13 1
        return os.path.join(self.root, self.LATEST)
14
15 1
    def exists(self, image):
16 1
        image.root = self.root
17
        # TODO: add a way to determine if the styled image was already generated
18 1
        return os.path.isfile(image.path) and not image.style
19
20 1
    def create(self, image):
21 1
        image.root = self.root
22 1
        image.generate()
23 1
        try:
24 1
            os.remove(self.latest)
25 1
        except IOError:
26 1
            pass
27
        os.symlink(image.path, self.latest)
28