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={})
| 32 | return data |
| 33 | |
| 34 | def 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("<", "<") |
| 42 | data = data.replace(">", ">") |
| 43 | if entities: |
| 44 | data = __dict_replace(data, entities) |
| 45 | # must do ampersand last |
| 46 | return data.replace("&", "&") |
| 47 | |
| 48 | def quoteattr(data, entities={}): |
| 49 | """Escape and quote an attribute value. |
searching dependent graphs…