Skip to content

Commit 1c12d8c

Browse files
committed
show the search paths in case of an import error
1 parent 57d006b commit 1c12d8c

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

django_pyscss/extension/django.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from scss.extension.core import CoreExtension
99
from scss.source import SourceFile
1010

11-
from ..utils import get_file_and_storage
11+
from ..utils import get_file_and_storage, get_searched_paths
1212

1313

1414
class DjangoExtension(CoreExtension):
@@ -29,19 +29,21 @@ def handle_import(self, name, compilation, rule):
2929

3030
if original_path.is_absolute():
3131
# Remove the beginning slash
32-
search_path = original_path.relative_to('/').parent
32+
origin = original_path.relative_to('/').parent
3333
elif rule.source_file.origin:
34-
search_path = rule.source_file.origin
34+
origin = rule.source_file.origin
3535
if original_path.parent:
36-
search_path = os.path.normpath(str(search_path / original_path.parent))
36+
origin = os.path.normpath(str(origin / original_path.parent))
3737
else:
38-
search_path = original_path.parent
38+
origin = original_path.parent
3939

4040
for prefix, suffix in product(('_', ''), search_exts):
4141
filename = PurePath(prefix + basename + suffix)
4242

43-
full_filename, storage = get_file_and_storage(str(search_path / filename))
43+
full_filename, storage = get_file_and_storage(str(origin / filename))
4444

4545
if full_filename:
4646
with storage.open(full_filename) as f:
47-
return SourceFile.from_file(f, origin=search_path, relpath=filename)
47+
return SourceFile.from_file(f, origin=origin, relpath=filename)
48+
49+
compilation.compiler.search_path = get_searched_paths(basename)

django_pyscss/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,8 @@ def get_file_and_storage(filename):
4646
if storage is None:
4747
name, storage = get_file_from_storage(filename)
4848
return name, storage
49+
50+
51+
def get_searched_paths(filename):
52+
finders.find(filename)
53+
return finders.searched_locations

0 commit comments

Comments
 (0)