diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2007-04-17 08:48:32 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2007-04-17 08:48:32 (GMT) |
commit | 9d72bb452bced3a100f07f8a9e30c4495a9ec41a (patch) | |
tree | c39762a764fcc16f2cfc42e2504e58ff31e159e6 /Lib/xml/etree | |
parent | ff11334927ee616d765b54a3851016b76a20bcec (diff) | |
download | cpython-9d72bb452bced3a100f07f8a9e30c4495a9ec41a.zip cpython-9d72bb452bced3a100f07f8a9e30c4495a9ec41a.tar.gz cpython-9d72bb452bced3a100f07f8a9e30c4495a9ec41a.tar.bz2 |
Remove functions in string module that are also string methods. Also remove:
* all calls to functions in the string module (except maketrans)
* everything from stropmodule except for maketrans() which is still used
Diffstat (limited to 'Lib/xml/etree')
-rw-r--r-- | Lib/xml/etree/ElementTree.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py index aed69bb..19bb747 100644 --- a/Lib/xml/etree/ElementTree.py +++ b/Lib/xml/etree/ElementTree.py @@ -109,7 +109,7 @@ __all__ = [ # structure, and convert it from and to XML. ## -import string, sys, re +import sys, re from . import ElementPath @@ -762,7 +762,7 @@ def _encode_entity(text, pattern=_escape): if text is None: text = "&#%d;" % ord(char) append(text) - return string.join(out, "") + return "".join(out) try: return _encode(pattern.sub(escape_entities, text), "ascii") except TypeError: @@ -772,7 +772,7 @@ def _encode_entity(text, pattern=_escape): # the following functions assume an ascii-compatible encoding # (or "utf-16") -def _escape_cdata(text, encoding=None, replace=string.replace): +def _escape_cdata(text, encoding=None): # escape character data try: if encoding: @@ -780,14 +780,14 @@ def _escape_cdata(text, encoding=None, replace=string.replace): text = _encode(text, encoding) except UnicodeError: return _encode_entity(text) - text = replace(text, "&", "&") - text = replace(text, "<", "<") - text = replace(text, ">", ">") + text = text.replace("&", "&") + text = text.replace("<", "<") + text = text.replace(">", ">") return text except (TypeError, AttributeError): _raise_serialization_error(text) -def _escape_attrib(text, encoding=None, replace=string.replace): +def _escape_attrib(text, encoding=None): # escape attribute value try: if encoding: @@ -795,11 +795,11 @@ def _escape_attrib(text, encoding=None, replace=string.replace): text = _encode(text, encoding) except UnicodeError: return _encode_entity(text) - text = replace(text, "&", "&") - text = replace(text, "'", "'") # FIXME: overkill - text = replace(text, "\"", """) - text = replace(text, "<", "<") - text = replace(text, ">", ">") + text = text.replace("&", "&") + text = text.replace("'", "'") # FIXME: overkill + text = text.replace("\"", """) + text = text.replace("<", "<") + text = text.replace(">", ">") return text except (TypeError, AttributeError): _raise_serialization_error(text) @@ -809,7 +809,7 @@ def fixtag(tag, namespaces): # tag and namespace declaration, if any if isinstance(tag, QName): tag = tag.text - namespace_uri, tag = string.split(tag[1:], "}", 1) + namespace_uri, tag = tag[1:].split("}", 1) prefix = namespaces.get(namespace_uri) if prefix is None: prefix = _namespace_map.get(namespace_uri) @@ -982,7 +982,7 @@ def tostring(element, encoding=None): file = dummy() file.write = data.append ElementTree(element).write(file, encoding) - return string.join(data, "") + return "".join(data) ## # Generic element structure builder. This builder converts a sequence @@ -1021,7 +1021,7 @@ class TreeBuilder: def _flush(self): if self._data: if self._last is not None: - text = string.join(self._data, "") + text = "".join(self._data) if self._tail: assert self._last.tail is None, "internal error (tail)" self._last.tail = text @@ -1182,7 +1182,7 @@ class XMLTreeBuilder: if prefix == ">": self._doctype = None return - text = string.strip(text) + text = text.strip() if not text: return self._doctype.append(text) |