MCPcopy Index your code
hub / github.com/python/cpython / _escape_cdata_c14n

Function _escape_cdata_c14n

Lib/xml/etree/ElementTree.py:2052–2068  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

2050
2051
2052def _escape_cdata_c14n(text):
2053 # escape character data
2054 try:
2055 # it's worth avoiding do-nothing calls for strings that are
2056 # shorter than 500 character, or so. assume that's, by far,
2057 # the most common case in most applications.
2058 if '&' in text:
2059 text = text.replace('&', '&')
2060 if '<' in text:
2061 text = text.replace('<', '&lt;')
2062 if '>' in text:
2063 text = text.replace('>', '&gt;')
2064 if '\r' in text:
2065 text = text.replace('\r', '&#xD;')
2066 return text
2067 except (TypeError, AttributeError):
2068 _raise_serialization_error(text)
2069
2070
2071def _escape_attrib_c14n(text):

Callers 4

_flushMethod · 0.85
_startMethod · 0.85
commentMethod · 0.85
piMethod · 0.85

Calls 2

replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…