Refactor horizon TemplateLoader
Here we can use `with` statement to keep horizon code clean. Change-Id: I98ffc3fbcb6892a3739f2de1936c54e868f8908f
This commit is contained in:
parent
950bd9a4f3
commit
bebeaa6e11
@ -35,11 +35,8 @@ class TemplateLoader(BaseLoader):
|
||||
def load_template_source(self, template_name, template_dirs=None):
|
||||
for path in self.get_template_sources(template_name):
|
||||
try:
|
||||
file = open(path)
|
||||
try:
|
||||
with open(path) as file:
|
||||
return (file.read().decode(settings.FILE_CHARSET), path)
|
||||
finally:
|
||||
file.close()
|
||||
except IOError:
|
||||
pass
|
||||
raise TemplateDoesNotExist(template_name)
|
||||
|
Loading…
Reference in New Issue
Block a user