�`^c@s�dZddlZddlZddlZddlZddlmZmZmZmZdej fd��YZ
ddd��YZdefd ��YZd
eefd��YZ
deefd
��YZdS(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.
i�N(tSimpleXMLRPCServertSimpleXMLRPCRequestHandlertCGIXMLRPCRequestHandlertresolve_dotted_attributet
ServerHTMLDoccBsDeZdZdiiid�Zdiiidd�Zd�ZRS(s7Class used to generate pydoc HTML document for a servercCs�|p|j}g}d}tjd�}x|j||�} | sIPn| j�\}
}|j||||
!��| j�\}}
}}}}|
r�||�jdd�}|jd||f�n�|rdt|�}|jd|||�f�n�|r7dt|�}|jd|||�f�nl|||d!d krp|j|j ||||��n3|r�|jd
|�n|j|j ||��|}q-|j|||��dj
|�S(s�Mark 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|\.)+))\bt"s"s<a href="%s">%s</a>s'http://www.rfc-editor.org/rfc/rfc%d.txts(http://www.python.org/dev/peps/pep-%04d/it(sself.<strong>%s</strong>t(tescapetretcompiletsearchtspantappendtgroupstreplacetinttnamelinktjoin(tselfttextRtfuncstclassestmethodstresultstheretpatterntmatchtstarttendtalltschemetrfctpeptselfdottnameturl((s%/sys/lib/python2.7/DocXMLRPCServer.pytmarkups8 " cCs�|r|jpdd|}d} d|j|�|j|�f}
tj|�r�tj|j�\}}}
}tj|d||
|d|j�}nTtj|�r�j|�\}}}
}tj|||
|d|j�}nd}t |t
�r |dp
|}|dpd}ntj|�}|
|| oL|j
d| �}|j||j|||�}|o{d |}d
||fS(s;Produce HTML documentation for a function or method object.Rt-s$<a name="%s"><strong>%s</strong></a>itformatvalues(...)is'<font face="helvetica, arial">%s</font>s<dd><tt>%s</tt></dd>s<dl><dt>%s</dt>%s</dl>
(t__name__Rtinspecttismethodt
getargspectim_funct
formatargspecR't
isfunctiont
isinstancettupletpydoctgetdoctgreyR%t preformat(RtobjectR#tmodRRRtcltanchortnotettitletargstvarargstvarkwtdefaultstargspect docstringtdecltdoc((s%/sys/lib/python2.7/DocXMLRPCServer.pyt
docroutineCs6cCsi}x6|j�D](\}}d|||<||||<qW|j|�}d|}|j|dd�}|j||j|�} | o�d| } |d| }g}
t|j��}x3|D]+\}}|
j|j||d|��q�W||jddd t j
|
��}|S(
s1Produce HTML documentation for an XML-RPC server.s#-s)<big><big><strong>%s</strong></big></big>s#ffffffs#7799ees<tt>%s</tt>s
<p>%s</p>
RtMethodss#eeaa77(titemsRtheadingR%R4tsortedR
RCt
bigsectionR1R(Rtserver_nametpackage_documentationRtfdicttkeytvaluetheadtresultRBtcontentstmethod_items((s%/sys/lib/python2.7/DocXMLRPCServer.pyt docserverms"
# N(R(t
__module__t__doc__tNoneR%RCRR(((s%/sys/lib/python2.7/DocXMLRPCServer.pyRs
))tXMLRPCDocGeneratorcBs;eZdZd�Zd�Zd�Zd�Zd�ZRS(s�Generates 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.(RItserver_documentationtserver_title(R((s%/sys/lib/python2.7/DocXMLRPCServer.pyt__init__�s cCs
||_dS(s8Set the HTML title of the generated server documentationN(RX(RRX((s%/sys/lib/python2.7/DocXMLRPCServer.pytset_server_title�scCs
||_dS(s7Set the name of the generated HTML server documentationN(RI(RRI((s%/sys/lib/python2.7/DocXMLRPCServer.pytset_server_name�scCs
||_dS(s3Set the documentation string for the entire server.N(RW(RRW((s%/sys/lib/python2.7/DocXMLRPCServer.pytset_server_documentation�scCs]i}x|j�D]}||jkr8|j|}n�jdk rddg}t|jd�r~|jj|�|d<nt|jd�r�|jj|�|d<nt|�}|dkr�|}qt|jd�syt|j|�}Wqt k
r|}qXq|}n|||<qWt
�}|j|j|j
|�}|j|j|�S(sgenerate_html_documentation() => 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_listMethodsRtinstanceRUthasattrR]R^R0RtAttributeErrorRRRRIRWtpageRX(RRtmethod_nametmethodtmethod_infot
documentert
documentation((s%/sys/lib/python2.7/DocXMLRPCServer.pytgenerate_html_documentation�s8
(R(RSRTRYRZR[R\Rj(((s%/sys/lib/python2.7/DocXMLRPCServer.pyRV�s tDocXMLRPCRequestHandlercBseZdZd�ZRS(s�XML-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�|j�s|j�dS|jj�}|jd�|jdd�|jdtt|���|j�|j j
|�dS(s}Handles the HTTP GET request.
Interpret all HTTP GET requests as requests for server
documentation.
Ni�sContent-types text/htmlsContent-length(tis_rpc_path_validt
report_404tserverRjt
send_responsetsend_headertstrtlentend_headerstwfiletwrite(Rtresponse((s%/sys/lib/python2.7/DocXMLRPCServer.pytdo_GET�s
(R(RSRTRw(((s%/sys/lib/python2.7/DocXMLRPCServer.pyRk�stDocXMLRPCServercBs&eZdZededed�ZRS(s�XML-RPC and HTML documentation server.
Adds the ability to serve server documentation to the capabilities
of SimpleXMLRPCServer.
icCs0tj|||||||�tj|�dS(N(RRYRV(RtaddrtrequestHandlertlogRequestst
allow_nonetencodingtbind_and_activate((s%/sys/lib/python2.7/DocXMLRPCServer.pyRY�s
N(R(RSRTRktFalseRUtTrueRY(((s%/sys/lib/python2.7/DocXMLRPCServer.pyRx�s tDocCGIXMLRPCRequestHandlercBs eZdZd�Zd�ZRS(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(RjRrtsyststdoutRu(RRv((s%/sys/lib/python2.7/DocXMLRPCServer.pyt
handle_gets
cCstj|�tj|�dS(N(RRYRV(R((s%/sys/lib/python2.7/DocXMLRPCServer.pyRYs
(R(RSRTR�RY(((s%/sys/lib/python2.7/DocXMLRPCServer.pyR�s ((RTR1R)R R�RRRRtHTMLDocRRVRkRxR�(((s%/sys/lib/python2.7/DocXMLRPCServer.pyt<module>s"oQ
|