File: writer.py

package info (click to toggle)
bzr-xmloutput 0.8.8+bzr162-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 420 kB
  • sloc: python: 4,372; makefile: 7; sh: 2
file content (16 lines) | stat: -rw-r--r-- 464 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
"""Tools for writing xml

Suggestion for this module: create a simple xml writer here and expurgate all
other modules of angle brackets entirely.
"""

def _escape_cdata(text):
    """Escape special characters in cdata.

    :note: This does not care about the input encoding, and supports
        both unicode and byte strings.
    """
    text = text.replace("&", "&")
    text = text.replace("<", "&lt;")
    text = text.replace(">", "&gt;")
    return text