本文整理汇总了Python中programy.utils.text.text.TextUtils.html_escape方法的典型用法代码示例。如果您正苦于以下问题:Python TextUtils.html_escape方法的具体用法?Python TextUtils.html_escape怎么用?Python TextUtils.html_escape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类programy.utils.text.text.TextUtils
的用法示例。
在下文中一共展示了TextUtils.html_escape方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resolve_to_string
# 需要导入模块: from programy.utils.text.text import TextUtils [as 别名]
# 或者: from programy.utils.text.text.TextUtils import html_escape [as 别名]
def resolve_to_string(self, client_context):
xml = "<%s" % self._name
for attrib_name in self._attribs:
if isinstance(self._attribs[attrib_name], str):
attrib_value = self._attribs[attrib_name]
else:
attrib_value = self._attribs[attrib_name].resolve(client_context)
escaped = TextUtils.html_escape(attrib_value)
escaped = escaped.replace(" ", "")
xml += ' %s="%s"' % (attrib_name, escaped)
xml += ">"
xml += self.resolve_children_to_string(client_context)
xml += "</%s>" % self._name
return xml
示例2: to_xml
# 需要导入模块: from programy.utils.text.text import TextUtils [as 别名]
# 或者: from programy.utils.text.text.TextUtils import html_escape [as 别名]
def to_xml(self, client_context):
xml = "<%s"%self._name
for attrib_name in self._attribs:
if isinstance(self._attribs[attrib_name], str):
attrib_value = self._attribs[attrib_name]
else:
attrib_value = self._attribs[attrib_name].resolve(client_context)
escaped = TextUtils.html_escape(attrib_value)
xml += ' %s="%s"' % (attrib_name, escaped)
xml += ">"
child_xml = self.children_to_xml(client_context)
xml += child_xml
xml += "</%s>"%self._name
return xml
示例3: test_html_escape
# 需要导入模块: from programy.utils.text.text import TextUtils [as 别名]
# 或者: from programy.utils.text.text.TextUtils import html_escape [as 别名]
def test_html_escape(self):
self.assertEquals("", TextUtils.html_escape(""))
self.assertEquals(" ", TextUtils.html_escape(" "))
self.assertEquals("<>", TextUtils.html_escape("<>"))
self.assertEquals("<regex/>", TextUtils.html_escape("<regex/>"))
示例4: to_xml
# 需要导入模块: from programy.utils.text.text import TextUtils [as 别名]
# 或者: from programy.utils.text.text.TextUtils import html_escape [as 别名]
def to_xml(self, client_context):
return TextUtils.html_escape(self.word)