Files
deb-python-django-pyscss/django_pyscss/utils.py
Radomir Dopieralski 9fc62d06df [1.0.x] Fix #14, respect storage.prefix when looking for files
The function ``find_all_files`` ignored ``storage.prefix`` when looking
for files, which made it fail when a prefix was used in
``STATICFILES_DIRS``.

(cherry picked from commit 187a7a72bf)
2014-09-15 12:13:24 +02:00

19 lines
609 B
Python

import fnmatch
import os
from django.contrib.staticfiles import finders
def find_all_files(glob):
"""
Finds all files in the django finders for a given glob,
returns the file path, if available, and the django storage object.
storage objects must implement the File storage API:
https://docs.djangoproject.com/en/dev/ref/files/storage/
"""
for finder in finders.get_finders():
for path, storage in finder.list([]):
if fnmatch.fnmatchcase(os.path.join(storage.prefix or '', path),
glob):
yield path, storage