paulb@304 | 1 | #!/usr/bin/env python |
paulb@304 | 2 | |
paulb@304 | 3 | """ |
paulb@304 | 4 | XML-RPC support using libxml2dom. |
paulb@304 | 5 | |
paulb@304 | 6 | See: http://www.xmlrpc.com/spec |
paulb@304 | 7 | |
paulb@304 | 8 | Copyright (C) 2007 Paul Boddie <paul@boddie.org.uk> |
paulb@304 | 9 | |
paulb@304 | 10 | This program is free software; you can redistribute it and/or modify it under |
paulb@304 | 11 | the terms of the GNU Lesser General Public License as published by the Free |
paulb@304 | 12 | Software Foundation; either version 3 of the License, or (at your option) any |
paulb@304 | 13 | later version. |
paulb@304 | 14 | |
paulb@304 | 15 | This program is distributed in the hope that it will be useful, but WITHOUT |
paulb@304 | 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paulb@304 | 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
paulb@304 | 18 | details. |
paulb@304 | 19 | |
paulb@304 | 20 | You should have received a copy of the GNU Lesser General Public License along |
paulb@304 | 21 | with this program. If not, see <http://www.gnu.org/licenses/>. |
paulb@304 | 22 | |
paulb@304 | 23 | -------- |
paulb@304 | 24 | |
paulb@304 | 25 | The sending and receiving of XML-RPC messages can be done using traditional HTTP |
paulb@304 | 26 | libraries. |
paulb@304 | 27 | |
paulb@304 | 28 | See tests/xmlrpc_test.py for more details. |
paulb@304 | 29 | """ |
paulb@304 | 30 | |
paulb@304 | 31 | import libxml2dom |
paulb@304 | 32 | from libxml2dom.macrolib import * |
paulb@304 | 33 | from libxml2dom.macrolib import \ |
paulb@304 | 34 | createDocument as Node_createDocument |
paulb@307 | 35 | import datetime |
paulb@304 | 36 | |
paulb@304 | 37 | class XMLRPCImplementation(libxml2dom.Implementation): |
paulb@304 | 38 | |
paulb@304 | 39 | "Contains an XML-RPC-specific implementation." |
paulb@304 | 40 | |
paulb@304 | 41 | # Wrapping of documents. |
paulb@304 | 42 | |
paulb@304 | 43 | def adoptDocument(self, node): |
paulb@304 | 44 | return XMLRPCDocument(node, self) |
paulb@304 | 45 | |
paulb@304 | 46 | # Factory functions. |
paulb@304 | 47 | |
paulb@304 | 48 | def get_node(self, _node, context_node): |
paulb@304 | 49 | |
paulb@304 | 50 | """ |
paulb@304 | 51 | Get a libxml2dom node for the given low-level '_node' and libxml2dom |
paulb@304 | 52 | 'context_node'. |
paulb@304 | 53 | """ |
paulb@304 | 54 | |
paulb@304 | 55 | if Node_nodeType(_node) == context_node.ELEMENT_NODE: |
paulb@304 | 56 | |
paulb@304 | 57 | # Make special elements. |
paulb@304 | 58 | |
paulb@304 | 59 | if Node_localName(_node) in ("methodCall", "methodResponse"): |
paulb@304 | 60 | return XMLRPCMethodElement(_node, self, context_node.ownerDocument) |
paulb@304 | 61 | elif Node_localName(_node) == "methodName": |
paulb@304 | 62 | return XMLRPCMethodNameElement(_node, self, context_node.ownerDocument) |
paulb@304 | 63 | elif Node_localName(_node) == "fault": |
paulb@304 | 64 | return XMLRPCFaultElement(_node, self, context_node.ownerDocument) |
paulb@304 | 65 | elif Node_localName(_node) == "string": |
paulb@304 | 66 | return XMLRPCStringElement(_node, self, context_node.ownerDocument) |
paulb@304 | 67 | elif Node_localName(_node) in ("int", "i4"): |
paulb@304 | 68 | return XMLRPCIntegerElement(_node, self, context_node.ownerDocument) |
paulb@304 | 69 | elif Node_localName(_node) == "boolean": |
paulb@304 | 70 | return XMLRPCBooleanElement(_node, self, context_node.ownerDocument) |
paulb@304 | 71 | elif Node_localName(_node) == "double": |
paulb@304 | 72 | return XMLRPCDoubleElement(_node, self, context_node.ownerDocument) |
paulb@304 | 73 | elif Node_localName(_node) == "dateTime.iso8601": |
paulb@304 | 74 | return XMLRPCDateTimeElement(_node, self, context_node.ownerDocument) |
paulb@304 | 75 | elif Node_localName(_node) == "base64": |
paulb@304 | 76 | return XMLRPCBase64Element(_node, self, context_node.ownerDocument) |
paulb@304 | 77 | elif Node_localName(_node) == "struct": |
paulb@304 | 78 | return XMLRPCStructElement(_node, self, context_node.ownerDocument) |
paulb@304 | 79 | elif Node_localName(_node) == "member": |
paulb@304 | 80 | return XMLRPCMemberElement(_node, self, context_node.ownerDocument) |
paulb@307 | 81 | elif Node_localName(_node) == "value": |
paulb@307 | 82 | return XMLRPCValueElement(_node, self, context_node.ownerDocument) |
paulb@304 | 83 | |
paulb@304 | 84 | # Otherwise, make generic XML-RPC elements. |
paulb@304 | 85 | |
paulb@304 | 86 | return XMLRPCElement(_node, self, context_node.ownerDocument) |
paulb@304 | 87 | |
paulb@304 | 88 | else: |
paulb@304 | 89 | return libxml2dom.Implementation.get_node(self, _node, context_node) |
paulb@304 | 90 | |
paulb@304 | 91 | # Convenience functions. |
paulb@304 | 92 | |
paulb@304 | 93 | def createXMLRPCMessage(self, namespaceURI, localName): |
paulb@304 | 94 | |
paulb@304 | 95 | "Create a new XML-RPC message document (fragment)." |
paulb@304 | 96 | |
paulb@304 | 97 | return XMLRPCDocument(Node_createDocument(namespaceURI, localName, None), self).documentElement |
paulb@304 | 98 | |
paulb@307 | 99 | def createMethodCall(self): |
paulb@307 | 100 | return self.createXMLRPCMessage(None, "methodCall") |
paulb@307 | 101 | |
paulb@307 | 102 | def createMethodResponse(self): |
paulb@307 | 103 | return self.createXMLRPCMessage(None, "methodResponse") |
paulb@307 | 104 | |
paulb@307 | 105 | # Internal utility functions. |
paulb@307 | 106 | |
paulb@307 | 107 | def boolean(s): |
paulb@307 | 108 | if s.lower() == "true": |
paulb@307 | 109 | return True |
paulb@307 | 110 | elif s.lower() == "false": |
paulb@307 | 111 | return False |
paulb@307 | 112 | else: |
paulb@307 | 113 | raise ValueError, "String value %s not convertable to boolean." % repr(s) |
paulb@307 | 114 | |
paulb@307 | 115 | def iso8601(s): |
paulb@307 | 116 | return s |
paulb@307 | 117 | |
paulb@304 | 118 | # Node classes. |
paulb@304 | 119 | |
paulb@304 | 120 | class XMLRPCNode(libxml2dom.Node): |
paulb@304 | 121 | |
paulb@304 | 122 | "Convenience modifications to nodes specific to libxml2dom.xmlrpc." |
paulb@304 | 123 | |
paulb@304 | 124 | pass |
paulb@304 | 125 | |
paulb@307 | 126 | class XMLRPCElement(XMLRPCNode): |
paulb@307 | 127 | |
paulb@307 | 128 | "An XML-RPC element." |
paulb@307 | 129 | |
paulb@307 | 130 | pass |
paulb@307 | 131 | |
paulb@304 | 132 | class XMLRPCDocument(libxml2dom._Document, XMLRPCNode): |
paulb@304 | 133 | |
paulb@304 | 134 | "An XML-RPC document fragment." |
paulb@304 | 135 | |
paulb@304 | 136 | def _method(self): |
paulb@307 | 137 | return (self.xpath("./methodCall|./methodResponse") or [None])[0] |
paulb@304 | 138 | |
paulb@304 | 139 | method = property(_method) |
paulb@304 | 140 | |
paulb@307 | 141 | # Convenience methods and properties. |
paulb@307 | 142 | |
paulb@307 | 143 | def _methodName(self): |
paulb@307 | 144 | if self.method is not None: |
paulb@307 | 145 | return self.method.name |
paulb@307 | 146 | else: |
paulb@307 | 147 | return None |
paulb@307 | 148 | |
paulb@307 | 149 | def _parameterItems(self): |
paulb@307 | 150 | if self.method is not None: |
paulb@307 | 151 | return self.method.parameterItems |
paulb@307 | 152 | else: |
paulb@307 | 153 | return None |
paulb@307 | 154 | |
paulb@307 | 155 | def _parameterValues(self): |
paulb@307 | 156 | if self.method is not None: |
paulb@307 | 157 | return self.method.parameterValues |
paulb@307 | 158 | else: |
paulb@307 | 159 | return None |
paulb@304 | 160 | |
paulb@307 | 161 | def _parameterMap(self): |
paulb@307 | 162 | if self.method is not None: |
paulb@307 | 163 | return self.method.parameterMap |
paulb@307 | 164 | else: |
paulb@307 | 165 | return None |
paulb@307 | 166 | |
paulb@307 | 167 | def _fault(self): |
paulb@307 | 168 | if self.method is not None: |
paulb@307 | 169 | return self.method.fault |
paulb@307 | 170 | else: |
paulb@307 | 171 | return None |
paulb@304 | 172 | |
paulb@307 | 173 | # Node construction methods. |
paulb@307 | 174 | |
paulb@307 | 175 | def createMethodCall(self): |
paulb@307 | 176 | return self.ownerDocument.createElement("methodCall") |
paulb@307 | 177 | |
paulb@307 | 178 | def createMethodResponse(self): |
paulb@307 | 179 | return self.ownerDocument.createElement("methodResponse") |
paulb@307 | 180 | |
paulb@307 | 181 | methodName = property(_methodName) |
paulb@307 | 182 | parameterItems = property(_parameterItems) |
paulb@307 | 183 | parameterValues = property(_parameterValues) |
paulb@307 | 184 | parameterMap = property(_parameterMap) |
paulb@307 | 185 | fault = property(_fault) |
paulb@304 | 186 | |
paulb@304 | 187 | class XMLRPCMethodElement(XMLRPCNode): |
paulb@304 | 188 | |
paulb@304 | 189 | "An XML-RPC method element." |
paulb@304 | 190 | |
paulb@304 | 191 | def _fault(self): |
paulb@307 | 192 | return (self.xpath("./fault") or [None])[0] |
paulb@304 | 193 | |
paulb@304 | 194 | def _methodName(self): |
paulb@307 | 195 | return (self.xpath("./methodName") or [None])[0] |
paulb@307 | 196 | |
paulb@307 | 197 | def _name(self): |
paulb@307 | 198 | name = self.methodName |
paulb@307 | 199 | if name is not None: |
paulb@307 | 200 | return name.value |
paulb@307 | 201 | else: |
paulb@307 | 202 | return None |
paulb@307 | 203 | |
paulb@307 | 204 | def _setName(self, name): |
paulb@307 | 205 | if self.methodName is None: |
paulb@307 | 206 | methodName = self.createMethodName() |
paulb@307 | 207 | self.appendChild(methodName) |
paulb@307 | 208 | self.methodName.value = name |
paulb@304 | 209 | |
paulb@304 | 210 | def _parameters(self): |
paulb@307 | 211 | return self.xpath("./params/param") |
paulb@307 | 212 | |
paulb@307 | 213 | def _parameterItems(self): |
paulb@307 | 214 | values = self.xpath("./params/param/value") |
paulb@307 | 215 | if values: |
paulb@307 | 216 | items = [] |
paulb@307 | 217 | for value in values: |
paulb@307 | 218 | items.append(self._item_contents(value)) |
paulb@307 | 219 | return items |
paulb@307 | 220 | else: |
paulb@307 | 221 | return [] |
paulb@304 | 222 | |
paulb@304 | 223 | def _parameterValues(self): |
paulb@307 | 224 | return self._value_contents(self.parameterItems) |
paulb@307 | 225 | |
paulb@307 | 226 | def _setParameterValues(self, parameters): |
paulb@307 | 227 | param_list = self.parameters |
paulb@307 | 228 | params = (self.xpath("./params") or [None])[0] |
paulb@307 | 229 | if params: |
paulb@307 | 230 | if param_list: |
paulb@307 | 231 | for param in param_list: |
paulb@307 | 232 | params.removeChild(param) |
paulb@307 | 233 | else: |
paulb@307 | 234 | params = self.createParameters() |
paulb@307 | 235 | self.appendChild(params) |
paulb@307 | 236 | |
paulb@307 | 237 | for parameter in parameters: |
paulb@307 | 238 | param = self.ownerDocument.createElement("param") |
paulb@307 | 239 | params.appendChild(param) |
paulb@307 | 240 | value = self.ownerDocument.createElement("value") |
paulb@307 | 241 | param.appendChild(value) |
paulb@307 | 242 | |
paulb@307 | 243 | # NOTE: Only handles simple types. |
paulb@307 | 244 | |
paulb@307 | 245 | container = self._make_container(parameter) |
paulb@307 | 246 | value.appendChild(container) |
paulb@307 | 247 | text = self.ownerDocument.createTextNode(unicode(parameter)) |
paulb@307 | 248 | container.appendChild(text) |
paulb@307 | 249 | |
paulb@307 | 250 | def _parameterMap(self): |
paulb@307 | 251 | return self._map_contents(self.parameterItems) |
paulb@307 | 252 | |
paulb@307 | 253 | # Internal data. |
paulb@307 | 254 | |
paulb@307 | 255 | converters = { |
paulb@307 | 256 | "string" : unicode, |
paulb@307 | 257 | "int" : int, |
paulb@307 | 258 | "i4" : int, |
paulb@307 | 259 | "double" : float, |
paulb@307 | 260 | "boolean" : boolean, # see the module globals |
paulb@307 | 261 | "dateTime.iso8601" : iso8601, # see the module globals |
paulb@307 | 262 | "base64" : str |
paulb@307 | 263 | } |
paulb@307 | 264 | |
paulb@307 | 265 | # Internal methods. |
paulb@307 | 266 | |
paulb@307 | 267 | def _make_container(self, parameter): |
paulb@307 | 268 | if isinstance(parameter, (str, unicode)): |
paulb@307 | 269 | return self.ownerDocument.createElement("string") |
paulb@307 | 270 | elif isinstance(parameter, (int, long)): |
paulb@307 | 271 | return self.ownerDocument.createElement("int") |
paulb@307 | 272 | elif isinstance(parameter, float): |
paulb@307 | 273 | return self.ownerDocument.createElement("double") |
paulb@307 | 274 | elif isinstance(parameter, bool): |
paulb@307 | 275 | return self.ownerDocument.createElement("boolean") |
paulb@307 | 276 | elif isinstance(parameter, datetime.datetime): |
paulb@307 | 277 | return self.ownerDocument.createElement("dateTime.iso8601") |
paulb@307 | 278 | |
paulb@307 | 279 | def _from_string(self, typename, value): |
paulb@307 | 280 | return self.converters.get(typename, str)(value) |
paulb@307 | 281 | |
paulb@307 | 282 | def _item_contents(self, value): |
paulb@307 | 283 | if value.type == "struct": |
paulb@307 | 284 | items = [] |
paulb@307 | 285 | for member in value.container.members: |
paulb@307 | 286 | if member.value.type == "struct": |
paulb@307 | 287 | items.append((member.name, self._item_contents(member.value))) |
paulb@307 | 288 | else: |
paulb@307 | 289 | items.append((member.name, self._from_string(member.value.type, member.value.container.value))) |
paulb@307 | 290 | return None, items |
paulb@307 | 291 | else: |
paulb@307 | 292 | return None, self._from_string(value.type, value.container.value) |
paulb@307 | 293 | |
paulb@307 | 294 | def _value_contents(self, items): |
paulb@307 | 295 | values = [] |
paulb@307 | 296 | for name, value in items: |
paulb@307 | 297 | if isinstance(value, list): |
paulb@307 | 298 | values.append(self._value_contents(value)) |
paulb@307 | 299 | elif name is None: |
paulb@307 | 300 | values.append(value) |
paulb@307 | 301 | else: |
paulb@307 | 302 | values.append((name, value)) |
paulb@304 | 303 | return values |
paulb@304 | 304 | |
paulb@307 | 305 | def _map_contents(self, items): |
paulb@307 | 306 | d = {} |
paulb@307 | 307 | for n, (name, value) in enumerate(items): |
paulb@307 | 308 | key_name = name or str(n) |
paulb@307 | 309 | if isinstance(value, list): |
paulb@307 | 310 | d[key_name] = self._map_contents(value) |
paulb@307 | 311 | else: |
paulb@307 | 312 | d[key_name] = value |
paulb@307 | 313 | return d |
paulb@307 | 314 | |
paulb@307 | 315 | # Node construction methods. |
paulb@307 | 316 | |
paulb@307 | 317 | def createMethodName(self): |
paulb@307 | 318 | return self.ownerDocument.createElement("methodName") |
paulb@307 | 319 | |
paulb@307 | 320 | def createParameters(self): |
paulb@307 | 321 | return self.ownerDocument.createElement("params") |
paulb@307 | 322 | |
paulb@304 | 323 | def createFault(self): |
paulb@304 | 324 | return self.ownerDocument.createElement("fault") |
paulb@304 | 325 | |
paulb@304 | 326 | fault = property(_fault) |
paulb@307 | 327 | name = property(_name, _setName) |
paulb@304 | 328 | methodName = property(_methodName) |
paulb@304 | 329 | parameters = property(_parameters) |
paulb@307 | 330 | parameterItems = property(_parameterItems) |
paulb@307 | 331 | parameterValues = property(_parameterValues, _setParameterValues) |
paulb@307 | 332 | parameterMap = property(_parameterMap) |
paulb@304 | 333 | |
paulb@304 | 334 | class XMLRPCStringElement(XMLRPCNode): |
paulb@304 | 335 | |
paulb@304 | 336 | "An XML-RPC string element." |
paulb@304 | 337 | |
paulb@304 | 338 | def _value(self): |
paulb@304 | 339 | return self.textContent.strip() |
paulb@304 | 340 | |
paulb@304 | 341 | def _setValue(self, value): |
paulb@304 | 342 | for node in self.childNodes: |
paulb@304 | 343 | self.removeChild(node) |
paulb@304 | 344 | text = self.ownerDocument.createTextNode(value) |
paulb@304 | 345 | self.appendChild(text) |
paulb@304 | 346 | |
paulb@304 | 347 | value = property(_value, _setValue) |
paulb@304 | 348 | |
paulb@307 | 349 | class XMLRPCValueElement(XMLRPCStringElement): |
paulb@307 | 350 | |
paulb@307 | 351 | "An XML-RPC value element." |
paulb@307 | 352 | |
paulb@307 | 353 | def _type(self): |
paulb@307 | 354 | elements = self.xpath("*") |
paulb@307 | 355 | if elements: |
paulb@307 | 356 | return elements[0].localName |
paulb@307 | 357 | else: |
paulb@307 | 358 | return "string" |
paulb@307 | 359 | |
paulb@307 | 360 | def _container(self): |
paulb@307 | 361 | return (self.xpath("*") or [self])[0] |
paulb@307 | 362 | |
paulb@307 | 363 | type = property(_type) |
paulb@307 | 364 | container = property(_container) |
paulb@307 | 365 | |
paulb@304 | 366 | class XMLRPCMethodNameElement(XMLRPCStringElement): |
paulb@304 | 367 | |
paulb@304 | 368 | "An XML-RPC method element." |
paulb@304 | 369 | |
paulb@304 | 370 | pass |
paulb@304 | 371 | |
paulb@304 | 372 | class XMLRPCIntegerElement(XMLRPCStringElement): |
paulb@304 | 373 | |
paulb@304 | 374 | "An XML-RPC integer element." |
paulb@304 | 375 | |
paulb@304 | 376 | pass |
paulb@304 | 377 | |
paulb@304 | 378 | class XMLRPCBooleanElement(XMLRPCStringElement): |
paulb@304 | 379 | |
paulb@304 | 380 | "An XML-RPC boolean element." |
paulb@304 | 381 | |
paulb@304 | 382 | pass |
paulb@304 | 383 | |
paulb@304 | 384 | class XMLRPCDoubleElement(XMLRPCStringElement): |
paulb@304 | 385 | |
paulb@304 | 386 | "An XML-RPC double floating point number element." |
paulb@304 | 387 | |
paulb@304 | 388 | pass |
paulb@304 | 389 | |
paulb@304 | 390 | class XMLRPCDateTimeElement(XMLRPCStringElement): |
paulb@304 | 391 | |
paulb@304 | 392 | "An XML-RPC date/time element." |
paulb@304 | 393 | |
paulb@304 | 394 | pass |
paulb@304 | 395 | |
paulb@304 | 396 | class XMLRPCBase64Element(XMLRPCStringElement): |
paulb@304 | 397 | |
paulb@304 | 398 | "An XML-RPC integer element." |
paulb@304 | 399 | |
paulb@304 | 400 | pass |
paulb@304 | 401 | |
paulb@304 | 402 | class XMLRPCStructElement(XMLRPCNode): |
paulb@304 | 403 | |
paulb@304 | 404 | "An XML-RPC structure element." |
paulb@304 | 405 | |
paulb@304 | 406 | def _members(self): |
paulb@304 | 407 | return self.xpath("./member") |
paulb@304 | 408 | |
paulb@304 | 409 | members = property(_members) |
paulb@304 | 410 | |
paulb@304 | 411 | class XMLRPCMemberElement(XMLRPCNode): |
paulb@304 | 412 | |
paulb@304 | 413 | "An XML-RPC structure member element." |
paulb@304 | 414 | |
paulb@304 | 415 | def _name(self): |
paulb@307 | 416 | value = self.xpath("./name") |
paulb@307 | 417 | if value: |
paulb@307 | 418 | return value[0].textContent.strip() |
paulb@307 | 419 | else: |
paulb@307 | 420 | return None |
paulb@304 | 421 | |
paulb@304 | 422 | def _value(self): |
paulb@307 | 423 | return (self.xpath("./value") or [None])[0] |
paulb@304 | 424 | |
paulb@304 | 425 | name = property(_name) |
paulb@304 | 426 | value = property(_value) |
paulb@304 | 427 | |
paulb@304 | 428 | class XMLRPCFaultElement(XMLRPCNode): |
paulb@304 | 429 | |
paulb@304 | 430 | "An XML-RPC fault element." |
paulb@304 | 431 | |
paulb@304 | 432 | def _code(self): |
paulb@307 | 433 | code = self.xpath("./value/struct/member[./name/text() = 'faultCode']/value/int") |
paulb@307 | 434 | if code: |
paulb@307 | 435 | return code[0].value |
paulb@307 | 436 | else: |
paulb@307 | 437 | return None |
paulb@304 | 438 | |
paulb@304 | 439 | def _reason(self): |
paulb@307 | 440 | reason = self.xpath("./value/struct/member[./name/text() = 'faultString']/value/string") |
paulb@307 | 441 | if reason: |
paulb@307 | 442 | return reason[0].value |
paulb@307 | 443 | else: |
paulb@307 | 444 | return None |
paulb@304 | 445 | |
paulb@304 | 446 | code = property(_code) |
paulb@304 | 447 | reason = property(_reason) |
paulb@304 | 448 | |
paulb@304 | 449 | # Utility functions. |
paulb@304 | 450 | |
paulb@304 | 451 | createDocument = libxml2dom.createDocument |
paulb@304 | 452 | createDocumentType = libxml2dom.createDocumentType |
paulb@304 | 453 | |
paulb@304 | 454 | def createXMLRPCMessage(namespaceURI, localName): |
paulb@307 | 455 | return default_impl.createXMLRPCMessage(None, localName) |
paulb@307 | 456 | |
paulb@307 | 457 | def createMethodCall(): |
paulb@307 | 458 | return default_impl.createMethodCall() |
paulb@307 | 459 | |
paulb@307 | 460 | def createMethodResponse(): |
paulb@307 | 461 | return default_impl.createMethodResponse() |
paulb@304 | 462 | |
paulb@304 | 463 | def parse(stream_or_string, html=0, htmlencoding=None, unfinished=0, impl=None): |
paulb@304 | 464 | return libxml2dom.parse(stream_or_string, html=html, htmlencoding=htmlencoding, unfinished=unfinished, impl=(impl or default_impl)) |
paulb@304 | 465 | |
paulb@304 | 466 | def parseFile(filename, html=0, htmlencoding=None, unfinished=0, impl=None): |
paulb@304 | 467 | return libxml2dom.parseFile(filename, html=html, htmlencoding=htmlencoding, unfinished=unfinished, impl=(impl or default_impl)) |
paulb@304 | 468 | |
paulb@304 | 469 | def parseString(s, html=0, htmlencoding=None, unfinished=0, impl=None): |
paulb@304 | 470 | return libxml2dom.parseString(s, html=html, htmlencoding=htmlencoding, unfinished=unfinished, impl=(impl or default_impl)) |
paulb@304 | 471 | |
paulb@304 | 472 | def parseURI(uri, html=0, htmlencoding=None, unfinished=0, impl=None): |
paulb@304 | 473 | return libxml2dom.parseURI(uri, html=html, htmlencoding=htmlencoding, unfinished=unfinished, impl=(impl or default_impl)) |
paulb@304 | 474 | |
paulb@304 | 475 | # Single instance of the implementation. |
paulb@304 | 476 | |
paulb@304 | 477 | default_impl = XMLRPCImplementation() |
paulb@304 | 478 | |
paulb@304 | 479 | # vim: tabstop=4 expandtab shiftwidth=4 |