()
| 8 | |
| 9 | |
| 10 | def get_template_directories(): |
| 11 | # Iterate through each template backend and find |
| 12 | # any template_loader that has a 'get_dirs' method. |
| 13 | # Collect the directories, filtering out Django templates. |
| 14 | cwd = Path.cwd() |
| 15 | items = set() |
| 16 | for backend in engines.all(): |
| 17 | if not isinstance(backend, DjangoTemplates): |
| 18 | continue |
| 19 | |
| 20 | items.update(cwd / to_path(dir) for dir in backend.engine.dirs if dir) |
| 21 | |
| 22 | for loader in backend.engine.template_loaders: |
| 23 | if not hasattr(loader, "get_dirs"): |
| 24 | continue |
| 25 | items.update( |
| 26 | cwd / to_path(directory) |
| 27 | for directory in loader.get_dirs() |
| 28 | if directory and not is_django_path(directory) |
| 29 | ) |
| 30 | return items |
| 31 | |
| 32 | |
| 33 | def reset_loaders(): |
no test coverage detected