Total Complexity | 5 |
Total Lines | 21 |
Duplicated Lines | 0 % |
Coverage | 92.31% |
Changes | 0 |
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 |