Files
deb-python-django-pyscss/django_pyscss/utils.py
2014-02-01 21:43:42 -07:00

22 lines
613 B
Python

import fnmatch
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(path, glob):
yield path, storage
def find_one_file(path):
for file in find_all_files(path):
return file