Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib64/python2....
File: xmlrpclib.py
#
[0] Fix | Delete
# XML-RPC CLIENT LIBRARY
[1] Fix | Delete
# $Id$
[2] Fix | Delete
#
[3] Fix | Delete
# an XML-RPC client interface for Python.
[4] Fix | Delete
#
[5] Fix | Delete
# the marshalling and response parser code can also be used to
[6] Fix | Delete
# implement XML-RPC servers.
[7] Fix | Delete
#
[8] Fix | Delete
# Notes:
[9] Fix | Delete
# this version is designed to work with Python 2.1 or newer.
[10] Fix | Delete
#
[11] Fix | Delete
# History:
[12] Fix | Delete
# 1999-01-14 fl Created
[13] Fix | Delete
# 1999-01-15 fl Changed dateTime to use localtime
[14] Fix | Delete
# 1999-01-16 fl Added Binary/base64 element, default to RPC2 service
[15] Fix | Delete
# 1999-01-19 fl Fixed array data element (from Skip Montanaro)
[16] Fix | Delete
# 1999-01-21 fl Fixed dateTime constructor, etc.
[17] Fix | Delete
# 1999-02-02 fl Added fault handling, handle empty sequences, etc.
[18] Fix | Delete
# 1999-02-10 fl Fixed problem with empty responses (from Skip Montanaro)
[19] Fix | Delete
# 1999-06-20 fl Speed improvements, pluggable parsers/transports (0.9.8)
[20] Fix | Delete
# 2000-11-28 fl Changed boolean to check the truth value of its argument
[21] Fix | Delete
# 2001-02-24 fl Added encoding/Unicode/SafeTransport patches
[22] Fix | Delete
# 2001-02-26 fl Added compare support to wrappers (0.9.9/1.0b1)
[23] Fix | Delete
# 2001-03-28 fl Make sure response tuple is a singleton
[24] Fix | Delete
# 2001-03-29 fl Don't require empty params element (from Nicholas Riley)
[25] Fix | Delete
# 2001-06-10 fl Folded in _xmlrpclib accelerator support (1.0b2)
[26] Fix | Delete
# 2001-08-20 fl Base xmlrpclib.Error on built-in Exception (from Paul Prescod)
[27] Fix | Delete
# 2001-09-03 fl Allow Transport subclass to override getparser
[28] Fix | Delete
# 2001-09-10 fl Lazy import of urllib, cgi, xmllib (20x import speedup)
[29] Fix | Delete
# 2001-10-01 fl Remove containers from memo cache when done with them
[30] Fix | Delete
# 2001-10-01 fl Use faster escape method (80% dumps speedup)
[31] Fix | Delete
# 2001-10-02 fl More dumps microtuning
[32] Fix | Delete
# 2001-10-04 fl Make sure import expat gets a parser (from Guido van Rossum)
[33] Fix | Delete
# 2001-10-10 sm Allow long ints to be passed as ints if they don't overflow
[34] Fix | Delete
# 2001-10-17 sm Test for int and long overflow (allows use on 64-bit systems)
[35] Fix | Delete
# 2001-11-12 fl Use repr() to marshal doubles (from Paul Felix)
[36] Fix | Delete
# 2002-03-17 fl Avoid buffered read when possible (from James Rucker)
[37] Fix | Delete
# 2002-04-07 fl Added pythondoc comments
[38] Fix | Delete
# 2002-04-16 fl Added __str__ methods to datetime/binary wrappers
[39] Fix | Delete
# 2002-05-15 fl Added error constants (from Andrew Kuchling)
[40] Fix | Delete
# 2002-06-27 fl Merged with Python CVS version
[41] Fix | Delete
# 2002-10-22 fl Added basic authentication (based on code from Phillip Eby)
[42] Fix | Delete
# 2003-01-22 sm Add support for the bool type
[43] Fix | Delete
# 2003-02-27 gvr Remove apply calls
[44] Fix | Delete
# 2003-04-24 sm Use cStringIO if available
[45] Fix | Delete
# 2003-04-25 ak Add support for nil
[46] Fix | Delete
# 2003-06-15 gn Add support for time.struct_time
[47] Fix | Delete
# 2003-07-12 gp Correct marshalling of Faults
[48] Fix | Delete
# 2003-10-31 mvl Add multicall support
[49] Fix | Delete
# 2004-08-20 mvl Bump minimum supported Python version to 2.1
[50] Fix | Delete
# 2014-12-02 ch/doko Add workaround for gzip bomb vulnerability
[51] Fix | Delete
#
[52] Fix | Delete
# Copyright (c) 1999-2002 by Secret Labs AB.
[53] Fix | Delete
# Copyright (c) 1999-2002 by Fredrik Lundh.
[54] Fix | Delete
#
[55] Fix | Delete
# info@pythonware.com
[56] Fix | Delete
# http://www.pythonware.com
[57] Fix | Delete
#
[58] Fix | Delete
# --------------------------------------------------------------------
[59] Fix | Delete
# The XML-RPC client interface is
[60] Fix | Delete
#
[61] Fix | Delete
# Copyright (c) 1999-2002 by Secret Labs AB
[62] Fix | Delete
# Copyright (c) 1999-2002 by Fredrik Lundh
[63] Fix | Delete
#
[64] Fix | Delete
# By obtaining, using, and/or copying this software and/or its
[65] Fix | Delete
# associated documentation, you agree that you have read, understood,
[66] Fix | Delete
# and will comply with the following terms and conditions:
[67] Fix | Delete
#
[68] Fix | Delete
# Permission to use, copy, modify, and distribute this software and
[69] Fix | Delete
# its associated documentation for any purpose and without fee is
[70] Fix | Delete
# hereby granted, provided that the above copyright notice appears in
[71] Fix | Delete
# all copies, and that both that copyright notice and this permission
[72] Fix | Delete
# notice appear in supporting documentation, and that the name of
[73] Fix | Delete
# Secret Labs AB or the author not be used in advertising or publicity
[74] Fix | Delete
# pertaining to distribution of the software without specific, written
[75] Fix | Delete
# prior permission.
[76] Fix | Delete
#
[77] Fix | Delete
# SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
[78] Fix | Delete
# TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT-
[79] Fix | Delete
# ABILITY AND FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR
[80] Fix | Delete
# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
[81] Fix | Delete
# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
[82] Fix | Delete
# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
[83] Fix | Delete
# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
[84] Fix | Delete
# OF THIS SOFTWARE.
[85] Fix | Delete
# --------------------------------------------------------------------
[86] Fix | Delete
[87] Fix | Delete
#
[88] Fix | Delete
# things to look into some day:
[89] Fix | Delete
[90] Fix | Delete
# TODO: sort out True/False/boolean issues for Python 2.3
[91] Fix | Delete
[92] Fix | Delete
"""
[93] Fix | Delete
An XML-RPC client interface for Python.
[94] Fix | Delete
[95] Fix | Delete
The marshalling and response parser code can also be used to
[96] Fix | Delete
implement XML-RPC servers.
[97] Fix | Delete
[98] Fix | Delete
Exported exceptions:
[99] Fix | Delete
[100] Fix | Delete
Error Base class for client errors
[101] Fix | Delete
ProtocolError Indicates an HTTP protocol error
[102] Fix | Delete
ResponseError Indicates a broken response package
[103] Fix | Delete
Fault Indicates an XML-RPC fault package
[104] Fix | Delete
[105] Fix | Delete
Exported classes:
[106] Fix | Delete
[107] Fix | Delete
ServerProxy Represents a logical connection to an XML-RPC server
[108] Fix | Delete
[109] Fix | Delete
MultiCall Executor of boxcared xmlrpc requests
[110] Fix | Delete
Boolean boolean wrapper to generate a "boolean" XML-RPC value
[111] Fix | Delete
DateTime dateTime wrapper for an ISO 8601 string or time tuple or
[112] Fix | Delete
localtime integer value to generate a "dateTime.iso8601"
[113] Fix | Delete
XML-RPC value
[114] Fix | Delete
Binary binary data wrapper
[115] Fix | Delete
[116] Fix | Delete
SlowParser Slow but safe standard parser (based on xmllib)
[117] Fix | Delete
Marshaller Generate an XML-RPC params chunk from a Python data structure
[118] Fix | Delete
Unmarshaller Unmarshal an XML-RPC response from incoming XML event message
[119] Fix | Delete
Transport Handles an HTTP transaction to an XML-RPC server
[120] Fix | Delete
SafeTransport Handles an HTTPS transaction to an XML-RPC server
[121] Fix | Delete
[122] Fix | Delete
Exported constants:
[123] Fix | Delete
[124] Fix | Delete
True
[125] Fix | Delete
False
[126] Fix | Delete
[127] Fix | Delete
Exported functions:
[128] Fix | Delete
[129] Fix | Delete
boolean Convert any Python value to an XML-RPC boolean
[130] Fix | Delete
getparser Create instance of the fastest available parser & attach
[131] Fix | Delete
to an unmarshalling object
[132] Fix | Delete
dumps Convert an argument tuple or a Fault instance to an XML-RPC
[133] Fix | Delete
request (or response, if the methodresponse option is used).
[134] Fix | Delete
loads Convert an XML-RPC packet to unmarshalled data plus a method
[135] Fix | Delete
name (None if not present).
[136] Fix | Delete
"""
[137] Fix | Delete
[138] Fix | Delete
import re, string, time, operator
[139] Fix | Delete
[140] Fix | Delete
from types import *
[141] Fix | Delete
import socket
[142] Fix | Delete
import errno
[143] Fix | Delete
import httplib
[144] Fix | Delete
try:
[145] Fix | Delete
import gzip
[146] Fix | Delete
except ImportError:
[147] Fix | Delete
gzip = None #python can be built without zlib/gzip support
[148] Fix | Delete
[149] Fix | Delete
# --------------------------------------------------------------------
[150] Fix | Delete
# Internal stuff
[151] Fix | Delete
[152] Fix | Delete
try:
[153] Fix | Delete
unicode
[154] Fix | Delete
except NameError:
[155] Fix | Delete
unicode = None # unicode support not available
[156] Fix | Delete
[157] Fix | Delete
try:
[158] Fix | Delete
import datetime
[159] Fix | Delete
except ImportError:
[160] Fix | Delete
datetime = None
[161] Fix | Delete
[162] Fix | Delete
try:
[163] Fix | Delete
_bool_is_builtin = False.__class__.__name__ == "bool"
[164] Fix | Delete
except NameError:
[165] Fix | Delete
_bool_is_builtin = 0
[166] Fix | Delete
[167] Fix | Delete
def _decode(data, encoding, is8bit=re.compile("[\x80-\xff]").search):
[168] Fix | Delete
# decode non-ascii string (if possible)
[169] Fix | Delete
if unicode and encoding and is8bit(data):
[170] Fix | Delete
data = unicode(data, encoding)
[171] Fix | Delete
return data
[172] Fix | Delete
[173] Fix | Delete
def escape(s, replace=string.replace):
[174] Fix | Delete
s = replace(s, "&", "&")
[175] Fix | Delete
s = replace(s, "<", "&lt;")
[176] Fix | Delete
return replace(s, ">", "&gt;",)
[177] Fix | Delete
[178] Fix | Delete
if unicode:
[179] Fix | Delete
def _stringify(string):
[180] Fix | Delete
# convert to 7-bit ascii if possible
[181] Fix | Delete
try:
[182] Fix | Delete
return string.encode("ascii")
[183] Fix | Delete
except UnicodeError:
[184] Fix | Delete
return string
[185] Fix | Delete
else:
[186] Fix | Delete
def _stringify(string):
[187] Fix | Delete
return string
[188] Fix | Delete
[189] Fix | Delete
__version__ = "1.0.1"
[190] Fix | Delete
[191] Fix | Delete
# xmlrpc integer limits
[192] Fix | Delete
MAXINT = 2L**31-1
[193] Fix | Delete
MININT = -2L**31
[194] Fix | Delete
[195] Fix | Delete
# --------------------------------------------------------------------
[196] Fix | Delete
# Error constants (from Dan Libby's specification at
[197] Fix | Delete
# http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php)
[198] Fix | Delete
[199] Fix | Delete
# Ranges of errors
[200] Fix | Delete
PARSE_ERROR = -32700
[201] Fix | Delete
SERVER_ERROR = -32600
[202] Fix | Delete
APPLICATION_ERROR = -32500
[203] Fix | Delete
SYSTEM_ERROR = -32400
[204] Fix | Delete
TRANSPORT_ERROR = -32300
[205] Fix | Delete
[206] Fix | Delete
# Specific errors
[207] Fix | Delete
NOT_WELLFORMED_ERROR = -32700
[208] Fix | Delete
UNSUPPORTED_ENCODING = -32701
[209] Fix | Delete
INVALID_ENCODING_CHAR = -32702
[210] Fix | Delete
INVALID_XMLRPC = -32600
[211] Fix | Delete
METHOD_NOT_FOUND = -32601
[212] Fix | Delete
INVALID_METHOD_PARAMS = -32602
[213] Fix | Delete
INTERNAL_ERROR = -32603
[214] Fix | Delete
[215] Fix | Delete
# --------------------------------------------------------------------
[216] Fix | Delete
# Exceptions
[217] Fix | Delete
[218] Fix | Delete
##
[219] Fix | Delete
# Base class for all kinds of client-side errors.
[220] Fix | Delete
[221] Fix | Delete
class Error(Exception):
[222] Fix | Delete
"""Base class for client errors."""
[223] Fix | Delete
def __str__(self):
[224] Fix | Delete
return repr(self)
[225] Fix | Delete
[226] Fix | Delete
##
[227] Fix | Delete
# Indicates an HTTP-level protocol error. This is raised by the HTTP
[228] Fix | Delete
# transport layer, if the server returns an error code other than 200
[229] Fix | Delete
# (OK).
[230] Fix | Delete
#
[231] Fix | Delete
# @param url The target URL.
[232] Fix | Delete
# @param errcode The HTTP error code.
[233] Fix | Delete
# @param errmsg The HTTP error message.
[234] Fix | Delete
# @param headers The HTTP header dictionary.
[235] Fix | Delete
[236] Fix | Delete
class ProtocolError(Error):
[237] Fix | Delete
"""Indicates an HTTP protocol error."""
[238] Fix | Delete
def __init__(self, url, errcode, errmsg, headers):
[239] Fix | Delete
Error.__init__(self)
[240] Fix | Delete
self.url = url
[241] Fix | Delete
self.errcode = errcode
[242] Fix | Delete
self.errmsg = errmsg
[243] Fix | Delete
self.headers = headers
[244] Fix | Delete
def __repr__(self):
[245] Fix | Delete
return (
[246] Fix | Delete
"<ProtocolError for %s: %s %s>" %
[247] Fix | Delete
(self.url, self.errcode, self.errmsg)
[248] Fix | Delete
)
[249] Fix | Delete
[250] Fix | Delete
##
[251] Fix | Delete
# Indicates a broken XML-RPC response package. This exception is
[252] Fix | Delete
# raised by the unmarshalling layer, if the XML-RPC response is
[253] Fix | Delete
# malformed.
[254] Fix | Delete
[255] Fix | Delete
class ResponseError(Error):
[256] Fix | Delete
"""Indicates a broken response package."""
[257] Fix | Delete
pass
[258] Fix | Delete
[259] Fix | Delete
##
[260] Fix | Delete
# Indicates an XML-RPC fault response package. This exception is
[261] Fix | Delete
# raised by the unmarshalling layer, if the XML-RPC response contains
[262] Fix | Delete
# a fault string. This exception can also used as a class, to
[263] Fix | Delete
# generate a fault XML-RPC message.
[264] Fix | Delete
#
[265] Fix | Delete
# @param faultCode The XML-RPC fault code.
[266] Fix | Delete
# @param faultString The XML-RPC fault string.
[267] Fix | Delete
[268] Fix | Delete
class Fault(Error):
[269] Fix | Delete
"""Indicates an XML-RPC fault package."""
[270] Fix | Delete
def __init__(self, faultCode, faultString, **extra):
[271] Fix | Delete
Error.__init__(self)
[272] Fix | Delete
self.faultCode = faultCode
[273] Fix | Delete
self.faultString = faultString
[274] Fix | Delete
def __repr__(self):
[275] Fix | Delete
return (
[276] Fix | Delete
"<Fault %s: %s>" %
[277] Fix | Delete
(self.faultCode, repr(self.faultString))
[278] Fix | Delete
)
[279] Fix | Delete
[280] Fix | Delete
# --------------------------------------------------------------------
[281] Fix | Delete
# Special values
[282] Fix | Delete
[283] Fix | Delete
##
[284] Fix | Delete
# Wrapper for XML-RPC boolean values. Use the xmlrpclib.True and
[285] Fix | Delete
# xmlrpclib.False constants, or the xmlrpclib.boolean() function, to
[286] Fix | Delete
# generate boolean XML-RPC values.
[287] Fix | Delete
#
[288] Fix | Delete
# @param value A boolean value. Any true value is interpreted as True,
[289] Fix | Delete
# all other values are interpreted as False.
[290] Fix | Delete
[291] Fix | Delete
from sys import modules
[292] Fix | Delete
mod_dict = modules[__name__].__dict__
[293] Fix | Delete
if _bool_is_builtin:
[294] Fix | Delete
boolean = Boolean = bool
[295] Fix | Delete
# to avoid breaking code which references xmlrpclib.{True,False}
[296] Fix | Delete
mod_dict['True'] = True
[297] Fix | Delete
mod_dict['False'] = False
[298] Fix | Delete
else:
[299] Fix | Delete
class Boolean:
[300] Fix | Delete
"""Boolean-value wrapper.
[301] Fix | Delete
[302] Fix | Delete
Use True or False to generate a "boolean" XML-RPC value.
[303] Fix | Delete
"""
[304] Fix | Delete
[305] Fix | Delete
def __init__(self, value = 0):
[306] Fix | Delete
self.value = operator.truth(value)
[307] Fix | Delete
[308] Fix | Delete
def encode(self, out):
[309] Fix | Delete
out.write("<value><boolean>%d</boolean></value>\n" % self.value)
[310] Fix | Delete
[311] Fix | Delete
def __cmp__(self, other):
[312] Fix | Delete
if isinstance(other, Boolean):
[313] Fix | Delete
other = other.value
[314] Fix | Delete
return cmp(self.value, other)
[315] Fix | Delete
[316] Fix | Delete
def __repr__(self):
[317] Fix | Delete
if self.value:
[318] Fix | Delete
return "<Boolean True at %x>" % id(self)
[319] Fix | Delete
else:
[320] Fix | Delete
return "<Boolean False at %x>" % id(self)
[321] Fix | Delete
[322] Fix | Delete
def __int__(self):
[323] Fix | Delete
return self.value
[324] Fix | Delete
[325] Fix | Delete
def __nonzero__(self):
[326] Fix | Delete
return self.value
[327] Fix | Delete
[328] Fix | Delete
mod_dict['True'] = Boolean(1)
[329] Fix | Delete
mod_dict['False'] = Boolean(0)
[330] Fix | Delete
[331] Fix | Delete
##
[332] Fix | Delete
# Map true or false value to XML-RPC boolean values.
[333] Fix | Delete
#
[334] Fix | Delete
# @def boolean(value)
[335] Fix | Delete
# @param value A boolean value. Any true value is mapped to True,
[336] Fix | Delete
# all other values are mapped to False.
[337] Fix | Delete
# @return xmlrpclib.True or xmlrpclib.False.
[338] Fix | Delete
# @see Boolean
[339] Fix | Delete
# @see True
[340] Fix | Delete
# @see False
[341] Fix | Delete
[342] Fix | Delete
def boolean(value, _truefalse=(False, True)):
[343] Fix | Delete
"""Convert any Python value to XML-RPC 'boolean'."""
[344] Fix | Delete
return _truefalse[operator.truth(value)]
[345] Fix | Delete
[346] Fix | Delete
del modules, mod_dict
[347] Fix | Delete
[348] Fix | Delete
##
[349] Fix | Delete
# Wrapper for XML-RPC DateTime values. This converts a time value to
[350] Fix | Delete
# the format used by XML-RPC.
[351] Fix | Delete
# <p>
[352] Fix | Delete
# The value can be given as a string in the format
[353] Fix | Delete
# "yyyymmddThh:mm:ss", as a 9-item time tuple (as returned by
[354] Fix | Delete
# time.localtime()), or an integer value (as returned by time.time()).
[355] Fix | Delete
# The wrapper uses time.localtime() to convert an integer to a time
[356] Fix | Delete
# tuple.
[357] Fix | Delete
#
[358] Fix | Delete
# @param value The time, given as an ISO 8601 string, a time
[359] Fix | Delete
# tuple, or an integer time value.
[360] Fix | Delete
[361] Fix | Delete
def _strftime(value):
[362] Fix | Delete
if datetime:
[363] Fix | Delete
if isinstance(value, datetime.datetime):
[364] Fix | Delete
return "%04d%02d%02dT%02d:%02d:%02d" % (
[365] Fix | Delete
value.year, value.month, value.day,
[366] Fix | Delete
value.hour, value.minute, value.second)
[367] Fix | Delete
[368] Fix | Delete
if not isinstance(value, (TupleType, time.struct_time)):
[369] Fix | Delete
if value == 0:
[370] Fix | Delete
value = time.time()
[371] Fix | Delete
value = time.localtime(value)
[372] Fix | Delete
[373] Fix | Delete
return "%04d%02d%02dT%02d:%02d:%02d" % value[:6]
[374] Fix | Delete
[375] Fix | Delete
class DateTime:
[376] Fix | Delete
"""DateTime wrapper for an ISO 8601 string or time tuple or
[377] Fix | Delete
localtime integer value to generate 'dateTime.iso8601' XML-RPC
[378] Fix | Delete
value.
[379] Fix | Delete
"""
[380] Fix | Delete
[381] Fix | Delete
def __init__(self, value=0):
[382] Fix | Delete
if isinstance(value, StringType):
[383] Fix | Delete
self.value = value
[384] Fix | Delete
else:
[385] Fix | Delete
self.value = _strftime(value)
[386] Fix | Delete
[387] Fix | Delete
def make_comparable(self, other):
[388] Fix | Delete
if isinstance(other, DateTime):
[389] Fix | Delete
s = self.value
[390] Fix | Delete
o = other.value
[391] Fix | Delete
elif datetime and isinstance(other, datetime.datetime):
[392] Fix | Delete
s = self.value
[393] Fix | Delete
o = other.strftime("%Y%m%dT%H:%M:%S")
[394] Fix | Delete
elif isinstance(other, basestring):
[395] Fix | Delete
s = self.value
[396] Fix | Delete
o = other
[397] Fix | Delete
elif hasattr(other, "timetuple"):
[398] Fix | Delete
s = self.timetuple()
[399] Fix | Delete
o = other.timetuple()
[400] Fix | Delete
else:
[401] Fix | Delete
otype = (hasattr(other, "__class__")
[402] Fix | Delete
and other.__class__.__name__
[403] Fix | Delete
or type(other))
[404] Fix | Delete
raise TypeError("Can't compare %s and %s" %
[405] Fix | Delete
(self.__class__.__name__, otype))
[406] Fix | Delete
return s, o
[407] Fix | Delete
[408] Fix | Delete
def __lt__(self, other):
[409] Fix | Delete
s, o = self.make_comparable(other)
[410] Fix | Delete
return s < o
[411] Fix | Delete
[412] Fix | Delete
def __le__(self, other):
[413] Fix | Delete
s, o = self.make_comparable(other)
[414] Fix | Delete
return s <= o
[415] Fix | Delete
[416] Fix | Delete
def __gt__(self, other):
[417] Fix | Delete
s, o = self.make_comparable(other)
[418] Fix | Delete
return s > o
[419] Fix | Delete
[420] Fix | Delete
def __ge__(self, other):
[421] Fix | Delete
s, o = self.make_comparable(other)
[422] Fix | Delete
return s >= o
[423] Fix | Delete
[424] Fix | Delete
def __eq__(self, other):
[425] Fix | Delete
s, o = self.make_comparable(other)
[426] Fix | Delete
return s == o
[427] Fix | Delete
[428] Fix | Delete
def __ne__(self, other):
[429] Fix | Delete
s, o = self.make_comparable(other)
[430] Fix | Delete
return s != o
[431] Fix | Delete
[432] Fix | Delete
def timetuple(self):
[433] Fix | Delete
return time.strptime(self.value, "%Y%m%dT%H:%M:%S")
[434] Fix | Delete
[435] Fix | Delete
def __cmp__(self, other):
[436] Fix | Delete
s, o = self.make_comparable(other)
[437] Fix | Delete
return cmp(s, o)
[438] Fix | Delete
[439] Fix | Delete
##
[440] Fix | Delete
# Get date/time value.
[441] Fix | Delete
#
[442] Fix | Delete
# @return Date/time value, as an ISO 8601 string.
[443] Fix | Delete
[444] Fix | Delete
def __str__(self):
[445] Fix | Delete
return self.value
[446] Fix | Delete
[447] Fix | Delete
def __repr__(self):
[448] Fix | Delete
return "<DateTime %s at %x>" % (repr(self.value), id(self))
[449] Fix | Delete
[450] Fix | Delete
def decode(self, data):
[451] Fix | Delete
data = str(data)
[452] Fix | Delete
self.value = string.strip(data)
[453] Fix | Delete
[454] Fix | Delete
def encode(self, out):
[455] Fix | Delete
out.write("<value><dateTime.iso8601>")
[456] Fix | Delete
out.write(self.value)
[457] Fix | Delete
out.write("</dateTime.iso8601></value>\n")
[458] Fix | Delete
[459] Fix | Delete
def _datetime(data):
[460] Fix | Delete
# decode xml element contents into a DateTime structure.
[461] Fix | Delete
value = DateTime()
[462] Fix | Delete
value.decode(data)
[463] Fix | Delete
return value
[464] Fix | Delete
[465] Fix | Delete
def _datetime_type(data):
[466] Fix | Delete
t = time.strptime(data, "%Y%m%dT%H:%M:%S")
[467] Fix | Delete
return datetime.datetime(*tuple(t)[:6])
[468] Fix | Delete
[469] Fix | Delete
##
[470] Fix | Delete
# Wrapper for binary data. This can be used to transport any kind
[471] Fix | Delete
# of binary data over XML-RPC, using BASE64 encoding.
[472] Fix | Delete
#
[473] Fix | Delete
# @param data An 8-bit string containing arbitrary data.
[474] Fix | Delete
[475] Fix | Delete
import base64
[476] Fix | Delete
try:
[477] Fix | Delete
import cStringIO as StringIO
[478] Fix | Delete
except ImportError:
[479] Fix | Delete
import StringIO
[480] Fix | Delete
[481] Fix | Delete
class Binary:
[482] Fix | Delete
"""Wrapper for binary data."""
[483] Fix | Delete
[484] Fix | Delete
def __init__(self, data=None):
[485] Fix | Delete
self.data = data
[486] Fix | Delete
[487] Fix | Delete
##
[488] Fix | Delete
# Get buffer contents.
[489] Fix | Delete
#
[490] Fix | Delete
# @return Buffer contents, as an 8-bit string.
[491] Fix | Delete
[492] Fix | Delete
def __str__(self):
[493] Fix | Delete
return self.data or ""
[494] Fix | Delete
[495] Fix | Delete
def __cmp__(self, other):
[496] Fix | Delete
if isinstance(other, Binary):
[497] Fix | Delete
other = other.data
[498] Fix | Delete
return cmp(self.data, other)
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function