Пример #1
0
 def set_body(self, content, lang=None):
     if lang is None:
         lang = self.get_lang()
     self.del_body(lang)
     if lang == '*':
         for sublang, subcontent in content.items():
             self.set_body(subcontent, sublang)
     else:
         if isinstance(content, type(ET.Element('test'))):
             content = unicode(ET.tostring(content))
         else:
             content = unicode(content)
         header = '<body xmlns="%s"' % XHTML_NS
         if lang:
             header = '%s xml:lang="%s"' % (header, lang)
         content = '%s>%s</body>' % (header, content)
         xhtml = ET.fromstring(content)
         self.xml.append(xhtml)
Пример #2
0
 def set_body(self, content, lang=None):
     if lang is None:
         lang = self.get_lang()
     self.del_body(lang)
     if lang == '*':
         for sublang, subcontent in content.items():
             self.set_body(subcontent, sublang)
     else:
         if isinstance(content, type(ET.Element('test'))):
             content = unicode(ET.tostring(content))
         else:
             content = unicode(content)
         header = '<body xmlns="%s"' % XHTML_NS
         if lang:
             header = '%s xml:lang="%s"' % (header, lang)
         content = '%s>%s</body>' % (header, content)
         xhtml = ET.fromstring(content)
         self.xml.append(xhtml)
Пример #3
0
    def profile(data, query=False):
        try:
            data = unicode(data)
        except UnicodeError:
            raise StringPrepError

        data = map_input(data, mappings)
        data = normalize(data, nfkc)
        prohibit_output(data, prohibited)
        if bidi:
            check_bidi(data)
        if query and unassigned:
            check_unassigned(data, unassigned)
        return data