From de17dd27c956e4499ba90c46ff8ec1879621ae61 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Tue, 2 Jul 2019 09:10:08 -0400 Subject: [PATCH] use context managers to open files where possible --- src/calibre/ebooks/oeb/stylizer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/ebooks/oeb/stylizer.py b/src/calibre/ebooks/oeb/stylizer.py index bc32034c65..d834e26ad3 100644 --- a/src/calibre/ebooks/oeb/stylizer.py +++ b/src/calibre/ebooks/oeb/stylizer.py @@ -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