root/galaxy-central/eggs/Cheetah-2.2.2-py2.6-macosx-10.6-universal-ucs2.egg/Cheetah/Utils/htmlEncode.py @ 3

リビジョン 3, 508 bytes (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1"""This is a copy of the htmlEncode function in Webware.
2
3
4@@TR: It implemented more efficiently.
5
6"""
7htmlCodes = [
8    ['&', '&'],
9    ['<', '&lt;'],
10    ['>', '&gt;'],
11    ['"', '&quot;'],
12]
13htmlCodesReversed = htmlCodes[:]
14htmlCodesReversed.reverse()
15
16def 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
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。