summaryrefslogtreecommitdiff
path: root/django_pyscss/scss.py
diff options
context:
space:
mode:
Diffstat (limited to 'django_pyscss/scss.py')
-rw-r--r--django_pyscss/scss.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/django_pyscss/scss.py b/django_pyscss/scss.py
index b4c5981..5aea4ac 100644
--- a/django_pyscss/scss.py
+++ b/django_pyscss/scss.py
@@ -2,6 +2,7 @@ from __future__ import absolute_import, unicode_literals
import os
from itertools import product
+import errno
from django.contrib.staticfiles.storage import staticfiles_storage
from django.conf import settings
@@ -24,6 +25,18 @@ config.ASSETS_ROOT = os.path.join(settings.STATIC_ROOT, 'scss', 'assets')
config.ASSETS_URL = staticfiles_storage.url('scss/assets/')
+def idempotent_makedirs(path, *args, **kwargs):
+ """
+ os.makedirs throws an error if the directory already existed. This function
+ does not. See https://github.com/fusionbox/django-pyscss/issues/23
+ """
+ try:
+ os.makedirs(path, *args, **kwargs)
+ except OSError as e:
+ if e.errno != errno.EEXIST:
+ raise
+
+
class DjangoScss(Scss):
"""
A subclass of the Scss compiler that uses the storages API for accessing
@@ -157,8 +170,7 @@ class DjangoScss(Scss):
Overwritten to call _find_source_file instead of
SourceFile.from_filename. Also added the relative_to option.
"""
- if not os.path.exists(config.ASSETS_ROOT):
- os.makedirs(config.ASSETS_ROOT)
+ idempotent_makedirs(config.ASSETS_ROOT)
if super_selector:
self.super_selector = super_selector + ' '
self.reset()