From 1c12d8cb770faf2f403a89b9abff93197e689657 Mon Sep 17 00:00:00 2001 From: Philip Garnero Date: Fri, 17 Jul 2015 18:05:27 +0200 Subject: [PATCH] show the search paths in case of an import error --- django_pyscss/extension/django.py | 16 +++++++++------- django_pyscss/utils.py | 5 +++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/django_pyscss/extension/django.py b/django_pyscss/extension/django.py index 8db6ae1..7212f44 100644 --- a/django_pyscss/extension/django.py +++ b/django_pyscss/extension/django.py @@ -8,7 +8,7 @@ from scss.extension.core import CoreExtension from scss.source import SourceFile -from ..utils import get_file_and_storage +from ..utils import get_file_and_storage, get_searched_paths class DjangoExtension(CoreExtension): @@ -29,19 +29,21 @@ def handle_import(self, name, compilation, rule): if original_path.is_absolute(): # Remove the beginning slash - search_path = original_path.relative_to('/').parent + origin = original_path.relative_to('/').parent elif rule.source_file.origin: - search_path = rule.source_file.origin + origin = rule.source_file.origin if original_path.parent: - search_path = os.path.normpath(str(search_path / original_path.parent)) + origin = os.path.normpath(str(origin / original_path.parent)) else: - search_path = original_path.parent + origin = original_path.parent for prefix, suffix in product(('_', ''), search_exts): filename = PurePath(prefix + basename + suffix) - full_filename, storage = get_file_and_storage(str(search_path / filename)) + full_filename, storage = get_file_and_storage(str(origin / filename)) if full_filename: with storage.open(full_filename) as f: - return SourceFile.from_file(f, origin=search_path, relpath=filename) + return SourceFile.from_file(f, origin=origin, relpath=filename) + + compilation.compiler.search_path = get_searched_paths(basename) diff --git a/django_pyscss/utils.py b/django_pyscss/utils.py index e4222c0..fd16922 100644 --- a/django_pyscss/utils.py +++ b/django_pyscss/utils.py @@ -46,3 +46,8 @@ def get_file_and_storage(filename): if storage is None: name, storage = get_file_from_storage(filename) return name, storage + + +def get_searched_paths(filename): + finders.find(filename) + return finders.searched_locations