X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/10138c15c015c3c0c3546e5083642cf2145dfe82..92d72b35447cf7210728725b217812492b3855e0:/tools/crunchstat-summary/crunchstat_summary/webchart.py diff --git a/tools/crunchstat-summary/crunchstat_summary/webchart.py b/tools/crunchstat-summary/crunchstat_summary/webchart.py index 790b08da87..cf0c1e67aa 100644 --- a/tools/crunchstat-summary/crunchstat_summary/webchart.py +++ b/tools/crunchstat-summary/crunchstat_summary/webchart.py @@ -2,7 +2,11 @@ # # SPDX-License-Identifier: AGPL-3.0 -import cgi +try: + from html import escape +except ImportError: + from cgi import escape + import json import pkg_resources @@ -10,7 +14,7 @@ import pkg_resources class WebChart(object): """Base class for a web chart. - Subclasses must assign JSLIB and JSASSET, and override the + Subclasses must assign JSLIB and JSASSETS, and override the chartdata() method. """ JSLIB = None @@ -27,13 +31,13 @@ class WebChart(object): {} - '''.format(cgi.escape(self.label), + '''.format(escape(self.label), self.JSLIB, self.js(), self.headHTML()) def js(self): return 'var chartdata = {};\n{}'.format( json.dumps(self.sections()), - pkg_resources.resource_string('crunchstat_summary', self.JSASSET)) + '\n'.join([pkg_resources.resource_string('crunchstat_summary', jsa).decode('utf-8') for jsa in self.JSASSETS])) def sections(self): return [