From 9d1e390fd6d39bc72100f3bf21da2eb5ef55dfaf Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Fri, 27 Jan 2017 10:27:00 +0100 Subject: [PATCH] Properly close js and css files after opening --- holoviews/plotting/renderer.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/holoviews/plotting/renderer.py b/holoviews/plotting/renderer.py index 60cb646c64..479cf57a56 100644 --- a/holoviews/plotting/renderer.py +++ b/holoviews/plotting/renderer.py @@ -407,10 +407,15 @@ def html_assets(cls, core=True, extras=True, backends=None): # Join all the js widget code into one string path = os.path.dirname(os.path.abspath(__file__)) - widgetjs = '\n'.join(open(find_file(path, f), 'r').read() - for f in basejs + extensionjs - if f is not None ) - widgetcss = '\n'.join(open(find_file(path, f), 'r').read() + + def open_and_read(path, f): + with open(find_file(path, f), 'r') as f: + txt = f.read() + return txt + + widgetjs = '\n'.join(open_and_read(path, f) + for f in basejs + extensionjs if f is not None) + widgetcss = '\n'.join(open_and_read(path, f) for f in css if f is not None) dependencies = {}