Optimized django.template.autoreload.get_template_directories() a bit.
This commit is contained in:
parent
72b23c04d8
commit
cc752c1c3a
|
@ -13,18 +13,19 @@ def get_template_directories():
|
||||||
# Iterate through each template backend and find
|
# Iterate through each template backend and find
|
||||||
# any template_loader that has a 'get_dirs' method.
|
# any template_loader that has a 'get_dirs' method.
|
||||||
# Collect the directories, filtering out Django templates.
|
# Collect the directories, filtering out Django templates.
|
||||||
|
cwd = Path.cwd()
|
||||||
items = set()
|
items = set()
|
||||||
for backend in engines.all():
|
for backend in engines.all():
|
||||||
if not isinstance(backend, DjangoTemplates):
|
if not isinstance(backend, DjangoTemplates):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
items.update(Path.cwd() / to_path(dir) for dir in backend.engine.dirs)
|
items.update(cwd / to_path(dir) for dir in backend.engine.dirs)
|
||||||
|
|
||||||
for loader in backend.engine.template_loaders:
|
for loader in backend.engine.template_loaders:
|
||||||
if not hasattr(loader, 'get_dirs'):
|
if not hasattr(loader, 'get_dirs'):
|
||||||
continue
|
continue
|
||||||
items.update(
|
items.update(
|
||||||
Path.cwd() / to_path(directory)
|
cwd / to_path(directory)
|
||||||
for directory in loader.get_dirs()
|
for directory in loader.get_dirs()
|
||||||
if not is_django_path(directory)
|
if not is_django_path(directory)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue