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

Function unescape

Lib/xml/sax/saxutils.py:34–46  ·  view source on GitHub ↗

Unescape &, <, and > in a string of data. You can unescape other strings of data by passing a dictionary as the optional entities parameter. The keys and values must all be strings; each key will be replaced with its corresponding value.

(data, entities={})

Source from the content-addressed store, hash-verified

32 return data
33
34def unescape(data, entities={}):
35 """Unescape &, <, and > in a string of data.
36
37 You can unescape other strings of data by passing a dictionary as
38 the optional entities parameter. The keys and values must all be
39 strings; each key will be replaced with its corresponding value.
40 """
41 data = data.replace("&lt;", "<")
42 data = data.replace("&gt;", ">")
43 if entities:
44 data = __dict_replace(data, entities)
45 # must do ampersand last
46 return data.replace("&amp;", "&")
47
48def quoteattr(data, entities={}):
49 """Escape and quote an attribute value.

Callers 4

test_unescape_basicMethod · 0.90
test_unescape_allMethod · 0.90
test_unescape_extraMethod · 0.90

Calls 2

__dict_replaceFunction · 0.85
replaceMethod · 0.45

Tested by 4

test_unescape_basicMethod · 0.72
test_unescape_allMethod · 0.72
test_unescape_extraMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…