예제 #1
0
 def _open_tag(self, tag_name, attributes=None):
     if attributes is None:
         attributes = []
     attrs = collect_attributes(tag_name, attributes, self._indent,
                                self._indent_char,
                                len(tag_name) + 2)
     self.write_line('<%s%s>' % (tag_name, attrs))
예제 #2
0
 def _open_tag(self, tag_name, attributes=None):
     if attributes is None:
         attributes = []
     attrs = collect_attributes(
         tag_name, attributes, self._indent,
         self._indent_char,
         len(tag_name) + 2)
     self.write_line(u'<%s%s>' % (tag_name, attrs))
예제 #3
0
 def write_tag(self, tag_name, attributes, data=None):
     if attributes is None:
         attributes = []
     prefix = u'<%s' % (tag_name, )
     if data is not None:
         if isinstance(data, str):
             data = data.decode('UTF-8')
         suffix = u'>%s</%s>' % (escape(data), tag_name)
     else:
         suffix = u'/>'
     attrs = collect_attributes(tag_name, attributes, self._indent,
                                self._indent_char,
                                len(prefix) + len(suffix))
     self.write_line(prefix + attrs + suffix)
예제 #4
0
 def write_tag(self, tag_name, attributes, data=None):
     if attributes is None:
         attributes = []
     prefix = u'<%s' % (tag_name, )
     if data is not None:
         if isinstance(data, str):
             data = data.decode('UTF-8')
         suffix = u'>%s</%s>' % (escape(data), tag_name)
     else:
         suffix = u'/>'
     attrs = collect_attributes(
         tag_name, attributes,
         self._indent,
         self._indent_char,
         len(prefix) + len(suffix))
     self.write_line(prefix + attrs + suffix)
예제 #5
0
def build_xml_tag(tag_name, attributes=None, data=None, self_indent=0,
                  self_indent_char=' '):
    if attributes is None:
        attributes = []
    prefix = '<%s' % (tag_name, )
    if data is not None:
        if isinstance(data, bytes):
            data = data.decode('UTF-8')
        suffix = '>%s</%s>' % (escape(data), tag_name)
    else:
        suffix = '/>'
    attrs = collect_attributes(
        tag_name, attributes,
        self_indent,
        self_indent_char,
        len(prefix) + len(suffix))
    return prefix + attrs + suffix
def build_xml_tag(tag_name, attributes=None, data=None, self_indent=0,
                  self_indent_char=' '):
    if attributes is None:
        attributes = []
    prefix = u'<%s' % (tag_name, )
    if data is not None:
        if isinstance(data, str):
            data = data.decode('UTF-8')
        suffix = u'>%s</%s>' % (escape(data), tag_name)
    else:
        suffix = u'/>'
    attrs = collect_attributes(
        tag_name, attributes,
        self_indent,
        self_indent_char,
        len(prefix) + len(suffix))
    return prefix + attrs + suffix