MCPcopy Index your code
hub / github.com/csev/py4e / renderContents

Method renderContents

old/old-code/BeautifulSoup.py:796–815  ·  view source on GitHub ↗

Renders the contents of this tag as a string in the given encoding. If encoding is None, returns a Unicode string..

(self, encoding=DEFAULT_OUTPUT_ENCODING,
                       prettyPrint=False, indentLevel=0)

Source from the content-addressed store, hash-verified

794 return self.__str__(encoding, True)
795
796 def renderContents(self, encoding=DEFAULT_OUTPUT_ENCODING,
797 prettyPrint=False, indentLevel=0):
798 """Renders the contents of this tag as a string in the given
799 encoding. If encoding is None, returns a Unicode string.."""
800 s=[]
801 for c in self:
802 text = None
803 if isinstance(c, NavigableString):
804 text = c.__str__(encoding)
805 elif isinstance(c, Tag):
806 s.append(c.__str__(encoding, prettyPrint, indentLevel))
807 if text and prettyPrint:
808 text = text.strip()
809 if text:
810 if prettyPrint:
811 s.append(" " * (indentLevel-1))
812 s.append(text)
813 if prettyPrint:
814 s.append("\n")
815 return ''.join(s)
816
817 #Soup methods
818

Callers 1

__str__Method · 0.95

Calls 2

__str__Method · 0.45
appendMethod · 0.45

Tested by

no test coverage detected