1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Ref #23919 -- Replaced some os.path usage with pathlib.Path.

This commit is contained in:
Tom
2017-07-21 21:33:26 +01:00
committed by Tim Graham
parent 5d923f2d8c
commit 11b8c30b9e
10 changed files with 54 additions and 57 deletions

View File

@@ -1,6 +1,6 @@
import inspect
import os
from importlib import import_module
from pathlib import Path
from django.apps import apps
from django.conf import settings
@@ -331,15 +331,15 @@ class TemplateDetailView(BaseAdminDocsView):
else:
# This doesn't account for template loaders (#24128).
for index, directory in enumerate(default_engine.dirs):
template_file = os.path.join(directory, template)
if os.path.exists(template_file):
with open(template_file) as f:
template_file = Path(directory) / template
if template_file.exists():
with template_file.open() as f:
template_contents = f.read()
else:
template_contents = ''
templates.append({
'file': template_file,
'exists': os.path.exists(template_file),
'exists': template_file.exists(),
'contents': template_contents,
'order': index,
})