Initial Commit
[Projects.git] / pkgbuilds / pytivo / pkg / usr / share / pyTivo / Cheetah / Utils / htmlEncode.py
blobf76c77e4e622f5d3124804f7c553ab79daed5f41
1 """This is a copy of the htmlEncode function in Webware.
4 @@TR: It implemented more efficiently.
6 """
7 htmlCodes = [
8 ['&', '&'],
9 ['<', '&lt;'],
10 ['>', '&gt;'],
11 ['"', '&quot;'],
13 htmlCodesReversed = htmlCodes[:]
14 htmlCodesReversed.reverse()
16 def htmlEncode(s, codes=htmlCodes):
17 """ Returns the HTML encoded version of the given string. This is useful to
18 display a plain ASCII text string on a web page."""
19 for code in codes:
20 s = s.replace(code[0], code[1])
21 return s