diff --git a/src/greplin/scales/formats.py b/src/greplin/scales/formats.py index c4ef979..b6a96d4 100644 --- a/src/greplin/scales/formats.py +++ b/src/greplin/scales/formats.py @@ -16,7 +16,11 @@ from greplin import scales -import cgi +try: + import html +except ImportError: + # Python 2.7 has no html module + import cgi as html import six import json import operator @@ -105,7 +109,7 @@ def _htmlRenderDict(pathParts, statDict, output): output.write('
') for key in keys: - keyStr = cgi.escape(_utf8str(key)) + keyStr = html.escape(_utf8str(key)) value = statDict[key] if hasattr(value, '__call__'): value = value() @@ -119,7 +123,7 @@ def _htmlRenderDict(pathParts, statDict, output): _htmlRenderDict(valuePath, value, output) else: output.write('
%s %s
' % - (keyStr, type(value).__name__, cgi.escape(_utf8str(value)).replace('\n', '
'))) + (keyStr, type(value).__name__, html.escape(_utf8str(value)).replace('\n', '
'))) if links: for link in links: