~ubuntu-branches/debian/stretch/bzr-xmloutput/stretch

« back to all changes in this revision

Viewing changes to writer.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij, Jelmer Vernooij, Max Bowsher
  • Date: 2011-03-07 05:29:49 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20110307052949-qj68inm3y8e3eit0
Tags: 0.8.7-1
[ Jelmer Vernooij ]
* New upstream snapshot.

[ Max Bowsher ]
* Run tests in a UTF-8 locale, because they do not properly support the C
  locale.

[ Jelmer Vernooij ]
* Switch to dh_python2. Closes: #616769
* Switch to debhelper 7, drop cdbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
other modules of angle brackets entirely.
5
5
"""
6
6
 
7
 
import bzrlib.xml_serializer
 
7
def _escape_cdata(text):
 
8
    """Escape special characters in cdata.
8
9
 
9
 
# Use xml_serializer to avoid duplicating the elementtree location logic
10
 
_escape_cdata = bzrlib.xml_serializer.elementtree.ElementTree._escape_cdata
 
10
    :note: This does not care about the input encoding, and supports
 
11
        both unicode and byte strings.
 
12
    """
 
13
    text = text.replace("&", "&")
 
14
    text = text.replace("<", "&lt;")
 
15
    text = text.replace(">", "&gt;")
 
16
    return text