Skip to content

Commit

Permalink
Use html module in Python 3 and cgi module in Python 2
Browse files Browse the repository at this point in the history
`cgi.escape()` has been deprecated since Python 3.2 and
removed from Python 3.8.

Fixes: Cue#46
  • Loading branch information
frenzymadness committed Aug 30, 2019
1 parent d9c0d4e commit ee69d45
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/greplin/scales/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -105,7 +109,7 @@ def _htmlRenderDict(pathParts, statDict, output):

output.write('<div class="level">')
for key in keys:
keyStr = cgi.escape(_utf8str(key))
keyStr = html.escape(_utf8str(key))
value = statDict[key]
if hasattr(value, '__call__'):
value = value()
Expand All @@ -119,7 +123,7 @@ def _htmlRenderDict(pathParts, statDict, output):
_htmlRenderDict(valuePath, value, output)
else:
output.write('<div><span class="key">%s</span> <span class="%s">%s</span></div>' %
(keyStr, type(value).__name__, cgi.escape(_utf8str(value)).replace('\n', '<br/>')))
(keyStr, type(value).__name__, html.escape(_utf8str(value)).replace('\n', '<br/>')))

if links:
for link in links:
Expand Down

0 comments on commit ee69d45

Please sign in to comment.