m %UIc@sdZdZdZdZdZdkZdkZdkZdkZdk Z dk Z dk Z dk l Z dklZlZlZlZlZlZlZlZdklZd Zd Zd Zd Zd ZdZdZei dei!Z"dZ#dZ$dZ%dZ&e'dZ(dZ)hdZ*de+fdYZ,dZ-dhdZ.dfdYZ/de fd YZ0d!e/fd"YZ1d#e fd$YZ2d%e/fd&YZ3d'a4d(Z5d)Z6d*Z7d+Z8d,Z9d-Z:d.Z;dd/Z<e3Z=e1Z>dd0Z?d1dd2Z@dd3ZAd4e'd5ZBd6fd7YZCeCeiDeiEZFd8fd9YZGd:eGfd;YZHd<ZIe'e'd=ZJd>ZKd?ZLd@ZMeNdAjo eMndS(BsGenerate Python documentation in HTML or text for interactive use. In the Python interpreter, do "from pydoc import help" to provide online help. Calling help(thing) on a Python object documents the object. Or, at the shell command line outside of Python: Run "pydoc " to show documentation on something. may be the name of a function, module, package, or a dotted reference to a class or function within a module or module in a package. If the argument contains a path segment delimiter (e.g. slash on Unix, backslash on Windows) it is treated as the path to a Python source file. Run "pydoc -k " to search for a keyword in the synopsis lines of all available modules. Run "pydoc -p " to start an HTTP server on a given port on the local machine to generate documentation web pages. For platforms without a command line, "pydoc -g" starts the HTTP server and also pops up a little window for controlling it. Run "pydoc -w " to write out the HTML documentation for a module to a file named ".html". Module docs for core modules are assumed to be in http://www.python.org/doc/current/lib/ This can be overridden by setting the PYTHONDOCS environment variable to a different URL or to a local directory containing the Library Reference Manual pages. sKa-Ping Yee s26 February 2001s$Revision: 43347 $sGuido van Rossum, for an excellent programming language. Tommy Burnette, the original creator of manpy. Paul Prescod, for all his work on onlinehelp. Richard Chamberlain, for the first implementation of textdoc. N(sRepr(s expandtabssfindsjoinslowerssplitsstripsrfindsrstrip(sdequecCsg}g}xztiD]o}tii|pd}tii|}||jo1tii |o|i ||i |qqW|S(sAConvert sys.path into a list of absolute, existing, unique paths.t.N( tdirstnormdirstsystpathtdirtostabspathtnormcasetnormdirtisdirtappend(RR RR((t"/data/zmath/lib/python2.4/pydoc.pytpathdirs=s   cCsFti|p ti|}|otiddt|pdS(s-Get the doc string or comments for an object.s^ * tN(tinspecttgetdoctobjectt getcommentstresulttretsubtrstrip(RR((R RIscCstt|d}t|djo|ddfSnEt|djo1t|d o|dt|ddfSndt|dfS(s>Split a doc string into a synopsis line (if any) and the rest.s iiRiN(tsplittstriptdoctlinestlenRtjoin(RR((R tsplitdocNs%cCs2|i}|i|jo|id|}n|S(s@Get a class name and qualify it with a module name if necessary.RN(Rt__name__tnamet __module__tmodname(RR!R((R t classnameWs  cCs^ti|pMti|p=ti|p-ti|pti|p ti| S(s>Check if an object is of a type that probably means it's data.N(RtismoduleRtisclasst isroutinetisframet istracebacktiscode(R((R tisdata^scGs=x6|o.tt||d|d}|d}qW|S(s/Do a series of global replacements on a string.iiiN(tpairsRRttext(R+R*((R treplaceds  cCsgt||joPtd|dd}td|d|}|| d|t||Sn|S(sCOmit part of a string if needed to make it fit in a maximum length.iiis...N(RR+tmaxlentmaxtpretpost(R+R-R/R0((R tcramks "s at 0x[0-9a-f]{6,16}(>+)$cCs.tittotid|Sn|S(s>Remove the hexadecimal id from a Python object representation.s\1N(t _re_stripidtsearchtreprt ExceptionRR+(R+((R tstripidtscCsti|p ti|S(N(Rtismethodtobjtismethoddescriptor(R8((R t_is_some_method{scCsh}x*ti|tD]\}}d||((R RC~s   cCsRg}g}x9|D]1}||o|i|q|i|qW||fS(sSplit sequence s via predicate, and return pair ([true], [false]). The return value is a 2-tuple of lists, ([x for x in s if predicate(x)], [x for x in s if not predicate(x)]) N(tyestnotstxt predicateR (RHRJRIRFRG((R t _split_lists cCs||ddddddgjodSn|ido|idod Sn|d j o||jSn|id  Sd S( s3Decide whether to show documentation on a variable.t __builtins__t__doc__t__file__t__path__R Rit__it_N(Rt startswithtendswithtalltNone(RRT((R t visiblenames  cCsctii|oLxIdddgD]4}tiitii|d|otSq#q#WntS(s3Guess whether a path refers to a package directory.s.pys.pycs.pyot__init__N(RRR texttisfileRtTruetFalse(RRX((R t ispackages&c Csti|i}|i|d\}}||jot i |}yt |}Wntj o dSnX|ojd|djoYy tid|||d}Wn dSnXt|ipddd}tid=n|i}x<|d djpt| o|i}|pPqqWt|}|d d jo|d}n|d d jos|d }|d djo|d }nx*t|p|i}|pPqqWtt|d d}nd}|i||f||Rdt __import__RnRRuR?RvRhRtRNt SyntaxErrorRat ImportErrorRtlowertstrRUtpartREtAttributeError( RRRdRRnRvRR>RhRuRR?R((R t safeimports4< 6 tDoccBs;tZddZddZeZZZZdZ RS(NcGs||f|}ygti|o|i|Snti|o|i|Snti |o|i |SnWnt j onXt |t o|i|Sn|i|S(s%Generate documentation for an object.N(RRtargsRR#Rwt docmoduleR$tdocclassR%t docroutineRt isinstancetpropertyt docpropertytdocother(RwRRR((R tdocument'scGs7d|odt|t|if}t|dS(s+Raise an exception for unimplemented types.s.don't know how to document object%s of type %st N(RR4RyRRtmessaget TypeError(RwRRRR((R tfail7s*c Cs yti|}Wntj o d}nXtiidd}ti i t i ddt i dd!}t|tto|idjp0|i|os|iti i |d oSd|i}|idod|id|f}qti i ||}nd}|S(s*Return the location of module docs or Nones (built-in)t PYTHONDOCSs%http://www.python.org/doc/current/libtlibtpythoniiterrnot exceptionstgcRltmarshaltposixtsignalRtthreadt zipimports site-packagessmodule-%s.htmlshttp://s%s/%st/N( serrnos exceptionsRsimpsmarshalsposixssignalssysRs zipimport(Rt getabsfileRRjRRtenvironRetdoclocRRRt exec_prefixtversiontbasedirRRyRRRthtmlfileRRU(RwRRRRjR((R t getdocloc?s    V ( RR RURRRRRRR(((R R&s  tHTMLReprcBsPtZdZdZdZdZdZdZeZdZ eZ RS(sBClass for safely making an HTML representation of a Python object.cCs:ti|d|_|_d|_d|_|_dS(Nii id(tReprRWRwtmaxlisttmaxtupletmaxdictt maxstringtmaxother(Rw((R RW^s  cCst|ddddddS(Nt&s&ts>(R,R+(RwR+((R tescapedscCsti||S(N(RR4RwR(RwR((R R4gscCstt|doPdttt|id}t||ot||||Sqfn|i t t t ||iS(NRtrepr_RQ(thasattrRyRIRRRt methodnameRwREtlevelRR1R6R4R(RwRIRR((R trepr1js "cCst||i}t|}d|jo>dt|ddjo%d|d|i||dSnt i dd|i|S(Ns\s\\RR}is-((\\[\\abfnrtv\'"]|\\[0-9]..|\\x..|\\u....)+)s\1( R1RIRwRttestR4ttestreprR,RRR(RwRIRRR((R t repr_stringqs &% cCsNy)|ittt||iSWn|id|iiSnXdS(Ns <%s instance>( RwRR1R6R4RIRt __class__R(RwRIR((R t repr_instance~s)( RR RMRWRR4RRtrepr_strRt repr_unicode(((R R\s       tHTMLDoccBs=tZdZeZeiZeiZdZddZdde ddZ dZ dZ d d Z d Zd Zd ZdZdZe hhhdZe dZe e dZe e hhdZdZe e hhhe dZdZe e e dZe e dZe dZRS(s'Formatter class for HTML documentation.cCsd||fS(sFormat an HTML page.s Python: %s %s N(ttitletcontents(RwRR((R tpagesRcCsd|||||pdfS(sFormat a page heading.s'
 
 
%s
%s
s N(tbgcoltfgcolRtextras(RwRRRR((R theadingsis c Cs~|djodd|d}nd|||f} |o| d||||f} n| d|||f} | d|S( s Format a section with a heading.ss ss

sR s( s'
 
%s
%s %s
%s
%s%s%s
N( t marginaliaRUtwidthRRRRtpreludetgapR( RwRRRRRRRRR((R tsections cGsd|}|i||S(s$Format a section with a big heading.s%sN(RRwRR(RwRR((R t bigsections c Cs7|it|}t|dddddddd S(s!Format literal preformatted text.s s Rs s s
N(RwRt expandtabsR+R,(RwR+((R t preformatsicCsd}t||d|}xt|D]w}|dd|}xRt|||||D]5}|t|jo||||d}q_q_W|d}q+Wd|S( s0Format a list of items into a multi-column list.Risids
ss7%s
N( RRtlisttcolstrowstrangetcoltitformat(RwRRRRRRR((R t multicolumns  cCsd|S(Ns%s(R+(RwR+((R tgreyscGs8x1|D])}||jod|||fSqqW|S(s:Make a link for an identifier, given name-to-URL mappings.s%sN(tdictstdictR(RwRRR((R tnamelinks  cCss|itii|i}}t||o7t |||jo!d|i|t ||fSnt ||S(sMake a link for a class.s%sN( RRRRoReR RRnRRER"R!(RwRR!RRn((R t classlinks &!cCsd|i|ifS(sMake a link for a module.s%sN(RR(RwR((R t modulelinkscCsx|\}}}}|o|i|Sn|od||f}n d|}|od|}n|}d||fS(s;Make a link for a module or package to display in an index.s %s.%s.htmls%s.htmls"%s (package)s%sN(RRR\tshadowedRwRturlR+(Rwt.2RRR\RRR+((R t modpkglinks cCs|p|i}g}d}tid} xto| i||} | pPn| i \} }|i|||| !| i\}} }} }}| o3||idd}|id||fn|o1dt|}|id|||fn| o1dt| }|id|||fnq|||d!d jo#|i|i||||n6|o|id |n|i|i|||}q.W|i|||t|d S( sMark up some plain text, given a context of symbols to look for. Each context dictionary maps object names to anchor names.isD\b((http|ftp)://\S+[\w/]|RFC[- ]?(\d+)|PEP[- ]?(\d+)|(self\.)?(\w+))t"s"s%ss'http://www.rfc-editor.org/rfc/rfc%d.txts(http://www.python.org/peps/pep-%04d.htmlit(sself.%sRN(RRwtresultsthereRtcompiletpatternRZR3R+tmatchtspantstarttendR tgroupsRTtschemetrfctpeptselfdotRR,RtintRR;tfuncstclassesR(RwR+RRRR;RTRRRRRRRRRRRR((R tmarkups<!!# c Csd}x|D]} t| tfjo| \}}|d}||i||}|o_||fjoOg}x'|D]}|i |i||q|W|dt |dd}n|d}q t| tgjo!|d|i| ||}q q Wd|S( sAProduce HTML for a class tree as given by inspect.getclasstree().Rs"

Rs, t)s
s
%s
s
%s
N(RttreetentryRytctbasesRwRR!tparenttparentsRAR Rt formattree( RwRR!RRRR RRAR((R R s$  %c$Gsy|i}y |i}Wntj o d}nXt|d}g}xJt t |dD]2}|i dt||d d||fq^Wt||dd}d|} yUti|}|}"tidjodk}|i|}"nd|"|f}Wntj o d }nXg}t|d ojt|i}|d d d jo(|dd jot |d d!}n|i d|i"|nt|do#|i |i"t|i#n|o| dt|d} n|i$|}!|!dj odt&}!nd}!|i'| ddd||!} ti)|ti*} gh}#}xti)|ti.D]w\}}|dj pti1|p||joAt2||o-|#i ||fd|||<|||o|||||iAt|iW|iC}| |iQd-dd|} nt|d.o>|iAt|iX|iC}| |iQd/dd|} n| S(0s/Produce HTML documentation for a module object.Ris5%sis)%stwin32Ns%ss (built-in)t __version__i t$s Revision: s version %st__date__s (%s)s, s(
Module DocsRs#ffffffs#7799eesindex
R_s.html#s#-s %ss

%s

ROiRWsPackage Contentss#aa55cccCs|\}}|i|S(N(R>R?RHR(t.0RHR>R?((R tstModuless#fffffcCs|\}}|S(N(R>R?(RR>R?((R RstClassess#ee77aat Functionss#eeaa77tDatas#55aa55s
t __author__tAuthort __credits__tCredits(YRRRt__all__RTRRURtpartstlinksRRRR Rt linkednametheadRRRRRtplatformt nturl2patht pathname2urltfilelinkRRhRRR RRRwRRRRtlocalsRRR<R#RoRtcdictR$R>R?t getmoduleRVR@RAR R!ReRnRERtfdictR%t isbuiltint isfunctiontdataR)RRRRtmodpkgstmodnamesRtlistdirRORjt getmodulenameR\tsortRRRRtmapt classlistR t getclasstreeRRR($RwRRtmodtignoredR>RTRRR/RRnR*RRjR)RR!RRRRAR?RR%RR(RhR!RRR#RoRRR((R R,s   0   &#   *"  $ .  3 !  %   ! && && )  csi}|p|}i} g} | idfdY}|t t i }t|djoPidx+|D]#}di|iqWdnd}d}d }td t i}hxg|D]_\}}}}d |d ||<}t!|}y|| i(RwR4tpush(Rw(R5(R tmaybes (RR RWR6((R5(R R3s is&
Method resolution order:
s
%s
s
c st||\}}|omi|xV|D]J\}}}}i t||dq7Wn|S(Ns (RKtattrsRJtokthrR6R5tmsgRRthomeclsR?RwRRERR1RRtmdict(R:R7RJR8RRR?R;(RR<R9RwRR5RR1(R tspills  csnt||\}}|oNi|x7|D]+\}}}}i ||q7Wn|S(N(RKR7RJR8R9R6R5R:RRR;R?Rwt _docpropertyR1(R:R7RJR8RRR?R;(R9RwR5R1(R tspillpropertiess  !c st||\}}|oi|x|D]\}}}} i t||}t| pti| ot| dd}nd}|djod|nCit| i}d|}d||fdq7Wn|S(NRMs
%s
s
%ss
%s%s
s (RKR7RJR8R9R6R5R:RRR;R?RwRRERR1RAtcallableRtisdatadescriptorRURRRRRRR<( R:R7RJRAR;RR8RRR?(RR<RwRR9R1RR5(R t spilldatas$    cCs|\}}}}t|S(N(RRtclsR?RV(RRRRCR?((R RsR_t-ics|djS(Ni(ttt thisclass(RE(RF(R R ss defined heresinherited from %ss:
R>cCs|dS(Ni(RE(RE((R Rss Methods %scCs|ddjS(Nitmethod(RE(RE((R RssClass methods %scCs|ddjS(Nis class method(RE(RE((R RssStatic methods %scCs|ddjS(Nis static method(RE(RE((R Rss Properties %scCs|ddjS(NiR(RE(RE((R R ssData and other attributes %scCs|ddjS(NiR((RE(RE((R R"sRs*class %ss/%s = class %ss(%s)s, s%s
 
s#000000s#ffc8d8iN(4RRtrealnameRR@RRR R5R3R9tdequeRtgetmrotmroRR6RARwRR R=R?RBtfiltertclassify_class_attrsR7R<R>RR;R?tanchorRERtpopleftRFRKt inheritedt __builtin__ttagR-RRR RRRRRRR(RwRRR1RRR2RRR7R<RFRRRR3RPR R?RHR9RAR>RKRR;R=RRBR?R5RN(( RwRR1RRR9R5R<RFR Rs       !  !                    $cCs|id|i|S(s)Format an argument default value as text.t=N(RwRR4R(RwR((R t formatvalue8scCs]|i}|p|}|o |ipdd|}d} d} ti |o|i }|o+||j od|i ||} qnA|io d|i |ii|} nd|i ||} |i}n||jod||f} nj|oI||ijo9|i||jo%d|id||f}d } n|}d |||f} ti|ohti|\} }} }ti| || |d |i}|d jod |} |d d!}qnd}| || o|id| }| o d|SnD|i t!||i"|||}|od|}d||fSdS(s;Produce HTML documentation for a function or method object.RRDis from s method of %s instances unbound %s methods$%ss%sis)%s = %sRTss$%s lambda is(...)s'%ss
%s
s
%s
s
%s
%s
N('RRRHRR=RNtnotetskipdocsRR7tim_classtimclassRwRR1tim_selfRtim_funcRt__dict__treallinkR't getargspecRtvarargstvarkwtdefaultst formatargspecRTtargspecRtdeclRRRRRR;R(RwRRR1RRR;R=RcRVRRUR_RRHR^R\RXRbR`RRN((R R<sF        + !  " $c Csg}|i} |o| d|n|idj o-|it ||i }| d|nx`d d dgD]O\}}t||}|dj o'|i|||} | d | ququW| d d i|S(Ns!
%s
s
%s
tfgets gettfsets settfdelsdeletes
%s
s
R(Rds get(Res set(Rfsdelete(RR R5RR?RMRURwRRRRtattrRRREtfuncRR1RAR( RwRR?R1RRRRRhRgR5RA((R R>rs    cCs|i|||S(s*Produce html documentation for a property.N(RwR>RRR1(RwRRR1R=((R RscGs)|o d|pd}||i|S(s-Produce HTML documentation for a data object.s%s = RN(RtlhsRwR4R(RwRRR1R2Ri((R Rsc Cs!g}|djo h}nh} ti|}||| d}xA|D]9}ti i ||} t | o||dqKqKWxa|D]Y}ti i ||} ti i | o+ti|}|o||dqqqW|i|i||i}|i|dd|S(s2Generate an HTML index for a directory of modules.cCsH||jo7|i|d|||jfd||RRRm(((R Rs2            &  6 tTextReprcBs8tZdZdZdZdZeZdZRS(sAClass for safely making a text representation of a Python object.cCs:ti|d|_|_d|_d|_|_dS(Nii id(RRWRwRRRRR(Rw((R RWs  cCstt|doPdttt|id}t||ot||||Sqfnt t t ||i S(NRRRQ(RRyRIRRRRRwRERR1R6R4R(RwRIRR((R Rs "cCsdt||i}t|}d|jo5dt|ddjod|d||dSn|S(Ns\s\\RR}i(R1RIRwRRR4RR,(RwRIRRR((R Rs  &cCs<y ttt||iSWnd|iiSnXdS(Ns <%s instance>(R1R6R4RIRwRRR(RwRIR((R Rs (RR RMRWRRRR(((R Ros    tTextDoccBstZdZeZeiZdZddZdZe ddZ e e dZ e e dZ d Z e e e d Zd Ze e e d Ze e e e e d ZRS(s'Formatter class for text documentation.cCsttd|dS(s(Format a string in bold by overstriking.cCs |d|S(Ns(tch(Rq((R RsRN(RR.R+(RwR+((R tboldss cCs_|pdSnt|d}t|d|}|ot|d|dR?(RR>R?((R R1sitCLASSESt FUNCTIONSR-iFtDATAR i R s Revision: itVERSIONRtDATERtAUTHORRtCREDITSN(:RRRRRtsynoptdescRwRRRRTRRURRRjRRRRR<R$R>R?R$RVR RR%R&R(R)RR)RR+RORRR,R!R\R-R.R/R R0RRRRR RRRRR(RwRRR1RRTR/RRjRR)RRRR>RR(R!R?RR((R Rs !     * 3    #!  #  # &#&###cs(i}|p|}i}id} ||jodi |}ni |d|}|o*t | |} |dt | d}nt}|o|dgpg}|itti}t|djo=dx"|D]}d | |qWd nd fd Y} | d }d} d}tdti}x3|o+|o|i!n|ddt#|d\}} t%ijo | }qn.jo d}ndt'i}td||i(|d||d}|d||d}|d||d}| d||d}|d||d}| }qWdi |}|p |dSn|di)t*|d dS("s4Produce text documentation for a given class object.cCs t||S(N(R"RR(RR((R tmakenameWssclass s = class s(%s)s, s isMethod resolution order:s RR3cstZdZdZRS(NcCs d|_dS(Ni(RwR4(Rw((R RWpscs)|ioddnd|_dS(NRDiFi(RwR4R5(Rw(R5(R R6rs (RR RWR6((R5(R R3os cszt||\}}|oZi|xC|D]7\}}}}i t||q7Wn|S(N(RKR7RJR8R9R6R5R:RRR;R?RwRRERR1(R:R7RJR8RRR?R;(R9RwRR5R1(R R=xs  csnt||\}}|oNi|x7|D]+\}}}}i ||q7Wn|S(N(RKR7RJR8R9R6R5R:RRR;R?RwR>R1(R:R7RJR8RRR?R;(R9RwR5R1(R R?s  !c st||\}}|oi|x|D]w\}}}}t |pt i|ot|}nd}it||ddd|dq7Wn|S(NR-iFRs (RKR7RJR8R9R6R5R:RRR;R?R@RRARRRURwRRERR1( R:R7RJR8RRRR?R;(RR9RwR5R1(R RBs  %cCs|\}}}}t|S(N(RRRCR?RV(RRRRCR?((R Rsics|djS(Ni(RERF(RE(RF(R Rss defined heresinherited from %scCs|did S(NiRQ(RERR(RE((R Rss Methods %s: cCs|ddjS(NiRG(RE(RE((R RssClass methods %s: cCs|ddjS(Nis class method(RE(RE((R RssStatic methods %s: cCs|ddjS(Nis static method(RE(RE((R RssProperties %s: cCs|ddjS(NiR(RE(RE((R RssData and other attributes %s: cCs|ddjS(NiR((RE(RE((R Rss | N(+RRRHRR@RR RRwRrRR.R RRRRR R5RIRRJRKRRAR3R9R=R?RBRLRMR7RORFRKRPRQRRR"R-RtR(RwRRR1RRR7RFRRRR RPR3R?RHR9RARR=RRBRKR5((RwRR1R9R5RFR RQsv                            cCsd|i|S(s)Format an argument default value as text.RSN(RwR4R(RwR((R RTscCs|i}|p|}d} d}ti|o|i} |o(| |j odt | |} qn;|i odt |i i|} ndt | |} |i}n||jo|i|}nM|o.||ijo|i||jo d}n|i|d|}ti|oqti|\}} }} ti|| || d|i} |d jo$|i|d }| dd !} qnd } || | }|o |d Sn:t|pd}|d |ot |i!|d SdS(s;Produce text documentation for a function or method object.Ris from s method of %s instances unbound %s methodis = RTss lambda is(...)s N("RRRHRRURVRR7RWRXR=R"R1RYRRZRwRrRR[R'R]RR^R_R`RaRTRbRcRRRRt(RwRRR1R=RcRRVRRURXRbR`R^RR_RH((R Rs>       + !  c Csg}|i} |o| |nd}t|pd}|o| |i |d}nxd d d gD]o\} }t || }|dj oG|o| dd}n|i|||} | |i | qqqqWd i|S(NiRiRdsResRfss (sfgets(sfsets(sfdels(RR R5Rtneed_blank_after_docRR?RRwRtRgRRRERhRURR1RAR( RwRR?R1RRRRRRhRgR5RA((R R>s&      cCs|i|||S(s*Produce text documentation for a property.N(RwR>RRR1(RwRRR1R=((R R sc Cs|i|}|oO|o |dpd|} |t| }|djo|| d}qen|o|i|dpd|} |dj o!| d|i t |7} n| S(s-Produce text documentation for a data object.s = Ris...s N( RwR4RR-RRqRtchopRrRRURtR( RwRRR1RR-RR4RRq((R R s % !(RR RMRoRnR4RrRtRRUR RRRTRR>RR(((R Rps      Zq + cCstat|dS(sCThe first time this is called, determine what kind of pager to use.N(tgetpagertpagerR+(R+((R Rs cCsttitij otSntii ptii otSnti i dddgjotSndti joPti djo dSqti i dddgjo dSqdSnti djpti i d o d Snt td o!tid d jo dSndk}|i\}}ti|z=t td o%tid|d jo dSntSWdti|XdS(s2Decide what method to use for paging through text.tTERMtdumbtemacstPAGERR cCstt|tidS(NR(t tempfilepagertplainR+RR(R+((R R+scCstt|tidS(NR(t pipepagerRR+RR(R+((R R-scCst|tidS(NR(RR+RR(R+((R R/stos2cCstt|dS(Nsmore <(RRR+(R+((R R1stsystems(less) 2>/dev/nullicCs t|dS(Ntless(RR+(R+((R R3sNsmore %scCs t|dS(Ntmore(RR+(R+((R R:s(RyRtstdoutRztFileTypet plainpagertstdintisattyRRReRRRRRttempfiletmkstemptfdRaRrtttypagertunlink(RRaR((R R!s4"   # &   * cCstidd|S(s%Remove boldface formatting from text.s.RN(RRR+(R+((R R@scCsGti|d}y|i||iWntj onXdS(s3Page through text by feeding it to another program.twN(RtpopentcmdtpipetwriteR+RrRk(R+RR((R RDs cCsidk}|i}t|d}|i||izti |d|Wdti |XdS(s<Page through text by invoking a program on a temporary file.NRR( RtmktempRaRiRjRR+RrRRRR(R+RRRaRj((R RMs    c Cstt|d}yAdk}tii}|i |}|i |d}Wn(t tfj od}d}nXzXtiiddd}}tiit|| ddx||otiidtii|}|d d gjotiid PnA|d dgjo-tiid ||d|d}qn|d ddgjo)|||}|djo d}qntiidt||||!dd||}qWWd|o|i||i|nXdS(s%Page through text on a text terminal.s NcCstiidS(Ni(RRR(((R RascCstiid d S(Nii(RRRp(((R RdstLINESiis -- more --tqtQs s R]tBsi(RRR+RtttyRRtfilenoRt tcgetattrtoldt setcbreaktgetcharRRRURRReR}tincRRRtflushRt tcsetattrt TCSAFLUSH( R+RRRRR}RRR((R RYsF   !     ,cCstiit|dS(s>Simply print unformatted text. This is the ultimate fallback.N(RRRRR+(R+((R RscCsti|oP|itijod|iSnt|dod|iSq`d|iSnti|od|iSnti|od|iSnti |od|iSnti |od|iSnt |t i jod |iiSnt |iS( s/Produce a short description of the given thing.sbuilt-in module ROspackage smodule sbuilt-in function sclass s function smethod s instance of N(RR#tthingRRRRR&R$R'R7RyRzt InstanceTypeR(R((R tdescribes$c Csg}t|dD]}|o ||qq~}d\}}xU|t|joAt t ||d d|}|o||d}}qDPqDW|oP|}x?||D]3}yt||}Wqtj o dSqXqW|Sn"tt|ott|SndS(s@Locate an object by name or dotted path, importing as necessary.RiiN(Ni(RRRRRRURntnRRRRt nextmoduleRRERRRQ( RRRRRRnRRR((R tlocates(5    cCs_t|to5t||}|ptd|n||fSn|t|ddfSdS(sDGiven an object or a path to an object, get the object and its name.s$no Python documentation found for %rRN( RRRRRRRRERU(RRR((R tresolvess Python Library Documentation: %scCs3y t||\}}t|}ti|}|o,d|jo|d||i d 7}n*|o"||j o|d|i 7}nti |p-ti |pti|p t|tpt|}|d7}nt||dti||Wn ttfj o}|GHnXdS(sCDisplay text documentation, given an object or a path to an object.Rs in s in module s objects N(RRRRRRRRR$RntrfindRR#R$R%RRRyRRR+RRRtR?(RRRRRRnR?R((R Rs @ &cCsytt||\}}tit|ti||}t |dd}|i ||i dG|dGHWn t tfj o}|GHnXdS(s<Write HTML documentation to a file in the current directory.s.htmlRtwroteN(RRRRRthtmlRRRRiRjRRrRRtR?(RRRRR?RjR((R twritedocs$  RcCs|djo h}nxti|D]}tii||}t|ot |||d|q'tii |oht i |}|oN|djo|d }n ||}||jod||d?df(RtstackRw(Rw((R t__repr__oscCsF|dj o|i|n%|i|i|iiddS(Ns You are now leaving help and returning to the Python interpreter. If you want to ask for help on a particular object directly from the interpreter, you can type "help(object)". Executing "help('string')" has the same effect as typing a particular string at the help> prompt. (trequestRURwthelptintrotinteractR)R(RwR2((R t__call__us    cCs|iidxtoy|id}|pPnWnttfj oPnXtt |dddd}t |ddgjoPn|i |qWdS(Ns shelp> RRt'Rtquit( RwR)RRZtgetlineR2tKeyboardInterrupttEOFErrorRR,RR3(RwR2((R R5s cCsO|itijot|Sn+|ii||ii|ii SdS(s.Read one line, using raw_input when available.N( RwR(RRt raw_inputtpromptR)RRRp(RwR=((R R9s  cCsKt|tdjo|djo|iq7|djo|iq7|djo|iq7|djo|iq7|d djo|it|dq7||ijo|i |q7||i jo|i |q7|ot |d q7n)t |t o |nt |d |iid dS( NRR3tkeywordsttopicsRoismodules is Help on %s:s (RyR2RwR4t listkeywordst listtopicst listmodulesRR>t showtopicR?RRRR)R(RwR2((R R3s*      cCs|iidtid dS(Ns Welcome to Python %s! This is the online help utility. If this is your first time using Python, you should definitely check out the tutorial on the Internet at http://www.python.org/doc/tut/. Enter the name of any module, keyword, or topic to get help on writing Python programs and using Python modules. To quit this help utility and return to the interpreter, just type "quit". To get a list of available modules, keywords, or topics, type "modules", "keywords", or "topics". Each module also comes with a one-line summary of what it does; to list the modules whose summaries contain a given word such as "spam", type "modules spam". i(RwR)RRR(Rw((R R4siiPc Cs|}|i||}t||d|}xt|D]}xt|D]~}|||}|t|joW|i i ||||djo.|i i dd|dt||qqSqSW|i i dq@WdS(NiRs (titemsR-RtcolumnstcolwRRRtrowRRRwR)R( RwRDRERRRRFRRG((R Rs    6cCs*|iid|i|iidS(NsN Here is a list of the Python keywords. Enter any keyword to get more help. (RwR)RRR>RD(Rw((R R@scCs*|iid|i|iidS(NsN Here is a list of available topics. Enter any topic name to get more help. (RwR)RRR?RD(Rw((R RAscCs|ip|iiddSn|ii||ii|} | p"|iidt |dSnt | t djo|i | Sn| \}}|id|d}yt|}Wn|iid|dSnXtidtitiB}tidtitiB} ti| dti|d|i} |idk} dk}dk} | i}| i|i|i |}|i"|_#|d |_$|i%|_&|d |_'|_(|i)| t*|i+d d d d}t,dt-|d |oW| i}|i |i.dt/t0|dd |iid|i+ndS(Ns Sorry, topic and keyword documentation is not available because the Python HTML documentation files could not be found. If you have installed them, please set the environment variable PYTHONDOCS to indicate their location. sno documentation found for %s RRs.htmlscould not read docs from %s s]*navigat.*?s.*?cCs |ihS(N(tparsertdo_p(RH((R RscCs |idS(Ns (R]R(taR]((R RssRs s s sRelated help topics: s, s %s (1RwR*R)RR?RettopicR>ttargetR4RyRCRatxrefsRiRjRRtItStdivpattaddrpatRRRRrthtmllibt formattertStringIOtbuffert HTMLParsertAbstractFormattert DumbWriterRHRIt start_tablet end_tabletdo_brtstart_trtstart_tdtstart_thtfeedR,tgetvalueRRtsend_flowing_dataRR(RwRKRHRjRaRSRMRURPRRLRTRRRQ((R RCsD ! *  !    -cCs~|o|iidt|nV|iidh}|d}ti||i |i |iiddS(NsO Here is a list of matching modules. Enter any module name to get more help. sI Please wait a moment while I gather a list of all available modules... cCsR|o#|ddjo|d d}nt|ddjod||RwR)RtaproposRoRct ModuleScannertrunRRD(RwR>RoRc((R RBs (RR R>R?RWR1RUR6R5R9R3R4RR@RARCRB(((R Rs& 3P       -tScannercBs tZdZdZdZRS(sA generic tree iterator.cCs)||_g|_||_||_dS(N(trootsRwtstatetchildrentdescendp(RwRhRjRk((R RWs   cCs|ipC|ipdSn|iid}||i|fg|_n|id\}}|p|ii|iSn|id}|i |o#|ii ||i|fn|S(Nii( RwRiRhRUtpoptrootRjtnodetnexttchildRkR (RwRnRpRmRj((R Ro#s   #(RR RMRWRo(((R Rgs  RecBs8tZdZdZdZdZeedZRS(s7An interruptible scanner that searches module synopses.cCsJtdt}ti|||i|itd||_dS(NcCs |dfS(NR(R(R((R R5scCs|\}}ti|iS(N(RtpkgRR`tst_ino(RRRq((R R7s( R.R RhRgRWRwt submodulest isnewpackagetinodes(RwRh((R RW4scCs|\}}g}xrti|D]a}tii||}t|o&|i |||od|fq"|i ||fq"W|i |S(NR( RtpackageRjRR+RjRRR\R R-(RwRRRvRjRRj((R Rs9s  & cCsv|\}}tii|oti|i}tii|o ||i jp|i i |t |Snt S(N(RRvRRtexistsR`RrtinodetislinkRwRuR R\R[(RwRRRvRx((R RtDs %#c Cs|ot|}nt|_h}xtiD]}|djod||<|djo|d|dqt t |i pddd} tt|d| |djo|d|| qq0q0Wx|ip|i}|pPn|\}}ti|}tii|o|o||od|}||jozd||<|djo|||dqt|pd} tt|d| |djo|||| qqqqW|o |ndS(Nt__main__iRs is - R(R>RR[RwR8RjRRR!RURcRRRMRRbRoRnRRvRR,RRYRst completer( RwRcR>R{RnRvR!RRjR((R RfKs>     #$      $!(RR RMRWRsRtRURf(((R Re2s   cCsPd}y dk}Wntj onX|idti||dS(sAPrint all the one-line module summaries that contain a substring.cCs;|ddjo|d d}n|G|od|GHdS(Nis .__init__s (package)s- (R!R(RR!R((R RcmsNtignore(RctwarningsRtfilterwarningsReRfR>(R>RcR}((R Rdks   c Csdk}dk}dk}d|ifdY}d|ifdY}d|ifdY}|i|_||_ ||_ z:y|||i Wnt|ifj onXWd|o |nXdS(NtMessagecBstZddZRS(NicCsf|i}|ididi||||id|_|id|_ |i |i dS(Niscontent-transfer-encodings content-type( RwRRR@RWtfptseekablet getheadertencodingheadert typeheadert parsetypet parseplist(RwRRR((R RW}s  ! (RR RW(((R R|st DocHandlercBs#tZdZdZdZRS(NcCsayG|id|idd|i|iiti||Wnt j onXdS(Nis Content-Types text/html( Rwt send_responset send_headert end_headerstwfileRRRRRRk(RwRR((R t send_documents   c Cs|i}|ddjo|d }n|d djo|d}n|o|djoyt|dd}Wn8tj o,}|i|tit |dSnX|o&|it |ti ||q|i|dt |nti dd d }d }td ti} ti| |} d tidd d| g}h}x*tD]}|iti||qkW|t|d} |id| dS(Nis.htmliRRRs$no Python documentation found for %ss?Python: Index of Moduless#ffffffs#7799eecCsd||fS(Ns%s(R(R((R t bltinlinkscCs |djS(NRz(RI(RI((R Rss

sBuilt-in Moduless#ee77aas

pydoc by Ka-Ping Yee <ping@lfw.org>sIndex of Modules(RwRRR8RtR?RRRRRRR4RRRLRRtnamesRRRtindicesRjR RR RmR( RwR8R?RRRjRRRRR((R tdo_GETs8  &       cGsdS(N((RwR((R t log_messages(RR RRR(((R Rs  #t DocServercBs#tZdZdZdZRS(NcCshtidjodpd}d|f|_d||f|_||_|ii ||i|i dS(Ntmacs 127.0.0.1t localhostRs http://%s:%d/( RRthosttportRwtaddressRRcRARWthandler(RwRRcR((R RWs  cCsjdk}t|_xQ|ipF|i|iigggd\}}}|o|i qqWdS(Ni( tselectR[RwR8tsocketRtrdtwrtexthandle_request(RwRRRR((R tserve_until_quits   -cCs/|ii||io|i|ndS(N(RwRAtserver_activateRc(Rw((R Rs (RR RWRR(((R Rs  (tBaseHTTPServert mimetoolsRRtBaseHTTPRequestHandlerRt HTTPServerRRARt MessageClassRRcRR:terrorR{( RRcR{RRRRRR((R tservexs .    cCsndfdY}dk}y8|i}z||}|iWd|iXWntj onXdS(sEGraphical interface (starts web server and pops up a control window).tGUIcBstZddZdZdddZddZddZdZddZ d Z dd Z dd Z d Z d ZddZRS(Ni(c Cs||_d|_d|_dk}|i||_|i|idd|_ |i |iddd|i dd|_ |i |iddd|i dd|_|i||_|i|idd|_|i|i|_|iid |i|i |idd d d d|idd|_tid jo|iiddn|iid|iid|i |i idddd|i idddddd|iidddddd|iidddd|iidd|iidddddd|iidddd|iidtid jodpdf}|i|d|dd|_|iid|i |iid|i!|i"|d d!d|ii#|_$|ii%d"|i$i&|i||_'|i |i'dd#d|i!|_(|i |i'dd$d|i)|_*|i(idddddd|i*idddddd|ii+|ii,|_-|ii.|_/|ii0|ii0|ii0|i'i0|_1|i-|i1|_2|_3d |_4|ii5d%|i-|i/f|ii6|i-|i/|ii7i8dk9}|i:d&t;d'||i=|i fi>dS((NR+sStarting server... s open browsertcommandRitdisableds quit servings Search forststoptpadyiR tsidetrighttpydoctWM_DELETE_WINDOWttoptfillRItlefttexpandit helveticaii tfonttheightis storienttverticaltyscrollcommandsgo to selecteds hide resultss%dx%dRLR(?twindowRwRUtservertscannertTkintertFramet server_frmtLabelt title_lbltButtonRitopen_btnR8tquit_btnt search_frmt search_lbltEntryt search_enttbindR3Rtstop_btnRRtpackRtprotocolt focus_setRtListboxt result_lstRtgotot Scrollbartyviewt result_scrtconfigtsett result_frmtgoto_btnthidethide_btnRBt winfo_widthtminwidtht winfo_heightt minheighttwinfo_reqheightt bigminheighttbigwidtht bigheighttexpandedt wm_geometryt wm_minsizettkt willdispatcht threadingtThreadRRtreadyR(RwRRRRR((R RWsl        $ #    9   cCsM||_|iidd|i|iidd|iidddS(NR+sPython documentation server at Ritnormal(RRwRRRRR(RwR((R Rs cCs|p |ii}ydk}|i|Wntj otidjoti d|qtidjo4y dk }Wntj oqX|i |qti d|}|oti d|qnXdS(NR s start "%s"Rs netscape -remote "openURL(%s)" &snetscape "%s" &( RRwRt webbrowserRiRRRRRtict launchurltrc(RwteventRRRR((R Ri"s   cCs+|iod|i_n|iidS(Ni(RwRR8R(RwR((R R82s cCs|ii}|iidd|iidd|iidd||ii|iidd|i i dd |i idd |i dk }|iod |i_nt|_|id |iid |i||ifidS(NRRRiRR+sSearching for "%s"...RiRRiRLR(RwRReR>RRRRtforgetRtdeleteRRRRR8ReRRfRBRR(RwRRR>((R R37s     cCsI|ddjo|d d}n|iid|d|pddS(Nis .__init__s (package)Rs - s(no description)(R!RwRtinsertR(RwRR!R((R RBIs cCs'|iod|i_d|_ndS(Ni(RwRR8RU(RwR((R ROs  cCsd|_|iidd|iidd|iidddddd tid jo|i i n|i id d dS( NR+s Search forRRRRRIRiR RiR( RURwRRRRRRRRR(Rw((R RTs cCs|iidddS(NRiR(RwRR(RwR((R R\scCs\|ii}|oBt|ii|dd}|id|ii |dndS(NiRs.html( RwRt curselectiont selectionRReR!RiRR(RwRRR!((R R_s cCs|ipdSn|ii|ii|ii|ii|_|ii |_ |ii d|i |i f|ii|i |i d|_dS(Ns%dx%di(RwRRRRRRRRRRRRRR(Rw((R tcollapsees     cCs|iodSn|iidddd|iidddd|iiddddd d |iid |i|i f|ii |i |i d |_dS( NRtbottomRRIRtyRtbothRis%dx%d( RwRRRRRRRRRRRR(Rw((R Rps  cCs|i|idS(N(RwRR(RwR((R Rys (RR RWRRURiR8R3RBRRRRRRR(((R Rs E         N(RRtTkRmtguitmainlooptdestroyR:(RmRRR((R Rs   cCs&t|tot|tidjS(Ni(RRIRRbRtsep(RI((R tispathscCsdk}dfdY} tiitid}|tijotii|ntii ddy|itidd\} } d}x| D]\}}|djotdSn|d jot|dSn|d joVyt|}Wntj o | nXd }d } t||| dSn|d jo d}qqW| p | nx| D]}t|o"tii| od|GHPnyt|o#tii|ot|}n|o<t|o!tii|ot|q0t|nti|Wqxt j o}|GHqxXqxWWnY|i"| fj oDtii#tid} d| ti%| | | | ti%fGHnXdS(s@Command-line interface (looks at sys.argv to decide what to do).NtBadUsagecBstZRS(N(RR (((R RsiRisgk:p:ws-gs-ks-pcCsd|iGHdS(Nspydoc server ready at %s(RR(R((R RscCs dGHdS(Nspydoc server stopped((((R tstoppedss-wsfile %r does not existspydoc - the Python documentation tool %s ... Show text documentation on something. may be the name of a Python keyword, topic, function, module, or package, or a dotted reference to a class or function within a module or module in a package. If contains a '%s', it is used as the path to a Python source file to document. If name is 'keywords', 'topics', or 'modules', a listing of these things is displayed. %s -k Search for a keyword in the synopsis lines of all available modules. %s -p Start an HTTP server on the given port on the local machine. %s -g Pop up a graphical interface for finding and serving documentation. %s -w ... Write out the HTML documentation for a module to a file in the current directory. If contains a '%s', it is treated as a filename; if it names a directory, documentation is written for all the contents. (&tgetoptRRRR+Rtargvt scriptdirtremoveRtoptsRtwritingtopttvalRRdRRt ValueErrorRRRtargRRwRYRR RRR3RtR?RRRR(RR?R RRR RRRRRRRR((R tclisb           !   Rz(ORMRRR RRRlRRRzRRQR4RtstringRRbRRRRRRt collectionsRIR RRR"R)R,R1Rt IGNORECASER2R6R:RCRKRURVR\RsR5RtRRRRRRoRpRRRRRRRRRR+RRRRRRRRR3RgReRdRRRR R(CRRoR3R)RRR+RtRQR,R"RRdRRRRbRRR RlRRRRRRRRR1R R6RRIRR\RRRRRRRpReR RzRRRRRgRRKRVRRRRR:RsRRR2RRCRR((R R/#sz? 7            # 26*) O    &       -9 [  Q