a 97a @sdZddlmZmZmZmZddlmZmZm Z m Z m Z ddl Z e j e _e je _ddlZddlZddlmZddlmZddlmZddlmZdd lmZddlZddlZdd l m!Z!z ddl"Z"Wne#ydZ"Yn0d d Z$ej%dd Z&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1dZ2dZ3dZ4Gddde5Z6Gddde6Z7Gddde6Z8Gd d!d!e6Z9e:Z;ZGd&d'd'e?Z@d(d)ZAd*d+ZBGd,d-d-e?ZCd.d/ZDe@eCfZEGd0d1d1e?ZFGd2d3d3e?ZGGd4d5d5e?ZHGd6d7d7e?ZIGd8d9d9e?ZJGd:d;d;e?ZKdZLZMZNdWd=d>ZOdXd?d@ZPdYdAdBZQdCdDZRdEdFZSGdGdHdHe"rre"jTne?ZUGdIdJdJe?ZVGdKdLdLe?ZWGdMdNdNeWZXGdOdPdPe?ZYeYZZe[dQkreYdRZ\ze]e\j^_Wn0e6yZ`ze]dSe`WYdZ`[`n dZ`[`00eKe\ZaeabeacdTdUeaddVdTzeaD]Zee]eeqBWn0e6yZ`ze]dSe`WYdZ`[`n dZ`[`00dS)Za Ported using Python-Future from the Python 3.3 standard library. An XML-RPC client interface for Python. The marshalling and response parser code can also be used to implement XML-RPC servers. Exported exceptions: Error Base class for client errors ProtocolError Indicates an HTTP protocol error ResponseError Indicates a broken response package Fault Indicates an XML-RPC fault package Exported classes: ServerProxy Represents a logical connection to an XML-RPC server MultiCall Executor of boxcared xmlrpc requests DateTime dateTime wrapper for an ISO 8601 string or time tuple or localtime integer value to generate a "dateTime.iso8601" XML-RPC value Binary binary data wrapper Marshaller Generate an XML-RPC params chunk from a Python data structure Unmarshaller Unmarshal an XML-RPC response from incoming XML event message Transport Handles an HTTP transaction to an XML-RPC server SafeTransport Handles an HTTPS transaction to an XML-RPC server Exported constants: (none) Exported functions: getparser Create instance of the fastest available parser & attach to an unmarshalling object dumps Convert an argument tuple or a Fault instance to an XML-RPC request (or response, if the methodresponse option is used). loads Convert an XML-RPC packet to unmarshalled data plus a method name (None if not present). )absolute_importdivisionprint_functionunicode_literals)bytesdictintrangestrN)datetime)client)parse)ensure_new_type)expat)BytesIOcCs$|dd}|dd}|ddS)N&z&z>)replace)sry/private/var/folders/s6/9n5zrl012gv99k63s4q6ccsd4s6mqz/T/pip-target-f5cq3f2q/lib/python/future/backports/xmlrpc/client.pyescapes  riiiDii ipiԁiCiBiiic@seZdZdZddZdS)ErrorzBase class for client errors.cCst|SN)reprselfrrr__str__sz Error.__str__N)__name__ __module__ __qualname____doc__rrrrrrsrc@s eZdZdZddZddZdS) ProtocolErrorz!Indicates an HTTP protocol error.cCs&t|||_||_||_||_dSr)r__init__urlerrcodeerrmsgheaders)rr&r'r(r)rrrr%s  zProtocolError.__init__cCsd|j|j|jfS)Nz)r&r'r(rrrr__repr__szProtocolError.__repr__Nr r!r"r#r%r*rrrrr$sr$c@seZdZdZdS) ResponseErrorz$Indicates a broken response package.N)r r!r"r#rrrrr,sr,c@s eZdZdZddZddZdS)Faultz#Indicates an XML-RPC fault package.cKst|||_||_dSr)rr% faultCode faultString)rr.r/extrarrrr%s zFault.__init__cCsdt|jt|jfS)Nz)rr.r/rrrrr*s zFault.__repr__Nr+rrrrr-sr-cCs d|j|j|j|j|j|jfS)N%04d%02d%02dT%02d:%02d:%02d)yearmonthdayhourminutesecondvaluerrr_iso8601_formats  r:cCsLt|trt|St|ttjfs<|dkr2t}t|}d|ddS)Nrr1) isinstancer r:tupletime struct_time localtimer8rrr _strftime's  rAc@szeZdZdZdddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZdS)DateTimezDateTime wrapper for an ISO 8601 string or time tuple or localtime integer value to generate 'dateTime.iso8601' XML-RPC value. rcCs t|tr||_n t||_dSr)r<r r9rA)rr9rrrr%8s zDateTime.__init__cCst|tr|j}|j}nzt|tr2|j}t|}n`t|trH|j}|}nJt|drd|}|}n.t|drv|jj p|t |}t d|jj |f||fS)N timetuple __class__zCan't compare %s and %s) r<rBr9r r:r hasattrrCrDr type TypeError)rotherroZotyperrrmake_comparable>s*        zDateTime.make_comparablecCs||\}}||kSrrJrrHrrIrrr__lt__SszDateTime.__lt__cCs||\}}||kSrrKrLrrr__le__WszDateTime.__le__cCs||\}}||kSrrKrLrrr__gt__[szDateTime.__gt__cCs||\}}||kSrrKrLrrr__ge___szDateTime.__ge__cCs||\}}||kSrrKrLrrr__eq__cszDateTime.__eq__cCs||\}}||kSrrKrLrrr__ne__gszDateTime.__ne__cCst|jdSNz%Y%m%dT%H:%M:%S)r>strptimer9rrrrrCkszDateTime.timetuplecCs|jSrr8rrrrrsszDateTime.__str__cCsdt|jt|fS)Nz)rr9idrrrrr*vszDateTime.__repr__cCst||_dSr)r stripr9rdatarrrdecodeyszDateTime.decodecCs$|d||j|ddSNzz )writer9)routrrrencode|s  zDateTime.encodeN)r)r r!r"r#r%rJrMrNrOrPrQrRrCrr*rYr]rrrrrB2s rBcCst}|||Sr)rBrYrXr9rrr _datetimes r_cCs t|dSrS)r rT)rXrrr_datetime_typesr`c@sBeZdZdZdddZddZddZd d Zd d Zd dZ dS)BinaryzWrapper for binary data.NcCs>|durd}n&t|ttfs,td|jjt|}||_dS)Nz#expected bytes or bytearray, not %s)r<r bytearrayrGrDr rXrWrrrr%szBinary.__init__cCs t|jdS)Nzlatin-1)r rXrrrrrszBinary.__str__cCst|tr|j}|j|kSrr<rarXrrHrrrrQs z Binary.__eq__cCst|tr|j}|j|kSrrdrerrrrRs z Binary.__ne__cCst||_dSr)base64 decodebytesrXrWrrrrYsz Binary.decodecCs4|dt|j}||d|ddSNz asciiz )r[rf encodebytesrXrY)rr\encodedrrrr]s  z Binary.encode)N) r r!r"r#r%rrQrRrYr]rrrrras racCst}|||Sr)rarYr^rrr_binarys rlc@s$eZdZddZddZddZdS) ExpatParsercCsDtdd|_}||_|j|_|j|_|j|_ d}| |ddSr) r ParserCreate_parser_targetstartStartElementHandlerendEndElementHandlerrXCharacterDataHandlerxml)rtargetparserencodingrrrr%szExpatParser.__init__cCs|j|ddSNr)roParserWrrrfeedszExpatParser.feedcCs|jdd|`|`dS)N)ror{rprrrrcloseszExpatParser.closeN)r r!r"r%r|rrrrrrms rmc@seZdZdZdddZiZddZdd Zd d Zeee d<d d Z e ee <ddZ e ee <e ZddZeee<efddZeee<ddZeee<eee<ddZeee<eee<efddZeee<ddZeee<ddZeee<eee <eed<dS) MarshalleravGenerate an XML-RPC params chunk from a Python data structure. Create a Marshaller instance for each set of parameters, and use the "dumps" method to convert your data (represented as a tuple) to an XML-RPC params chunk. To write a fault response, pass a Fault instance instead. You may prefer to use the "dumps" module function for this purpose. NFcCsi|_d|_||_||_dSr)memorXry allow_none)rryrrrrr%szMarshaller.__init__cCsg}|j}|j}t|tr@|d||j|jd||dn4|d|D]}|d||||dqL|dd|}t|S) Nz )r.r/z z z z z r})append_Marshaller__dumpr<r-r.r/joinr )rvaluesr\r[dumpvresultrrrdumpss&     zMarshaller.dumpscCsz|jtt|}Wndtyzt|ds>tdt|t|jD]"}||jvrHtdt|qH|jd}Yn0||||dS)N__dict__zcannot marshal %s objects_arbitrary_instance)dispatchrFrKeyErrorrErG__mro__keys)rr9r[ftype_rrr__dumps  zMarshaller.__dumpcCs|jstd|ddS)Nz0cannot marshal None unless allow_none is enabledz)rrGrr9r[rrrdump_nil!szMarshaller.dump_nilcCs$|d||rdpd|ddS)Nz10z rrrrr dump_bool'szMarshaller.dump_boolcCs<|tks|tkrtd|d|tt||ddS)Nzlong int exceeds XML-RPC limitsz z )MAXINTMININT OverflowErrorr rrrrr dump_long-s zMarshaller.dump_longcCs$|d|tt||ddS)Nzz )rrrrrr dump_double8szMarshaller.dump_doublecCs |d||||ddS)Nzz r)rr9r[rrrr dump_unicode>s zMarshaller.dump_unicodecCs,|dt|}||d|ddSrh)rfrjrY)rr9r[rkrrr dump_bytesDs zMarshaller.dump_bytescCsZt|}||jvrtdd|j|<|j}|d|D]}|||q6|d|j|=dS)Nz"cannot marshal recursive sequencesz z )rUrrGr)rr9r[irrrrr dump_arrayLs   zMarshaller.dump_arraycCst|}||jvrtdd|j|<|j}|d|D]D\}}|dt|ts\td|d||||||dq:|d|j|=dS)Nz%cannot marshal recursive dictionariesz z zdictionary key must be stringz%s z z )rUrrGritemsr<r )rr9r[rrrkrrrr dump_structZs     zMarshaller.dump_structcCs |d|t||ddSrZ)rArrrr dump_datetimels zMarshaller.dump_datetimecCs2|jtvr ||_|||`n||j|dSr)rDWRAPPERSr[r]rrrrrr dump_instancers   zMarshaller.dump_instancer)NF)!r r!r"r#r%rrrrrFrboolrrdump_intrfloatrrr rrrcrr=listrrrr rrBrarrrrrs<      rc@s>eZdZdZd>ddZddZddZd d Zd d Zd dZ ddZ ddZ iZ ddZ e e d<ddZee d<ddZee d<ee d<ee d<ddZee d <d!d"Zee d#<ee d$<d%d&Zee d'<d(d)Zee d*<d+d,Zee d-<d.d/Zee d0<d1d2Zee d3<d4d5Zee d6<d7d8Zee d9<d:d;Zee d<<d=S)? UnmarshalleraUnmarshal an XML-RPC response, based on incoming XML event messages (start, data, end). Call close() to get the resulting data structure. Note that this reader is fairly tolerant, and gladly accepts bogus XML-RPC data without complaining (but not bogus XML). FcCsBd|_g|_g|_g|_d|_d|_|jj|_|p4||_||_dS)Nutf-8) _type_stack_marks_data _methodname _encodingr _use_datetime _use_bytesr use_datetimeuse_builtin_typesrrrr%s  zUnmarshaller.__init__cCs>|jdus|jrt|jdkr4tfi|jdt|jS)Nfaultr)rrr,r-rr=rrrrrs  zUnmarshaller.closecCs|jSr)rrrrr getmethodnameszUnmarshaller.getmethodnamecCs ||_dSr)r)rry standalonerrrrvszUnmarshaller.xmlcCs6|dks|dkr"|jt|jg|_|dk|_dS)Narraystructr9)rrlenrr_value)rtagattrsrrrrqszUnmarshaller.startcCs|j|dSr)rr)rtextrrrrXszUnmarshaller.datacCs8z|j|}Wnty Yn0||d|jSdS)Nr})rrrr)rrrrrrrss  zUnmarshaller.endcCs0z|j|}Wnty Yn 0|||SdSr)rr)rrrXrrrr end_dispatchs  zUnmarshaller.end_dispatchcCs|dd|_dSrz)rrrWrrrend_nils zUnmarshaller.end_nilnilcCs:|dkr|dn|dkr(|dntdd|_dS)NrFrTzbad boolean valuer)rrGrrWrrr end_booleans   zUnmarshaller.end_booleanbooleancCs|t|d|_dSrz)rrrrWrrrend_intszUnmarshaller.end_inti4i8rcCs|t|d|_dSrz)rrrrWrrr end_doubleszUnmarshaller.end_doubledoublecCs&|jr||j}||d|_dSrz)rrYrrrWrrr end_strings  zUnmarshaller.end_stringstringnamecCs.|j}|j|dg|j|d<d|_dSrz)rpoprr)rrXmarkrrr end_arrays zUnmarshaller.end_arrayrcCs`|j}i}|j|d}tdt|dD]}||d|||<q,|g|j|d<d|_dS)Nrr~)rrrr rr)rrXrrrrrrr end_structs zUnmarshaller.end_structrcCs6t}||d|jr"|j}||d|_dS)Nrir)rarYr]rrXrrrrXr9rrr end_base64s  zUnmarshaller.end_base64rfcCs,t}|||jrt|}||dSr)rBrYrr`rrrrr end_dateTimes  zUnmarshaller.end_dateTimezdateTime.iso8601cCs|jr||dSr)rrrWrrr end_valueszUnmarshaller.end_valuer9cCs d|_dS)NparamsrrWrrr end_params szUnmarshaller.end_paramsrcCs d|_dS)NrrrWrrr end_fault$szUnmarshaller.end_faultrcCs"|jr||j}||_d|_dS)N methodName)rrYrrrWrrrend_methodName(s zUnmarshaller.end_methodNamerN)FF)r r!r"r#r%rrrvrqrXrsrrrrrrrrrrrrrrrrrrrrsN    rc@s$eZdZddZddZddZdS)_MultiCallMethodcCs||_||_dSr)_MultiCallMethod__call_list_MultiCallMethod__name)r call_listrrrrr%5sz_MultiCallMethod.__init__cCst|jd|j|fSNz%s.%s)rrrrrrrr __getattr__8sz_MultiCallMethod.__getattr__cGs|j|j|fdSr)rrrrargsrrr__call__:sz_MultiCallMethod.__call__Nr r!r"r%rrrrrrr2src@s eZdZdZddZddZdS)MultiCallIteratorzaIterates over the results of a multicall. Exceptions are raised in response to xmlrpc faults.cCs ||_dSr)results)rrrrrr%AszMultiCallIterator.__init__cCsP|j|}tt|tr,t|d|dn t|tgkrD|dStddS)Nr.r/rz#unexpected type in multicall result)rr<rFrr- ValueError)rritemrrr __getitem__Ds  zMultiCallIterator.__getitem__N)r r!r"r#r%rrrrrr=src@s4eZdZdZddZddZeZddZdd Zd S) MultiCalla}server -> a object used to boxcar method calls server should be a ServerProxy object. Methods can be added to the MultiCall using normal method call syntax e.g.: multicall = MultiCall(server_proxy) multicall.add(2,3) multicall.get_address("Guido") To execute the multicall, call the MultiCall object e.g.: add_result, address = multicall() cCs||_g|_dSr)_MultiCall__server_MultiCall__call_list)rserverrrrr%^szMultiCall.__init__cCs dt|S)Nz)rUrrrrr*bszMultiCall.__repr__cCs t|j|Sr)rrrrrrrgszMultiCall.__getattr__cCs6g}|jD]\}}|||dq t|jj|S)N)rr)rrrrsystem multicall)rmarshalled_listrrrrrrjszMultiCall.__call__N) r r!r"r#r%r*rrrrrrrrMs rFcCsrtrHtrH|rt}tj}n|r&t}t}nt}t}tdd||t}t|}n"t||d}trbt|}nt |}||fS)zgetparser() -> parser, unmarshaller Create an instance of the fastest available parser, and attach it to an unmarshalling object. Return both objects. TFrr) FastParserFastUnmarshallerr`rfrgrlr_r-rrm)rr mkdatetimemkbytesrwrxrrr getparser|s    rcCst|ttfsJdt|tr&d}n"|rHt|trHt|dksHJd|sPd}tr^t|}n t||}||}|dkrdt|}nd}|rt|ts||}|d|d|d f}n|r|d |d f}n|Std  |S) adata [,options] -> marshalled data Convert an argument tuple or a Fault instance to an XML-RPC request (or response, if the methodresponse option is used). In addition to the data object, the following options can be given as keyword arguments: methodname: the method name for a methodCall packet methodresponse: true to create a methodResponse packet. If this option is used with a tuple, the tuple must be a singleton (i.e. it can contain only one element). encoding: the packet encoding (default is UTF-8) All byte strings in the data structure are assumed to use the packet encoding. Unicode strings are automatically converted, where necessary. z(argument must be tuple or Fault instancer~z"response tuple must be a singletonrz$ z z z z z z r}) r<r=r-rFastMarshallerrrr r]r)r methodnamemethodresponseryrmrX xmlheaderrrrrs>      rcCs2t||d\}}|||||fS)zdata -> unmarshalled data, method name Convert an XML-RPC packet to unmarshalled data plus a method name (None if not present). If the XML-RPC packet represents a fault condition, this function raises a Fault exception. r)rr|rr)rXrrpurrrloadss  rcCsDtstt}tjd|dd}||||}||S)zhdata -> gzip encoded data Encode data using the gzip content encoding as described in RFC 1952 wbr~)modefileobj compresslevel)gzipNotImplementedErrorrGzipFiler[rgetvalue)rXrgzfrkrrr gzip_encodes r cCsZtstt|}tjd|d}z |}WntyDtdYn0|||S)zrgzip encoded data -> unencoded data Decode data using the gzip content encoding as described in RFC 1952 rbrrz invalid data)rr rr readIOErrorrr)rXrr decodedrrr gzip_decodes  rc@s eZdZdZddZddZdS)GzipDecodedResponsezha file-like object to decode a response encoded with the gzip method, as described in RFC 1952. cCs.tstt||_tjj|d|jddS)Nrr)rr rrior r%)rresponserrrr%:szGzipDecodedResponse.__init__cCstj||jdSr)rr rrrrrrrBs zGzipDecodedResponse.closeN)r r!r"r#r%rrrrrr6src@s$eZdZddZddZddZdS)_MethodcCs||_||_dSr _Method__send _Method__name)rsendrrrrr%Msz_Method.__init__cCst|jd|j|fSr)rrrrrrrrPsz_Method.__getattr__cGs||j|SrrrrrrrRsz_Method.__call__NrrrrrrJsrc@s~eZdZdZdeZdZdZdddZddd Z dd d Z d d Z ddZ ddZ ddZddZddZddZddZdS) Transportz1Handles an HTTP transaction to an XML-RPC server.zPython-xmlrpc/%sTNFcCs||_||_d|_g|_dS)NNN)r_use_builtin_types _connection_extra_headersrrrrr%iszTransport.__init__c CsdD]v}z|||||WStjy`}z(|sJ|jtjtjtjfvrLWYd}~qd}~0tjyx|rtYq0qdS)N)rr~) single_requestsocketerrorerrno ECONNRESET ECONNABORTEDEPIPE http_client BadStatusLine)rhosthandler request_bodyverbosererrrrequestyszTransport.requestcCsz8|||||}|}|jdkr6||_||WSWn.tyLYntyf|Yn0|ddr|| t |||j|j t | dS)Nzcontent-lengthr}) send_request getresponsestatusr-parse_responser- Exceptionr getheaderrr$reasonr getheaders)rr*r+r,r- http_connresprrrr!s$     zTransport.single_requestcCst|j|jdS)Nr)rrrrrrrrszTransport.getparsercCsni}t|tr|\}}t|\}}|r`t|}t|d}d| }dd|fg}ng}|||fS)Nrr} AuthorizationzBasic ) r<r= urllib_parse splituserunquote_to_bytesrfrjrYrsplit)rr*x509auth extra_headersrrr get_host_infos   zTransport.get_host_infocCsJ|jr||jdkr|jdS||\}|_}|t|f|_|jdS)Nrr~)rrCr r(HTTPConnectionrr*chostr@rrrmake_connections  zTransport.make_connectioncCs"|jdr|jdd|_dS)Nr~r)rrrrrrrs zTransport.closecCs||}|jdd}|r&|d|jrLtrL|jd|dd|dn |d||d|d|jf|||| |||S)Nr~POSTT)skip_accept_encoding)zAccept-Encodingr)z Content-Typeztext/xmlz User-Agent) rGr set_debuglevelaccept_gzip_encodingr putrequestr user_agent send_headers send_content)rr*r+r,debug connectionr)rrrr1s        zTransport.send_requestcCs|D]\}}|||qdSr) putheader)rrQr)keyvalrrrrNs zTransport.send_headerscCsR|jdur0|jt|kr0tr0|ddt|}|dtt|||dS)NContent-EncodingrzContent-Length)encode_thresholdrrrRr r endheaders)rrQr,rrrrO s   zTransport.send_contentcCst|dr*|dddkr$t|}q.|}n|}|\}}|d}|sJqj|jr^tdt|||q:||urz| | | S)Nr6rUr}rizbody:) rEr6rrrr-printrr|r)rrstreamrrrXrrrr4s      zTransport.parse_response)FF)F)F)r r!r"r# __version__rMrKrVr%r/r!rrCrGrr1rNrOr4rrrrr[s  ! rc@seZdZdZddZdS) SafeTransportz2Handles an HTTPS transaction to an XML-RPC server.cCsj|jr||jdkr|jdSttds0td||\}|_}|tj|dfi|pVif|_|jdS)Nrr~HTTPSConnectionz1your version of http.client doesn't support HTTPS)rrEr(r rCr r\rErrrrGAs   zSafeTransport.make_connectionN)r r!r"r#rGrrrrr[<sr[c@sFeZdZdZdddZddZdd Zd d ZeZd d Z ddZ dS) ServerProxyauri [,options] -> a logical connection to an XML-RPC server uri is the connection point on the server, given as scheme://host/target. The standard implementation always supports the "http" scheme. If SSL socket support is available (Python 2.0), it also supports "https". If the target part and the slash preceding it are both omitted, "/RPC2" is assumed. The following options can be given as keyword arguments: transport: a transport factory encoding: the request encoding (default is UTF-8) All 8-bit strings passed to the server proxy are assumed to use the given encoding. NFc Cst|\}}|dvrtdt|\|_|_|js)rbrcrrrrr*s zServerProxy.__repr__cCs t|j|Sr)r_ServerProxy__requestrrrrrszServerProxy.__getattr__cCs.|dkr|jS|dkr|jStd|fdS)z|A workaround to get special attributes on the ServerProxy without interfering with the magic __getattr__ rrizAttribute %r not foundN)_ServerProxy__closerdAttributeError)rattrrrrrs zServerProxy.__call__)NNFFFF) r r!r"r#r%rmrlr*rrrrrrrr]`s r]__main__zhttp://localhost:8000ERRORr r~)FF)NNNF)FF)fr# __future__rrrrZfuture.builtinsrrrr r rf encodestringrj decodestringrgsysr>r Zfuture.backports.httpr r(Zfuture.backports.urllibr r<Z future.utilsrZ xml.parsersrr"r$rrr ImportErrorrversionrZrr PARSE_ERROR SERVER_ERRORAPPLICATION_ERROR SYSTEM_ERRORTRANSPORT_ERRORNOT_WELLFORMED_ERRORUNSUPPORTED_ENCODINGINVALID_ENCODING_CHARINVALID_XMLRPCMETHOD_NOT_FOUNDINVALID_METHOD_PARAMSINTERNAL_ERRORr5rr$r,r-rrBooleanr:rAobjectrBr_r`rarlrrmrrrrrrrrrrrr rr rrrr[r]Serverr rrX currentTimeZgetCurrentTimerZmultiZgetDatapowaddrrrrrXs,           O ((- '  ' M b$_