| Total Complexity | 5 |
| Total Lines | 17 |
| Duplicated Lines | 0 % |
| Coverage | 91.67% |
| Changes | 0 | ||
| 1 | 1 | import os |
|
| 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 |