mirror of
https://github.com/python/cpython.git
synced 2025-09-03 15:31:08 +00:00
Remove the SlowParser class because it depended on the xmllib module
which was removed. Use string methods rather than the string module.
This commit is contained in:
parent
53855c6495
commit
ff11334927
1 changed files with 11 additions and 30 deletions
|
@ -136,7 +136,7 @@ Exported functions:
|
||||||
name (None if not present).
|
name (None if not present).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import re, string, time, operator
|
import re, time, operator
|
||||||
|
|
||||||
from types import *
|
from types import *
|
||||||
|
|
||||||
|
@ -164,10 +164,10 @@ def _decode(data, encoding, is8bit=re.compile("[\x80-\xff]").search):
|
||||||
data = unicode(data, encoding)
|
data = unicode(data, encoding)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def escape(s, replace=string.replace):
|
def escape(s):
|
||||||
s = replace(s, "&", "&")
|
s = s.replace("&", "&")
|
||||||
s = replace(s, "<", "<")
|
s = s.replace("<", "<")
|
||||||
return replace(s, ">", ">",)
|
return s.replace(">", ">",)
|
||||||
|
|
||||||
if unicode:
|
if unicode:
|
||||||
def _stringify(string):
|
def _stringify(string):
|
||||||
|
@ -346,8 +346,7 @@ class DateTime:
|
||||||
return "<DateTime %s at %x>" % (repr(self.value), id(self))
|
return "<DateTime %s at %x>" % (repr(self.value), id(self))
|
||||||
|
|
||||||
def decode(self, data):
|
def decode(self, data):
|
||||||
data = str(data)
|
self.value = str(data).strip()
|
||||||
self.value = string.strip(data)
|
|
||||||
|
|
||||||
def encode(self, out):
|
def encode(self, out):
|
||||||
out.write("<value><dateTime.iso8601>")
|
out.write("<value><dateTime.iso8601>")
|
||||||
|
@ -513,24 +512,6 @@ else:
|
||||||
self._parser.Parse("", 1) # end of data
|
self._parser.Parse("", 1) # end of data
|
||||||
del self._target, self._parser # get rid of circular references
|
del self._target, self._parser # get rid of circular references
|
||||||
|
|
||||||
class SlowParser:
|
|
||||||
"""Default XML parser (based on xmllib.XMLParser)."""
|
|
||||||
# this is about 10 times slower than sgmlop, on roundtrip
|
|
||||||
# testing.
|
|
||||||
def __init__(self, target):
|
|
||||||
import xmllib # lazy subclassing (!)
|
|
||||||
if xmllib.XMLParser not in SlowParser.__bases__:
|
|
||||||
SlowParser.__bases__ = (xmllib.XMLParser,)
|
|
||||||
self.handle_xml = target.xml
|
|
||||||
self.unknown_starttag = target.start
|
|
||||||
self.handle_data = target.data
|
|
||||||
self.handle_cdata = target.data
|
|
||||||
self.unknown_endtag = target.end
|
|
||||||
try:
|
|
||||||
xmllib.XMLParser.__init__(self, accept_utf8=1)
|
|
||||||
except TypeError:
|
|
||||||
xmllib.XMLParser.__init__(self) # pre-2.0
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# XML-RPC marshalling and unmarshalling code
|
# XML-RPC marshalling and unmarshalling code
|
||||||
|
|
||||||
|
@ -586,7 +567,7 @@ class Marshaller:
|
||||||
dump(v, write)
|
dump(v, write)
|
||||||
write("</param>\n")
|
write("</param>\n")
|
||||||
write("</params>\n")
|
write("</params>\n")
|
||||||
result = string.join(out, "")
|
result = "".join(out)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def __dump(self, value, write):
|
def __dump(self, value, write):
|
||||||
|
@ -786,14 +767,14 @@ class Unmarshaller:
|
||||||
def data(self, text):
|
def data(self, text):
|
||||||
self._data.append(text)
|
self._data.append(text)
|
||||||
|
|
||||||
def end(self, tag, join=string.join):
|
def end(self, tag):
|
||||||
# call the appropriate end tag handler
|
# call the appropriate end tag handler
|
||||||
try:
|
try:
|
||||||
f = self.dispatch[tag]
|
f = self.dispatch[tag]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass # unknown tag ?
|
pass # unknown tag ?
|
||||||
else:
|
else:
|
||||||
return f(self, join(self._data, ""))
|
return f(self, "".join(self._data))
|
||||||
|
|
||||||
#
|
#
|
||||||
# accelerator support
|
# accelerator support
|
||||||
|
@ -1085,7 +1066,7 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return data # return as is
|
return data # return as is
|
||||||
return string.join(data, "")
|
return "".join(data)
|
||||||
|
|
||||||
##
|
##
|
||||||
# Convert an XML-RPC packet to a Python object. If the XML-RPC packet
|
# Convert an XML-RPC packet to a Python object. If the XML-RPC packet
|
||||||
|
@ -1210,7 +1191,7 @@ class Transport:
|
||||||
if auth:
|
if auth:
|
||||||
import base64
|
import base64
|
||||||
auth = base64.encodestring(urllib.unquote(auth))
|
auth = base64.encodestring(urllib.unquote(auth))
|
||||||
auth = string.join(string.split(auth), "") # get rid of whitespace
|
auth = "".join(auth.split()) # get rid of whitespace
|
||||||
extra_headers = [
|
extra_headers = [
|
||||||
("Authorization", "Basic " + auth)
|
("Authorization", "Basic " + auth)
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue