示例#1
0
 def to_xml(self, bot, clientid):
     xml = "<%s"%self._name
     for attrib_name in self._attribs:
         attrib_value = self._attribs[attrib_name]
         escaped = TextUtils.html_escape(attrib_value)
         xml += ' %s="%s"' % (attrib_name, escaped)
     xml += ">"
     child_xml = self.children_to_xml(bot, clientid)
     xml += child_xml
     xml += "</%s>"%self._name
     return xml
示例#2
0
 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
0
 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
示例#4
0
 def resolve(self, client_context):
     if self._name is not None:
         xml = "<%s"%self._name
         for attrib_name in self._attribs:
             attrib_node = self._attribs[attrib_name]
             attrib_value = attrib_node.resolve(client_context)
             escaped = TextUtils.html_escape(attrib_value)
             escaped = escaped.replace(" ", "")
             xml += ' %s="%s"' % (attrib_name, escaped)
         xml += ">"
         child_xml = self.children_to_xml(client_context)
         xml += child_xml
         xml += "</%s>"%self._name
         return xml
     return ""
示例#5
0
 def resolve(self, bot, clientid):
     try:
         xml = "<%s" % self._name
         for attrib_name in self._attribs:
             attrib_value = self._attribs[attrib_name]
             escaped = TextUtils.html_escape(attrib_value)
             #TODO We could have nodes here, make sure they are resolved
             xml += ' %s="%s"' % (attrib_name, escaped)
         xml += ">"
         xml += self.resolve_children_to_string(bot, clientid)
         xml += "</%s>" % self._name
         return xml
     except Exception as excep:
         logging.exception(excep)
         return ""
示例#6
0
文件: word.py 项目: lilnana00/3ddd
 def to_xml(self, client_context):
     return TextUtils.html_escape(self.word)
示例#7
0
 def to_xml(self, bot, clientid):
     return TextUtils.html_escape(self.word)
示例#8
0
 def test_html_escape(self):
     self.assertEquals("", TextUtils.html_escape(""))
     self.assertEquals(" ", TextUtils.html_escape(" "))
     self.assertEquals("&lt;&gt;", TextUtils.html_escape("<>"))
     self.assertEquals("&lt;regex/&gt;", TextUtils.html_escape("<regex/>"))
示例#9
0
文件: word.py 项目: Freiza/program-y
 def to_xml(self, client_context):
     return TextUtils.html_escape(self.word)