Completed
Pull Request — master (#132)
by Jace
01:42
created

ImageStore.exists()   A

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1
Metric Value
cc 1
dl 0
loc 4
rs 10
ccs 3
cts 3
cp 1
crap 1
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