zfc@sdZddlZddlZddlZddlZddlmZmZmZmZdZ dej fdYZ dddYZ d efd YZ d ee fd YZd ee fdYZdS(sKSelf documenting XML-RPC Server. This module can be used to create XML-RPC servers that serve pydoc-style documentation in response to HTTP GET requests. This documentation is dynamically generated based on the functions and methods registered with the server. This module is built upon the pydoc and SimpleXMLRPCServer modules. iN(tSimpleXMLRPCServertSimpleXMLRPCRequestHandlertCGIXMLRPCRequestHandlertresolve_dotted_attributecCs^|jdd}|jdd}|jdd}|jdd}|jd d }|S( Nt&s&ts>t"s"s's'(treplace(ts((s'/usr/lib64/python2.7/DocXMLRPCServer.pyt_html_escape_quotes t ServerHTMLDoccBsDeZdZdiiidZdiiiddZdZRS(s7Class used to generate pydoc HTML document for a servercCs|p |j}g}d}tjd}x|j||} | sIPn| j\} } |j|||| !| j\} } }}}}| r|| jdd}|jd||fn|rdt|}|jd||| fn|r7dt|}|jd||| fnl|| | d!d krp|j|j ||||n3|r|jd |n|j|j ||| }q-W|j|||d j |S( sMark up some plain text, given a context of symbols to look for. Each context dictionary maps object names to anchor names.isM\b((http|ftp)://\S+[\w/]|RFC[- ]?(\d+)|PEP[- ]?(\d+)|(self\.)?((?:\w|\.)+))\bRs"s%ss'http://www.rfc-editor.org/rfc/rfc%d.txts(http://www.python.org/dev/peps/pep-%04d/it(sself.%st( tescapetretcompiletsearchtspantappendtgroupsRtinttnamelinktjoin(tselfttextRtfuncstclassestmethodstresultstheretpatterntmatchtstarttendtalltschemetrfctpeptselfdottnameturl((s'/usr/lib64/python2.7/DocXMLRPCServer.pytmarkup$s8  " cCs|r|jpdd|}d} d|j||j|f} tj|rtj|j\} } } }tj| d| | |d|j}nTtj|rtj|\} } } }tj| | | |d|j}nd}t |t r |dp |}|dpd}nt j |}| || oL|j d| }|j||j|||}|o{d |}d ||fS( s;Produce HTML documentation for a function or method object.R t-s$%sit formatvalues(...)is'%ss
%s
s
%s
%s
(t__name__Rtinspecttismethodt getargspectim_funct formatargspecR,t isfunctiont isinstancettupletpydoctgetdoctgreyR*t preformat(RtobjectR(tmodRRRtcltanchortnotettitletargstvarargstvarkwtdefaultstargspect docstringtdecltdoc((s'/usr/lib64/python2.7/DocXMLRPCServer.pyt docroutineMs6c Csi}x6|jD](\}}d|||<||||%ss#ffffffs#7799ees %ss

%s

RtMethodss#eeaa77( titemsRtheadingR*R9tsortedRRHt bigsectionR6R( Rt server_nametpackage_documentationRtfdicttkeytvaluetheadtresultRGtcontentst method_items((s'/usr/lib64/python2.7/DocXMLRPCServer.pyt docserverws" # N(R-t __module__t__doc__tNoneR*RHRW(((s'/usr/lib64/python2.7/DocXMLRPCServer.pyR !s ))tXMLRPCDocGeneratorcBs;eZdZdZdZdZdZdZRS(sGenerates documentation for an XML-RPC server. This class is designed as mix-in and should not be constructed directly. cCsd|_d|_d|_dS(NsXML-RPC Server DocumentationsGThis server exports the following methods through the XML-RPC protocol.(RNtserver_documentationt server_title(R((s'/usr/lib64/python2.7/DocXMLRPCServer.pyt__init__s  cCs ||_dS(s8Set the HTML title of the generated server documentationN(R](RR]((s'/usr/lib64/python2.7/DocXMLRPCServer.pytset_server_titlescCs ||_dS(s7Set the name of the generated HTML server documentationN(RN(RRN((s'/usr/lib64/python2.7/DocXMLRPCServer.pytset_server_namescCs ||_dS(s3Set the documentation string for the entire server.N(R\(RR\((s'/usr/lib64/python2.7/DocXMLRPCServer.pytset_server_documentationscCsii}x|jD]}||jkr8|j|}n|jdk rddg}t|jdr~|jj||d html documentation for the server Generates HTML documentation for the server using introspection for installed functions and instances that do not implement the _dispatch method. Alternatively, instances can choose to implement the _get_method_argstring(method_name) method to provide the argument string used in the documentation and the _methodHelp(method_name) method to provide the help text used in the documentation.t_get_method_argstringit _methodHelpit _dispatchN(NN(tsystem_listMethodsRtinstanceRZthasattrRbRcR5RtAttributeErrorR RWRNR\R R]tpage(RRt method_nametmethodt method_infot documentert documentationR?((s'/usr/lib64/python2.7/DocXMLRPCServer.pytgenerate_html_documentations:           (R-RXRYR^R_R`RaRo(((s'/usr/lib64/python2.7/DocXMLRPCServer.pyR[s     tDocXMLRPCRequestHandlercBseZdZdZRS(sXML-RPC and documentation request handler class. Handles all HTTP POST requests and attempts to decode them as XML-RPC requests. Handles all HTTP GET requests and interprets them as requests for documentation. cCs|js|jdS|jj}|jd|jdd|jdtt||j|j j |dS(s}Handles the HTTP GET request. Interpret all HTTP GET requests as requests for server documentation. Nis Content-types text/htmlsContent-length( tis_rpc_path_validt report_404tserverRot send_responset send_headertstrtlent end_headerstwfiletwrite(Rtresponse((s'/usr/lib64/python2.7/DocXMLRPCServer.pytdo_GETs    (R-RXRYR|(((s'/usr/lib64/python2.7/DocXMLRPCServer.pyRpstDocXMLRPCServercBs&eZdZedededZRS(sXML-RPC and HTML documentation server. Adds the ability to serve server documentation to the capabilities of SimpleXMLRPCServer. icCs0tj|||||||tj|dS(N(RR^R[(RtaddrtrequestHandlert logRequestst allow_nonetencodingtbind_and_activate((s'/usr/lib64/python2.7/DocXMLRPCServer.pyR^s N(R-RXRYRptFalseRZtTrueR^(((s'/usr/lib64/python2.7/DocXMLRPCServer.pyR}s tDocCGIXMLRPCRequestHandlercBs eZdZdZdZRS(sJHandler for XML-RPC data and documentation requests passed through CGIcCs5|j}dGHdt|GHHtjj|dS(s}Handles the HTTP GET request. Interpret all HTTP GET requests as requests for server documentation. sContent-Type: text/htmlsContent-Length: %dN(RoRwtsyststdoutRz(RR{((s'/usr/lib64/python2.7/DocXMLRPCServer.pyt handle_gets  cCstj|tj|dS(N(RR^R[(R((s'/usr/lib64/python2.7/DocXMLRPCServer.pyR^ s (R-RXRYRR^(((s'/usr/lib64/python2.7/DocXMLRPCServer.pyR s ((RYR6R.RRRRRRR tHTMLDocR R[RpR}R(((s'/usr/lib64/python2.7/DocXMLRPCServer.pyt s    " oR