use context managers to open files where possible

This commit is contained in:
Eli Schwartz 2019-07-02 09:10:08 -04:00
parent 31bd771cf9
commit de17dd27c9
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6

View File

@ -32,7 +32,8 @@ _html_css_stylesheet = None
def html_css_stylesheet():
global _html_css_stylesheet
if _html_css_stylesheet is None:
html_css = open(P('templates/html.css'), 'rb').read()
with open(P('templates/html.css'), 'rb') as f:
html_css = f.read()
_html_css_stylesheet = parseString(html_css, validate=False)
return _html_css_stylesheet