66
66
# --------------------------------------------------------------------
67
67
68
68
69
+ @_api .deprecated ("3.6" , alternative = "Vendor the code" )
69
70
def escape_cdata (s ):
71
+ return _escape_cdata (s )
72
+
73
+
74
+ def _escape_cdata (s ):
70
75
s = s .replace ("&" , "&" )
71
76
s = s .replace ("<" , "<" )
72
77
s = s .replace (">" , ">" )
@@ -76,12 +81,22 @@ def escape_cdata(s):
76
81
_escape_xml_comment = re .compile (r'-(?=-)' )
77
82
78
83
84
+ @_api .deprecated ("3.6" , alternative = "Vendor the code" )
79
85
def escape_comment (s ):
80
- s = escape_cdata (s )
86
+ return _escape_comment .sub (s )
87
+
88
+
89
+ def _escape_comment (s ):
90
+ s = _escape_cdata (s )
81
91
return _escape_xml_comment .sub ('- ' , s )
82
92
83
93
94
+ @_api .deprecated ("3.6" , alternative = "Vendor the code" )
84
95
def escape_attrib (s ):
96
+ return _escape_attrib (s )
97
+
98
+
99
+ def _escape_attrib (s ):
85
100
s = s .replace ("&" , "&" )
86
101
s = s .replace ("'" , "'" )
87
102
s = s .replace ('"' , """ )
@@ -91,12 +106,17 @@ def escape_attrib(s):
91
106
92
107
93
108
def _quote_escape_attrib (s ):
94
- return ('"' + escape_cdata (s ) + '"' if '"' not in s else
95
- "'" + escape_cdata (s ) + "'" if "'" not in s else
96
- '"' + escape_attrib (s ) + '"' )
109
+ return ('"' + _escape_cdata (s ) + '"' if '"' not in s else
110
+ "'" + _escape_cdata (s ) + "'" if "'" not in s else
111
+ '"' + _escape_attrib (s ) + '"' )
97
112
98
113
114
+ @_api .deprecated ("3.6" , alternative = "Vendor the code" )
99
115
def short_float_fmt (x ):
116
+ return _short_float_fmt (x )
117
+
118
+
119
+ def _short_float_fmt (x ):
100
120
"""
101
121
Create a short string representation of a float, which is %f
102
122
formatting with trailing zeros and the decimal point removed.
@@ -130,7 +150,7 @@ def __flush(self, indent=True):
130
150
self .__open = 0
131
151
if self .__data :
132
152
data = '' .join (self .__data )
133
- self .__write (escape_cdata (data ))
153
+ self .__write (_escape_cdata (data ))
134
154
self .__data = []
135
155
136
156
def start (self , tag , attrib = {}, ** extra ):
@@ -153,14 +173,14 @@ def start(self, tag, attrib={}, **extra):
153
173
An element identifier.
154
174
"""
155
175
self .__flush ()
156
- tag = escape_cdata (tag )
176
+ tag = _escape_cdata (tag )
157
177
self .__data = []
158
178
self .__tags .append (tag )
159
179
self .__write (self .__indentation [:len (self .__tags ) - 1 ])
160
180
self .__write ("<%s" % tag )
161
181
for k , v in {** attrib , ** extra }.items ():
162
182
if v :
163
- k = escape_cdata (k )
183
+ k = _escape_cdata (k )
164
184
v = _quote_escape_attrib (v )
165
185
self .__write (' %s=%s' % (k , v ))
166
186
self .__open = 1
@@ -177,7 +197,7 @@ def comment(self, comment):
177
197
"""
178
198
self .__flush ()
179
199
self .__write (self .__indentation [:len (self .__tags )])
180
- self .__write ("<!-- %s -->\n " % escape_comment (comment ))
200
+ self .__write ("<!-- %s -->\n " % _escape_comment (comment ))
181
201
182
202
def data (self , text ):
183
203
"""
@@ -203,7 +223,7 @@ def end(self, tag=None, indent=True):
203
223
"""
204
224
if tag :
205
225
assert self .__tags , "unbalanced end(%s)" % tag
206
- assert escape_cdata (tag ) == self .__tags [- 1 ], \
226
+ assert _escape_cdata (tag ) == self .__tags [- 1 ], \
207
227
"expected end(%s), got %s" % (self .__tags [- 1 ], tag )
208
228
else :
209
229
assert self .__tags , "unbalanced end()"
0 commit comments