Skip to content

Commit 6809449

Browse files
committed
Minor style update
1 parent 63bf99c commit 6809449

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

lib/core/convert.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@ def utf8decode(value):
136136
return value.decode("utf-8")
137137

138138
def htmlescape(value):
139-
_ = (('&', '&amp;'), ('<', '&lt;'), ('>', '&gt;'), ('"', '&quot;'), ("'", '&#39;'), (' ', '&nbsp;'))
140-
return reduce(lambda x, y: x.replace(y[0], y[1]), _, value)
139+
codes = (('&', '&amp;'), ('<', '&lt;'), ('>', '&gt;'), ('"', '&quot;'), ("'", '&#39;'), (' ', '&nbsp;'))
140+
return reduce(lambda x, y: x.replace(y[0], y[1]), codes, value)
141141

142142
def htmlunescape(value):
143143
retVal = value
144144
if value and isinstance(value, basestring):
145-
_ = (('&amp;', '&'), ('&lt;', '<'), ('&gt;', '>'), ('&quot;', '"'), ('&nbsp;', ' '))
146-
retVal = reduce(lambda x, y: x.replace(y[0], y[1]), _, retVal)
147-
retVal = re.sub('&#(\d+);', lambda x: unichr(int(x.group(1))), retVal)
145+
codes = (('&lt;', '<'), ('&gt;', '>'), ('&quot;', '"'), ('&nbsp;', ' '), ('&amp;', '&'))
146+
retVal = reduce(lambda x, y: x.replace(y[0], y[1]), codes, retVal)
147+
retVal = re.sub('&#(\d+);', lambda x: getUnicode(chr(x.group(1))), retVal)
148148
return retVal

0 commit comments

Comments
 (0)