|
136 | 136 | name (None if not present). |
137 | 137 | """ |
138 | 138 |
|
139 | | -import re, string, time, operator |
| 139 | +import re, time, operator |
140 | 140 |
|
141 | 141 | from types import * |
142 | 142 |
|
@@ -164,10 +164,10 @@ def _decode(data, encoding, is8bit=re.compile("[\x80-\xff]").search): |
164 | 164 | data = unicode(data, encoding) |
165 | 165 | return data |
166 | 166 |
|
167 | | -def escape(s, replace=string.replace): |
168 | | - s = replace(s, "&", "&") |
169 | | - s = replace(s, "<", "<") |
170 | | - return replace(s, ">", ">",) |
| 167 | +def escape(s): |
| 168 | + s = s.replace("&", "&") |
| 169 | + s = s.replace("<", "<") |
| 170 | + return s.replace(">", ">",) |
171 | 171 |
|
172 | 172 | if unicode: |
173 | 173 | def _stringify(string): |
@@ -346,8 +346,7 @@ def __repr__(self): |
346 | 346 | return "<DateTime %s at %x>" % (repr(self.value), id(self)) |
347 | 347 |
|
348 | 348 | def decode(self, data): |
349 | | - data = str(data) |
350 | | - self.value = string.strip(data) |
| 349 | + self.value = str(data).strip() |
351 | 350 |
|
352 | 351 | def encode(self, out): |
353 | 352 | out.write("<value><dateTime.iso8601>") |
@@ -513,24 +512,6 @@ def close(self): |
513 | 512 | self._parser.Parse("", 1) # end of data |
514 | 513 | del self._target, self._parser # get rid of circular references |
515 | 514 |
|
516 | | -class SlowParser: |
517 | | - """Default XML parser (based on xmllib.XMLParser).""" |
518 | | - # this is about 10 times slower than sgmlop, on roundtrip |
519 | | - # testing. |
520 | | - def __init__(self, target): |
521 | | - import xmllib # lazy subclassing (!) |
522 | | - if xmllib.XMLParser not in SlowParser.__bases__: |
523 | | - SlowParser.__bases__ = (xmllib.XMLParser,) |
524 | | - self.handle_xml = target.xml |
525 | | - self.unknown_starttag = target.start |
526 | | - self.handle_data = target.data |
527 | | - self.handle_cdata = target.data |
528 | | - self.unknown_endtag = target.end |
529 | | - try: |
530 | | - xmllib.XMLParser.__init__(self, accept_utf8=1) |
531 | | - except TypeError: |
532 | | - xmllib.XMLParser.__init__(self) # pre-2.0 |
533 | | - |
534 | 515 | # -------------------------------------------------------------------- |
535 | 516 | # XML-RPC marshalling and unmarshalling code |
536 | 517 |
|
@@ -586,7 +567,7 @@ def dumps(self, values): |
586 | 567 | dump(v, write) |
587 | 568 | write("</param>\n") |
588 | 569 | write("</params>\n") |
589 | | - result = string.join(out, "") |
| 570 | + result = "".join(out) |
590 | 571 | return result |
591 | 572 |
|
592 | 573 | def __dump(self, value, write): |
@@ -786,14 +767,14 @@ def start(self, tag, attrs): |
786 | 767 | def data(self, text): |
787 | 768 | self._data.append(text) |
788 | 769 |
|
789 | | - def end(self, tag, join=string.join): |
| 770 | + def end(self, tag): |
790 | 771 | # call the appropriate end tag handler |
791 | 772 | try: |
792 | 773 | f = self.dispatch[tag] |
793 | 774 | except KeyError: |
794 | 775 | pass # unknown tag ? |
795 | 776 | else: |
796 | | - return f(self, join(self._data, "")) |
| 777 | + return f(self, "".join(self._data)) |
797 | 778 |
|
798 | 779 | # |
799 | 780 | # accelerator support |
@@ -1085,7 +1066,7 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None, |
1085 | 1066 | ) |
1086 | 1067 | else: |
1087 | 1068 | return data # return as is |
1088 | | - return string.join(data, "") |
| 1069 | + return "".join(data) |
1089 | 1070 |
|
1090 | 1071 | ## |
1091 | 1072 | # Convert an XML-RPC packet to a Python object. If the XML-RPC packet |
@@ -1210,7 +1191,7 @@ def get_host_info(self, host): |
1210 | 1191 | if auth: |
1211 | 1192 | import base64 |
1212 | 1193 | auth = base64.encodestring(urllib.unquote(auth)) |
1213 | | - auth = string.join(string.split(auth), "") # get rid of whitespace |
| 1194 | + auth = "".join(auth.split()) # get rid of whitespace |
1214 | 1195 | extra_headers = [ |
1215 | 1196 | ("Authorization", "Basic " + auth) |
1216 | 1197 | ] |
|
0 commit comments