MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / str

Method str

suds/sax/element.py:743–770  ·  view source on GitHub ↗

Get a string representation of this XML fragment. @param indent: The indent to be used in formatting the output. @type indent: int @return: A I{pretty} string. @rtype: basestring

(self, indent=0)

Source from the content-addressed store, hash-verified

741 self.nsprefixes[ns[0]] = ns[1]
742
743 def str(self, indent=0):
744 """
745 Get a string representation of this XML fragment.
746 @param indent: The indent to be used in formatting the output.
747 @type indent: int
748 @return: A I{pretty} string.
749 @rtype: basestring
750 """
751 tab = '%*s' % (indent * 3, '')
752 result = []
753 result.append('%s<%s' % (tab, self.qname()))
754 result.append(self.nsdeclarations())
755 for a in [unicode(a) for a in self.attributes]:
756 result.append(' %s' % a)
757 if self.isempty():
758 result.append('/>')
759 return ''.join(result)
760 result.append('>')
761 if self.hasText():
762 result.append(self.text.escape())
763 for c in self.children:
764 result.append('\n')
765 result.append(c.str(indent+1))
766 if len(self.children):
767 result.append('\n%s' % tab)
768 result.append('</%s>' % self.qname())
769 result = ''.join(result)
770 return result
771
772 def plain(self):
773 """

Callers 2

__str__Method · 0.95
__unicode__Method · 0.95

Calls 6

qnameMethod · 0.95
nsdeclarationsMethod · 0.95
isemptyMethod · 0.95
hasTextMethod · 0.95
appendMethod · 0.45
escapeMethod · 0.45

Tested by

no test coverage detected