Skip to content

Commit ee79823

Browse files
committed
show the search paths in case of an import error
1 parent a48118f commit ee79823

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
@@ -6,7 +6,7 @@
66
from scss.extension.core import CoreExtension
77
from scss.source import SourceFile
88

9-
from ..utils import get_file_and_storage
9+
from ..utils import get_file_and_storage, get_searched_paths
1010

1111

1212
class DjangoExtension(CoreExtension):
@@ -26,21 +26,23 @@ def handle_import(self, name, compilation, rule):
2626

2727
if original_path.is_absolute():
2828
# Remove the beginning slash
29-
search_path = original_path.relative_to('/').parent
29+
origin = original_path.relative_to('/').parent
3030
elif rule.source_file.origin:
31-
search_path = rule.source_file.origin
31+
origin = rule.source_file.origin
3232
if original_path.parent:
33-
search_path = search_path / original_path.parent
33+
origin = origin / original_path.parent
3434
else:
35-
search_path = original_path.parent
35+
origin = original_path.parent
3636

3737
basename = original_path.stem
3838

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

42-
full_filename, storage = get_file_and_storage(str(search_path / filename))
42+
full_filename, storage = get_file_and_storage(str(origin / filename))
4343

4444
if full_filename:
4545
with storage.open(full_filename) as f:
46-
return SourceFile.from_file(f, origin=search_path, relpath=filename)
46+
return SourceFile.from_file(f, origin=origin, relpath=filename)
47+
48+
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)