o ?Og#@s6dZdgZdZdZdZddlZddlZddlZddl Zddl Zddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZddlmZdd lmZd d Zd d Z ddZ!ddZ"ddZ#ddZ$ddZ%ddZ&ddZ'ddZ(ddZ)d d!Z*e+d"ej,Z-d#d$Z.d%d&Z/d'd(Z0d)d*Z1dd+d,Z2d-d.Z3d/d0Z4d1d2Z5d3d4Z6ifd5d6Z7Gd7d8d8e8Z9d9d:Z:difd;d<Z;Gd=d>d>ZGdCdDdDeZ?GdEdFdFe<Z@GdGdHdHe@ZAdIdJaBdKdLZCdMdNZDdOdPZEdQdRZFdSdTZGdUdVZHdWdXZIdYdZZJdd[d\ZKe@ZLeAZMe>ZNdd]d^ZO  dd`daZP  ddbdcZQddddeZRddgdhZSGdidjdjZTeTZUGdkdldlZVdmdnZWdodpZXddrdsZYddtdudvdwdxZZdydzZ[d{d|Z\d}d~Z]ddZ^e_dkre^dSdS)aGenerate Python documentation in HTML or text for interactive use. At the Python interactive prompt, calling help(thing) on a Python object documents the object, and calling help() starts up an interactive help session. 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 -n " to start an HTTP server with the given hostname (default: localhost) on the local machine. Run "pydoc -p " to start an HTTP server on the given port on the local machine. Port number 0 can be used to get an arbitrary unused port. Run "pydoc -b" to start an HTTP server on an arbitrary unused port and open a web browser to interactively browse documentation. Combine with the -n and -p options to control the hostname and port used. 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 https://docs.python.org/X.Y/library/ 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. helpzKa-Ping Yee z26 February 2001zGuido 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)deque)Repr)format_exception_onlycCs\g}g}tjD]$}tj|pd}tj|}||vr+tj|r+||||q|S)zAConvert sys.path into a list of absolute, existing, unique paths..)syspathosabspathnormcaseisdirappend)dirsZnormdirsdirZnormdirr,/opt/alt/python310/lib64/python3.10/pydoc.pypathdirsRs    rcCst|o t|tj SN)inspectZisclass isinstancetypes GenericAliasobjectrrr_isclass^srcCsNtj|j}|dur dS|jdddD]}t||}qt|s%dS|S)Nr)rmodulesget __module__ __qualname__splitgetattrr)funcclsnamerrr _findclassas r%c Cst|r#|jj}|j}t|rtt||dd|jur|}n|j}nt|r=|j}t |}|dus:t|||urSplit a doc string into a synopsis line (if any) and the rest. rrCN)stripr lenrFjoin)r;linesrrrsplitdocs   rPcCs"|j}|j|kr|jd|}|S)z@Get a class name and qualify it with a module name if necessary.r)r)r)rmodnamer$rrr classnames rRcCs<t|pt|pt|pt|pt|pt| S)z>Check if an object is of a type that probably means it's data.)rismoduler isroutineZisframeZ istracebackZiscoderrrrisdatasrUcGs0|r|d||d}|dd}|s|S)z/Do a series of global replacements on a string.rJrrKN)rNr )textZpairsrrrreplaces  rWcCsXt||kr*td|dd}td|d|}|d|d|t||dS|S)zCOmit part of a string if needed to make it fit in a maximum length.rrKN...)rMmax)rVmaxlenZpreZpostrrrcrams $r\z at 0x[0-9a-f]{6,16}(>+)$cCs td|S)z>Remove the hexadecimal id from a Python object representation.z\1) _re_stripidrErVrrrstripids r_cCs<t|rdSt|rt|dd}t|p|du SdS)zo Returns True if fn is a bound method, regardless of whether fn was implemented in Python or in C. Tr*NF)rr(r-r!rS)fnr8rrr_is_bound_methods   racCs^i}t|tjD]\}}d||<q |jD] }|t|q|D] }t||||<q#|SNrJ)r getmembersrT __bases__update allmethodskeysr!)clmethodskeyvaluer:rrrrfs   rfcCs8g}g}|D]}||r||q||q||fS)zSplit 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)]) r )s predicateZyesZnoxrrr _split_lists  rpcCsX|dvrdS|dr|drdS|drt|drdS|dur&||vS|d S) z3Decide whether to show documentation on a variable.> __builtins__r)r= __loader____path____file__ __cached__ __version__ __package__ __author____date__r'r__spec__ __credits__rr__rJ__fieldsTN) startswithendswithhasattr)r$allr7rrr visiblenames rcCsXg}t|D]"\}}}}t|r d}t|tr |jdur d}|||||fq|S)zCWrap inspect.classify_class_attrs, with fixup for data descriptors.data descriptorNreadonly property)rclassify_class_attrsr0rr.fsetr )rresultsr$kindr#rkrrrr)s rcsZt|dgz fddtDWn tyiYnwfdd}|j|ddS)zGSort the attrs list in-place by _fields and then alphabetically by namer~csi|] \}}||tqSr)rM).0ir$)fieldsrr :z#sort_attributes..cs|dd|dfSNr)r)attr) field_orderrr=sz!sort_attributes..rjN)r! enumeraterAsort)attrsrZkeyfuncr)rrrsort_attributes4s   rcCs:tj|rdD]}tjtj|d|rdSqdS)z3Guess whether a path refers to a package directory.)z.pyz.pyc__init__TF)r rr isfilerN)rextrrr ispackageBs rcCs|}|dddks|s#|}|sn |dddks|r|}|dddkr5|dd}|dddkrk|dd}|dddkrQ|dd}|s`|}|s\n|rU|dd }|Sd}|S) NrJ#zr"""rX"""r\r)readlinerLr )filelinerGrrrsource_synopsisJs$ rc Cs,t|j}||d\}}|dus||kr|ttjjr$tjj }n|ttjj r2tjj }nd}|durazt |}Wn tyIYdSw| t|}Wdn1s[wYn-|d|}tjjd||d}ztj|} WnYdStjd=| jr| jdnd}||f||<|S)z.Get the one-line summary out of a module file.NNNZ__temp__loaderr)r statst_mtimerrtuple importlib machineryBYTECODE_SUFFIXESSourcelessFileLoaderEXTENSION_SUFFIXESExtensionFileLoadertokenizeopenOSErrorrutilspec_from_file_location _bootstrap_loadrrr= splitlines) filenamecachemtimeZ lastupdaterGZ loader_clsrrspecmodulerrrsynopsis[s<        rc@s eZdZdZddZddZdS)ErrorDuringImportzEErrors that occurred while trying to import something to document it.cCs||_|\|_|_|_dSr)rexcrktb)r8rexc_inforrrrszErrorDuringImport.__init__cCs|jj}d|j||jfS)Nzproblem in %s - %s: %s)rr)rrk)r8rrrr__str__szErrorDuringImport.__str__N)r)rrr=rrrrrrrs rc Cstjj}t|d}||t|k}Wdn1swYtj|}tj |\}}|r:tj ||}ntj ||}tjj |||d}ztj|WSt|t)zrzsafeimport..NrrJ)rrbuiltin_module_names __import__rrrt SyntaxErrorr issubclass ImportErrorr$r r!r6) r forceloadrZsubsrjrrrkrinfopartrrr safeimports*     rc@sfeZdZejddejddZd ddZ d ddZ e Z Z Z ZZZed fd d ZdS) Doc PYTHONDOCSz%https://docs.python.org/%d.%d/libraryNrKcGs||f|}z"t|r|j|WSt|r|j|WSt|r'|j|WSWn ty1Ynwt|r<|j |S|j |S)z%Generate documentation for an object.) rrS docmodulerdocclassrT docroutiner6r0docdatadocother)r8rr$argsrrrdocuments   z Doc.documentcGs&d|odt|t|jf}t|)z+Raise an exception for unimplemented types.z.don't know how to document object%s of type %s )reprr?r)rA)r8rr$rmessagerrrfailszDoc.failZstdlibcCszt|}Wn tyd}Ynwtjd|j}tj|}t |t trb|j dvs<| |rb| tj |dsb|j dvrb| drTd|d|j }|Stj ||j d }|Sd }|S) z*Return the location of module docs or None (built-in)r) errno exceptionsZgcZimpmarshalposixsignalr_threadZ zipimportz site-packages)z xml.etreeztest.pydoc_mod)zhttp://zhttps://z {}/{}.html/.htmlN)r getabsfilerAr environrrrr rr?r)rrNformatrFlower)r8rZbasedirrdoclocrrr getdoclocs*     z Doc.getdoclocr)r)rrr rrr version_inforrrrrrr docpropertyr sysconfigZget_pathrrrrrrs   rc@sHeZdZdZddZddZddZdd Zd d ZeZ d d Z eZ dS)HTMLReprzBClass for safely making an HTML representation of a Python object.cC,t|d|_|_d|_d|_|_dSN drrmaxlistmaxtuplemaxdict maxstringmaxotherr8rrrr   zHTMLRepr.__init__cCst|ddddddS)N&z&z>)rWr8rVrrrescapeszHTMLRepr.escapecCs t||Sr)rrr8rrrrr z HTMLRepr.reprcCsZtt|dr ddt|j}t||r t||||S|ttt ||j SNr)repr_r}) rr?rNr)r r!r r\r_rrr8rolevelZ methodnamerrrrepr1s  zHTMLRepr.repr1cCs^t||j}t|}d|vr%dt|ddvr%d|d|||dStdd||S)Nr\\rCrrz-((\\[\\abfnrtv\'"]|\\[0-9]..|\\x..|\\u....)+)z\1)r\rrrWr rDrEr8rortestZtestreprrrr repr_strings zHTMLRepr.repr_stringcCs:z|ttt||jWS|d|jjYSNz <%s instance>)r r\r_rrr+r)r8rorrrr repr_instance*szHTMLRepr.repr_instanceN) r)rrr=rr rrrrepr_strrZ repr_unicoderrrrrs rc@seZdZdZeZejZejZddZd1ddZ  d2d d Z d d Z ddZ d3ddZ ddZddZddZddZddZddZdiiifdd Zd4d!d"Zd5d#d$Zddiifd%d&Zd'd(Zddiiidfd)d*Zd6d+d,ZeZd5d-d.Zd4d/d0ZdS)7HTMLDocz'Formatter class for HTML documentation.cC d||fS)Format an HTML page.z Python: %s %s r)r8titlecontentsrrrpage;sz HTMLDoc.pagerCcCsd|||||pdfS)zFormat a page heading.a'
 
 
%s
%s
 r)r8rfgcolbgcolZextrasrrrheadingEszHTMLDoc.headingNr c Cs^|dur dd|d}d|||f} |r | d||||f} n | d|||f} | d|S) z Format a section with a heading.Nzr zz

zR z( z'
 
%s
%s %s
%s
%s%s%s
r) r8rr!r"rwidthZpreludeZ marginaliaZgaprGrrrsectionPs  zHTMLDoc.sectioncGsd|}|j|g|RS)z$Format a section with a big heading.z%s)r&)r8rrrrr bigsectionfszHTMLDoc.bigsectionc Cs&||}t|dddddddd S)z!Format literal preformatted text. z rr rI
)r  expandtabsrWrrrr preformatks zHTMLDoc.preformatrcCsd}t||d|}t|D],}|dd|}t|||||D]}|t|kr7||||d}q%|d}qd|S)z0Format a list of items into a multi-column list.rCrJzrr)zz7%s
)rMrange)r8listrZcolsrGrowscolrrrr multicolumnqs   zHTMLDoc.multicolumncCsd|S)Nz%srrrrrgrey}sz HTMLDoc.greycGs*|D]}||vrd|||fSq|S)z:Make a link for an identifier, given name-to-URL mappings.%sr)r8r$Zdictsr3rrrnamelinks zHTMLDoc.namelinkcCsN|jtj|j}}t||r"t|||ur"d|j|t||fSt||S)zMake a link for a class.z%s)r)rrrrrr!rR)r8rrQr$rrrr classlinks  zHTMLDoc.classlinkcCsd|j|jfS)zMake a link for a module.%s)r)r rrr modulelinkszHTMLDoc.modulelinkcCsR|\}}}}|r ||S|rd||f}nd|}|r!d|}n|}d||fS)z;Make a link for a module or package to display in an index.z %s.%s.htmlz%s.htmlz"%s (package)r2)r1)r8Z modpkginfor$rrshadowedurlrVrrr modpkglinks    zHTMLDoc.modpkglinkcCr)zMake a link to source file.z%sr)r8r8rrrrfilelink zHTMLDoc.filelinkcCs|p|j}g}d}td} |||} | sn| \} } ||||| | \} } }}}}| rG|| dd}|d||fng|r[dt|}|d||| fnS|rodt|}|d||| fn?|r|| | d d kr|d | ||n'|d |n|| | d d kr|| ||||n || ||| }q||||d d |S)zMark up some plain text, given a context of symbols to look for. Each context dictionary maps object names to anchor names.rzJ\b((http|https|ftp)://\S+[\w/]|RFC[- ]?(\d+)|PEP[- ]?(\d+)|(self\.)?(\w+))T"z"r2z'http://www.rfc-editor.org/rfc/rfc%d.txtz)https://www.python.org/dev/peps/pep-%04d/rJ(zself.zself.%sNrC) r rDcompilesearchspanr groupsrWintr3rN)r8rVr funcsclassesrirherepatternmatchstartendrZschemeZrfcZpepZselfdotr$r8rrrmarkups<       zHTMLDoc.markupc Csd}|D]T}t|tdurE|\}}|d}||||}|r@||fkr@g}|D] } ||| |q)|dd|d}|d}qt|tgurX|d||||}qd |S) zAProduce HTML for a class tree as given by inspect.getclasstree().rCrz"

r=, )z
z
%s
z
%s
)r?r4r rN formattree) r8treerQparentrGentrycbasesparentsr:rrrrMs$ zHTMLDoc.formattreec# s|j}z|j}Wn tyd}Ynw|d}g}tt|dD]}|dd|d|d||fq#d||dd} d| } zt |} t j | } | | } Wn tygd} Ynwg}t|drt|j}|dd d kr|ddd kr|d d}|d |t|d r|t|j|r| dd|} |}|durdt}nd}| ddd| |}t|tj}gi}}t|tD]*\}}|dust|p||ur t|||r |||fd|||<||<q|D]@\}}|jD]7}|j|j}}tj !|}||krJ|rJt||rJt"|||urJ||vrJ|d|||<||<qq gi}}t|tj#D]8\}}|dusqt$|sqt||urt|||r|||fd|||<t%|r||||<qZg}t|t&D]\}}t|||r|||fq't(|j)||}|od|}|d|}t|drg}t*+|j,D]\}}} |||| dfq|-.|j/}!|0ddd|!}n|r.|fdd}!|0d dd|!}|rHd!d"|D}"1t2|"d|g}!|D]\}}|!3|||||q)|0d#dd$d%|!}|rng}!|D]\}}|!3|||||qO|0d&dd'd%|!}|rg}!|D]\}}|!3||qu|0d(dd)d*|!}t|d+r't|j4j)}!|0d,dd|!}t|d-rň't|j5j)}!|0d.dd|!}|S)/z/Produce HTML documentation for a module object.NrrJz5%sr)%srrv $Revision: $z version %sryz (%s)rKz-
Module ReferencerC#ffffff#7799eezindex
rz.html#z#-z %sz

%s

rsrzPackage Contentsz#aa55cccs|dSrb)r6trrrr9z#HTMLDoc.docmodule..ZModulescSg|]\}}|qSrrrrjrkrrrr>z%HTMLDoc.docmodule..ZClasses#ee77aarZ Functionsz#eeaa77ZDataz#55aa55r)rxZAuthorr{ZCredits)6r)__all__r6r r,rMr rNrrurllibparseZquoter:rArr@rvrLr ryrlocalsr#rcrSr getmodulerrdrrrrr!rTr-r,rUrJrHr+pkgutil iter_modulesrsrr0r9r'rM getclasstreerrxr{)#r8rr$modignoredrpartsZlinksrZ linkednameheadrr8r:rversionrrGrrDZcdictrjrkr:rQrrCZfdictdatar;modpkgsimporterispkgr classlistrrrrs                             zHTMLDoc.docmodulec srj}|p|}j}g} | jGfddd} | tt} t| dkrDd| D] } d| j q2dfdd} fd d }fd d }fd dt D}i|D]2\}}}}d|d||<}zt |}Wn t yYnwz||<Wqvt yYqvw|r*| r| n|ddt|fdd\}}tjurшtjur|}qurd}n dj }|d7}t|| d||dd}| d||dd}| d||dd}|d||dd}|d||d d}|d!||d"d}|}|sd#| } ||kr;d$||f}nd%|||f}|r`g}|D] } || j qI|d&d'|}d#}zt}Wntt fywd(}Ynw|rt|}|r|d)kr||d*}t}|r||pd#}|j}|od+|}|d,d-| d.|S)/z.Produce HTML documentation for a class object.c eZdZddZfddZdS)z(HTMLDoc.docclass..HorizontalRulecS d|_dSrZneedonerrrrrh z1HTMLDoc.docclass..HorizontalRule.__init__c|jrdd|_dS)Nz
rJrurpushrrmaybej z.HTMLDoc.docclass..HorizontalRule.maybeNr)rrrrzrrxrrHorizontalRulegr}rKz&
Method resolution order:
z
%s

c st||\}}|rE||D]1\}}}}zt|}Wnty2||Ynw||dq|S)NrIrprzr! Exceptionrrmsgrrnokr$rhomeclsrkrDrChrmdictrirryr8rrspillzs   zHTMLDoc.docclass..spillcJt||\}}|r#||D]\}}}}||q|Srrprzrrrriryr8rrspilldescriptorsz*HTMLDoc.docclass..spilldescriptorsc st||\}}|rM||D]9\}}}}t||}t|} | s0d|nt|j} d| } d|| fdq|S)Nz
%s
z
%sz
%s%s
rI)rprzrr!rHrJr+) rrrnrr$rrrkr:r;rrr spilldatas  z#HTMLDoc.docclass..spilldatac,g|]\}}}}t|dr||||fqS)r7rrr$rr#rkrrrr  z$HTMLDoc.docclass..r-rc |duSNrKrrZ thisclassrrr z"HTMLDoc.docclass.. defined hereinherited from %sz:
z Methods %scS |ddkSNrJmethodrrZrrrrrzClass methods %scSrNrJz class methodrrZrrrrrzStatic methods %scSrNrJz static methodrrZrrrrrzReadonly properties %scSrNrJrrrZrrrrrzData descriptors %scSrNrJrrrZrrrrrzData and other attributes %scSrNrJrnrrZrrrrrrCz*class %sz/%s = class %s(%s)rKN()r(z%s
 
z#000000z#ffc8d8rX)r)rdr rrgetmrorMrzr4rrr!rrApopleftrpbuiltinsrrrN signature ValueErrorr@r rHrJr+r&)r8rr$rirCrDrjrealnamerRrr}mror:rrrrrjrrrkanchor inheritedtagrrSdeclrargspecr;r) rDrCrrrirryr8rrr\s                 # zHTMLDoc.docclasscCs|d||Sz)Format an argument default value as text.=)r1rr rrr formatvaluezHTMLDoc.formatvaluec Cs|j}|p|}|r |jp dd|} d} d} t|rE|jj} |r-| |ur,d|| |} n|jdur=d||jj|} nd|| |} t|sOt|rRd} nd} ||kr_d | |f}n"|rxt||g|urxd |jd||f}d } n|}d | ||f}d}t |rzt |}Wn t t fyd}Ynw|rt |}|d krd|}|d d}|sd}| |||| o|d| }| rd|S|t||j|||}|od|}d||fS)z;Produce HTML documentation for a function or method object.rCrr from N method of %s instance unbound %s methodasync z$%sz%srJz)%s = %sz$%s lambda r(...)z'%sz
%s
z
%s
z
%s
%s
)r)rar*r+r4riscoroutinefunctionisasyncgenfunctiongetattr_staticrTrrrAr@r r1rJrHr+)r8rr$rirCrDrirhrrnoteskipdocsimclassasyncqualifierrZreallinkrrrr;rrrrsp       zHTMLDoc.docroutinecCsNg}|j}|r |d||t||j}|r|d||dd|S)z1Produce html documentation for a data descriptor.z!
%s
z
%s
rrC)r rJrHr+rNr8rr$rirhrryr;rrrrCs   zHTMLDoc.docdatacGs|rd|pd}|||S)z-Produce HTML documentation for a data object.z%s = rCr)r8rr$rirjZlhsrrrrSszHTMLDoc.docothercCsg}|duri}t|gD]\}}}tdd|Drq||d|||vfd||<q||||j}||dd|S)z2Generate an HTML index for a directory of modules.Ncss,|]}dt|kodknVqdS)iiN)ordrZchrrr ]s*z HTMLDoc.index..rCrJrXr`)rfrganyr rr0r9r')r8rr7rorpr$rqrrrrindexXs  z HTMLDoc.indexrC)r$rCNr )rrrNNN)r)rrr=r_repr_instancerr rr#r&r'r+r0r1r3r4r6r9r:rJrMrrrrrrrrrrrrr2s@      + y# A rc@s4eZdZdZddZddZddZeZdd Zd S) TextReprzAClass for safely making a text representation of a Python object.cCrrrrrrrrkrzTextRepr.__init__cCsTtt|dr ddt|j}t||r t||||Sttt||j Sr ) rr?rNr)r r!r\r_rrrrrrrqs  zTextRepr.repr1cCsHt||j}t|}d|vr"dt|ddvr"d|d||dS|S)NrrrCrr)r\rrrWrrrrrxs zTextRepr.repr_stringcCs.z ttt||jWSd|jjYSr)r\r_rrr+r)rrrrrszTextRepr.repr_instanceN) r)rrr=rrrrrrrrrris rc@s~eZdZdZeZejZddZdddZddZ dd d Z dd dZ dddZ ddZ dddZdddZeZdddZd S)TextDocz'Formatter class for text documentation.cCsddd|DS)z(Format a string in bold by overstriking.rCcss|] }|d|VqdS)NrrrrrrszTextDoc.bold..)rNrrrrboldrz TextDoc.bold cs>|sdSfdd|dD}|r|d|d<d|S)z6Indent text by prepending a given prefix to each line.rCcsg|]}|qSrrrrprefixrrrr_z"TextDoc.indent..rIr)r rFrN)r8rVrrOrrrindents zTextDoc.indentcCs$||}||d|dS)z&Format a section with a given heading.rIr()rrFr)r8rrZclean_contentsrrrr&szTextDoc.sectionNrCc sd}|D]I}t|tdur9|\}}||t|}|r4||fkr4fdd|D} |dd| }|d}qt|tgurM|||||d}q|S) zBRender in text a class tree as returned by inspect.getclasstree().rCrc3s|]}t|VqdSrrR)rrQrQrrrz%TextDoc.formattree..rrKrIr)r?rRrNrM) r8rNrQrOrrGrPrQrRrSrrrrMs  zTextDoc.formattreec Cs |j}tt|\}}|d||od|}t|dd}||}|dur0||d|d}|r:||d|}g} t|tD]\} } |dusSt | pP||ur`t | ||r`| | | fqBg} t|tj D]!\} } |dus~t | s~t | |urt | ||r| | | fqjg} t|tD]\} } t | ||r| | | fqg}t}t|drt|jD]\}}}|||r| |d q| |q|||d d |}g}t|tjD]\} } | j|d r| |vr| | q|r|||d d |}| rBdd| D}|t|d|g}| D]\} } | || | |q'||dd |}| rdg}| D]\} } | || | |qI||dd |}| rg}| D]\} } | |j| | |ddqk||dd |}t|drt|j}|dddkr|dddkr|dd}||d|}t|dr||dt|j }t|dr||dt|j!}t|d r||d!t|j"}zt#|}Wn t$yd"}Ynw||d#|}|S)$z5Produce text documentation for a given module object.NAME - raNzMODULE REFERENCEa. The following documentation is automatically generated from the Python source files. It may be incomplete, incorrect or include features that are considered implementation detail and may vary between Python implementations. When in doubt, consult the module reference at the location listed above. Z DESCRIPTIONrs (package)zPACKAGE CONTENTSrIrZ SUBMODULEScSr]rrr^rrrrr_z%TextDoc.docmodule..rJCLASSES FUNCTIONSF)r[ZDATArvrUrVrrWZVERSIONryZDATErxZAUTHORr{ZCREDITSrZFILE)%r)rPrHr&r!rrrcrrerr rTr-rUsetrrfrgrsaddrrNrSrrMrhrrr@rvrLryrxr{rrA)r8rr$riZsynopdescrGrrrDrjrkrCrnroZ modpkgs_namesrprQrqZ submodulesrrrrmrrrrrs                  $   zTextDoc.docmodulec s@j}|p|}j}jfdd}||krd|}n |d|}|r6t||} |dd| }g} | jzt} Wn t t fyOd} Ynw| rdt | } | rd| dkrd|| d t } | rp| d t t}t|d krd |D] }d ||qd tddtDt jd}t|}d}|rЈd|d|D]}d |q||kr̈dt ||dd Gfddd}|fdd}fdd}fdd}fddtD}|r|r|n|dd t|fd d!\}}tjur0tjur0|}qur8d"}nd#tj}t||d$||d%d!}|d&||d'd!}|d(||d)d!}|d*||d+d!}|d,||d-d!}|d.||d/d!}|}|sd | } | s|d S|d | d0d S)1z4Produce text documentation for a given class object.cSs t||Srr)rQrrrrmakenamervz"TextDoc.docclass..makenameclass z = class rrKNrrIrKzMethod resolution order:rrCcss0|]}|jds|jdkrt|jVqdS)r}rN)r)rrr@)rr#rrrrCs  z#TextDoc.docclass..rrzBuilt-in subclasses:z ... and z other subclassescrs)z(TextDoc.docclass..HorizontalRulecSrtrrurrrrrUrvz1TextDoc.docclass..HorizontalRule.__init__crw)NzF----------------------------------------------------------------------rJrurrxrrrzWr{z.TextDoc.docclass..HorizontalRule.maybeNr|rrxrrr}Tr~r}c st||\}}|r>||D]*\}}}}zt|}Wnty2||Yqw||q|Srrrrrirryr8rrr]s zTextDoc.docclass..spillcrrrrrrrrnrz*TextDoc.docclass..spilldescriptorsc st||\}}|rB||D].\}}}}t|}zt|} Wnty2|j|} Ynwj| |d|ddq|S)Nr)r[r;rI)rprzrHr!r6__dict__r) rrrnrr$rrrkr;r7rrrrws z#TextDoc.docclass..spilldatacrrrrrrrrrz$TextDoc.docclass..rcrrrrZrrrrrz"TextDoc.docclass..rrz Methods %s: cSrrrrZrrrrrzClass methods %s: cSrrrrZrrrrrzStatic methods %s: cSrrrrZrrrrrzReadonly properties %s: cSrrrrZrrrrrzData descriptors %s: cSrrrrZrrrrrzData and other attributes %s: cSrrrrZrrrrrz | )r)rdrrmaprNr rrrrAr@rHrrrMsortedr?__subclasses__rrrrprrrRrrrF)r8rr$rirjrrRrrrSrrrr;rr:Z subclassesZno_of_subclassesZMAX_SUBCLASSES_TO_DISPLAYZ subclassnamer}rrrrrrr)rrirryr8rrrs                 #zTextDoc.docclasscCsd||Srrr rrrrzTextDoc.formatvaluec Cs|j}|p|}d}d}t|r7|jj}|r!||ur dt||}n|jdur0dt|jj|}ndt||}t|sAt|rDd} nd} ||krP||} n|r]t ||g|ur]d}||d |} d} t |rzt |} Wn t t fyd} Ynw| rt| } |d kr||d } | dd } | sd } | | | |} |r| dSt|pd}| d|o||dS)z;Produce text documentation for a function or method object.rCrrNrrrrJ = rz lambda rrrI)r)rar*r+rRrrrrrrTrrrAr@rHrrF)r8rr$rirhrrrrrrrrrr;rrrrsX      zTextDoc.docroutinecCsTg}|j}|r||||dt|pd}|r%||||dd|S)z1Produce text documentation for a data descriptor.rIrC)r rrHrrNrrrrrs  zTextDoc.docdatac Cs||}|r#|r |dpd|}|t|} | dkr#|d| d}|r,||dp-d|}|s6t|}|rE|d|t|d7}|S)z-Produce text documentation for a data object.rrCrNrYrI)rrMrrHrr@) r8rr$rirOr[r;rrZchoprrrrs  zTextDoc.docother)r)NrCrr)NNNNN)r)rrr=rrrrrr&rMrrrrrrrrrrrrs     e  7rc@seZdZdZddZdS) _PlainTextDocz2Subclass of TextDoc which overrides string stylingcCs|Srrrrrrr z_PlainTextDoc.boldN)r)rrr=rrrrrr s rcCstat|dS)zCThe first time this is called, determine what kind of pager to use.N)getpagerpagerr^rrrrs rc sDttjdstSttjdstStjrtjstStjdp'tjdrItj dkr5fddStjddvrCfd dSfd dStjddvrStStj dkr\d dSttd rlt d dkrlddSddl }| \}}t |z ttd rt d|dkrddWt|StWt|St|w)z2Decide what method to use for paging through text.isattyZMANPAGERZPAGERwin32ctt|Sr tempfilepagerplainr^Z use_pagerrrr#r\zgetpager..ZTERM)ZdumbZemacscrr) pipepagerrr^rrrr%r\cs t|Srrr^rrrr' cSstt|dS)Nzmore /dev/nullrcS t|dS)NZlessrr^rrrr-rNz more "%s"cSr)NZmorerr^rrrr4r)rrstdin plainpagerstdoutrr rrplatformrtempfileZmkstempcloseunlinkttypager)rfdrrrrrs8          rcCstdd|S)z%Remove boldface formatting from text.z.rC)rDrEr^rrrr:rrc Csddl}|j|d|jdd}z&|j}z||Wn ty#YnwWdn1s.wYWn ty=Ynw z|WdStyOYnwq?)z3Page through text by feeding it to another program.rNTbackslashreplace)shellrerrors) subprocessPopenPIPErwriteKeyboardInterruptrwait)rVcmdrprocpiperrrr>s2    rc Csddl}|B}tj|d}t|ddtjdkrtdndd }| |Wdn1s2wYt |d|d WddS1sMwYdS) z.cSstjddddS)NrrJ)rrrrrrrrrsZLINESrJz -- more --)qQz ) rI)bB)rrr ttyrrfilenoZ tcgetattrZ setcbreakrr6ioUnsupportedOperationrBr rrrrr rNflushZ tcsetattrZ TCSAFLUSH) rVrOrroldZgetcharhrZincrQrrrrgsX             & rcCstjtt|dS)z>Simply print unformatted text. This is the ultimate fallback.N)rrr rrr^rrrrsrcCst|r|jtjvrd|jSt|drd|jSd|jSt|r)d|jSt|r:d|jj |jj|jfSt |rKd|jj |jj|jfSt |rTd|jSt |r^d |jSt |rhd |jSt|jS) z/Produce a short description of the given thing.zbuilt-in module rszpackage zmodule zbuilt-in function zgetset descriptor %s.%s.%szmember descriptor %s.%s.%srz function zmethod )rrSr)rrrr-Zisgetsetdescriptorr1rr2rr,r(r?)thingrrrdescribes2                  r'c Csdd|dD}d\}}|t|kr3td|d|d|}|r,||d}}nn|t|ks|r8|}nt}||dD]}zt||}Wq@tyTYdSw|S)z@Locate an object by name or dotted path, importing as necessary.cSsg|]}|r|qSrr)rrrrrrr_zlocate..rrNrJ)r rMrrNrr!r6)rrrkrnZ nextmodulerrrrrlocates"   r)cCsTt|trt||}|durtd|||fSt|dd}|t|tr'|fSdfS)zDGiven an object or a path to an object, get the object and its name.Nz~No Python documentation found for %r. Use help() to get the interactive help utility. Use help(str) for help on the str class.r))rr@r)rr!)r&rrr$rrrresolves   r* Python Library Documentation: %scCs|durt}t||\}}t|}t|}|r*d|vr*|d|d|d7}n |r7||ur7|d|j7}t|s_t|s_t |s_t |s_t |s_t |drW|j }nt|}|d7}||d|||S)zBRender text documentation, given an object or a path to an object.Nrz in z in module __origin__z objectr()rVr*r'rrerfindr)rSrrTr0rBrr,r?r)r&rrZrendererrr$rrrrr render_docs.     r.c Cslz|durtt|||WdS|t|||tWdSttfy5}z t|WYd}~dSd}~ww)zCDisplay text documentation, given an object or a path to an object.N)rr.r  plaintextrrprint)r&rroutputrkrrrr;sr;c Csz;t||\}}tt|t||}t|dddd }||Wdn1s-wYtd|dWdStt fyT}z t|WYd}~dSd}~ww)zd?d@DZdAdBdCdDgeRdEdFdGdHdIdJdKZdLdMdNdOdPdQdRdSdTdUdVdWdWdXdXdYZeD]\ZZ e D]Z e e eZ ee vre dZeZ e ee <qqid[d\dSd]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxd[dyd[idzd{dPd|d}d~dddddd#ddddddddddddddddddddddidddddddddddddddddddTdddddldddddddodddidddddddddMdddddddÓddœd+dƓddǓdd ddʓdd̓dddd6dd#ddddddԜZ dddׄZ eddلZeddۄZdd݄ZeZefdd߄ZddZddZddZddZdddZddZddZddZdddZdddZddZdddZ dS)HelperFalserCNoneTrueandZBOOLEANaswithassert)r>rCasync)r?rCawait)r@rCbreak)rA while forclass)rCzCLASSES SPECIALMETHODScontinue)rDrBdef)ZfunctionrCdel)rF BASICMETHODSelififelse)rJrBexcepttryfinallyfor)rNzbreak continue whilefromimportglobal)rQznonlocal NAMESPACES)rI TRUTHVALUE)rPMODULESin)rTSEQUENCEMETHODSis COMPARISONlambda)rXrnonlocal)rYzglobal NAMESPACESnotorpass)r\rCraise)r] EXCEPTIONSreturn)r_r)rLr^while)r`zbreak continue if TRUTHVALUE)r=z CONTEXTMANAGERS EXCEPTIONS yieldyield)rarCcCsg|] }dD]}||qqS)'r<r)rprrrrrErzHelper.)rfrurcz'''r<r)+r***rz//%<<>>r|^~rr<=>===!=<>)rrrprqrrrsrt)rro) z+=z-=z*=z/=z%=z&=z|=z^=z<<=z>>=z**=z//=)rkrlrrmrnro)jJ)STRINGS OPERATORSrWUNARYAUGMENTEDASSIGNMENTBITWISECOMPLEXzOPERATORS FORMATTINGZPOWERzTUPLES LISTS FUNCTIONSz ATTRIBUTES FLOAT MODULES OBJECTSELLIPSISzSLICINGS DICTIONARYLITERALSz def classrwZ PRIVATENAMESzPRIVATENAMES SPECIALMETHODSZ BACKQUOTESzTUPLES FUNCTIONS CALLSzLISTS SUBSCRIPTS SLICINGS)rjri,rrY:@rr}r|`r=rL[]rTYPES)rzRSTRINGS UNICODE NUMBERS SEQUENCES MAPPINGS FUNCTIONS CLASSES MODULES FILES inspect)stringsz4str UNICODE SEQUENCES STRINGMETHODS FORMATTING TYPESZ STRINGMETHODS)zstring-methodszSTRINGS FORMATTINGZ FORMATTING)Z formatstringsrxUNICODE)rz:encodings unicode SEQUENCES STRINGMETHODS FORMATTING TYPESZNUMBERS)ZnumberszINTEGER FLOAT COMPLEX TYPESZINTEGER)Zintegersz int rangeZFLOAT)Zfloatingz float mathr|)Z imaginaryz complex cmathZ SEQUENCES)Ztypesseqz$STRINGMETHODS FORMATTING range LISTSZMAPPINGSZ DICTIONARIESr)Ztypesfunctionsz def TYPESZMETHODS)Z typesmethodszclass def CLASSES TYPESZ CODEOBJECTS)zbltin-code-objectszcompile FUNCTIONS TYPESZ TYPEOBJECTS)zbltin-type-objectsz types TYPESZ FRAMEOBJECTSZ TRACEBACKSZNONE)zbltin-null-objectrC)zbltin-ellipsis-objectSLICINGSZSPECIALATTRIBUTES)Z specialattrsrCr)rz!class SPECIALMETHODS PRIVATENAMESrS)Z typesmodulesrPZPACKAGES EXPRESSIONS)zoperator-summaryzlambda or and not in is BOOLEAN COMPARISON BITWISE SHIFTING BINARY FORMATTING POWER UNARY ATTRIBUTES SUBSCRIPTS SLICINGS CALLS TUPLES LISTS DICTIONARIESrxZ PRECEDENCEZOBJECTS)ZobjectsrZSPECIALMETHODS)Z specialnameszbBASICMETHODS ATTRIBUTEMETHODS CALLABLEMETHODS SEQUENCEMETHODS MAPPINGMETHODS NUMBERMETHODS CLASSESrG)Z customizationzhash repr str SPECIALMETHODSZATTRIBUTEMETHODS)zattribute-accesszATTRIBUTES SPECIALMETHODSZCALLABLEMETHODS)zcallable-typeszCALLS SPECIALMETHODSrU)sequence-typesz(SEQUENCES SEQUENCEMETHODS SPECIALMETHODSZMAPPINGMETHODS)rzMAPPINGS SPECIALMETHODS NUMBERMETHODS)z numeric-typesz*NUMBERS AUGMENTEDASSIGNMENT SPECIALMETHODSZ EXECUTION)Z execmodelz%NAMESPACES DYNAMICFEATURES EXCEPTIONSZ NAMESPACES)Znamingz3global nonlocal ASSIGNMENT DELETION DYNAMICFEATURESZDYNAMICFEATURES)zdynamic-featuresrCZSCOPINGZFRAMESr^)rztry except finally raiseZ CONVERSIONS)Z conversionsrCZ IDENTIFIERS)Z identifierszkeywords SPECIALIDENTIFIERSZSPECIALIDENTIFIERS)z id-classesrC)zatom-identifiersrCZLITERALS)z atom-literalsz=STRINGS NUMBERS TUPLELITERALS LISTLITERALS DICTIONARYLITERALSZTUPLESZ TUPLELITERALS)Z exprlistszTUPLES LITERALSZLISTS)ztypesseq-mutable LISTLITERALSr)ZlistszLISTS LITERALS)Z typesmappingDICTIONARYLITERALSr)r3zDICTIONARIES LITERALSZ ATTRIBUTES)zattribute-referencesz(getattr hasattr setattr ATTRIBUTEMETHODSZ SUBSCRIPTS)Z subscriptionsrUr)ZslicingsrUZCALLS)Zcallsr)Zpowerrry)ZunaryrZBINARY)ZbinaryrZSHIFTING)Zshiftingrr{)Zbitwiser)Z comparisonszEXPRESSIONS BASICMETHODS)ZbooleanszEXPRESSIONS TRUTHVALUEZ ASSERTIONZ ASSIGNMENT)Z assignmentrzrz)Z augassignrZDELETIONZ RETURNINGZ IMPORTING)Zcompoundzfor while break continue)truthz if while and or not BASICMETHODS)ZdebuggerZpdb)zcontext-managersr=)Z CONDITIONALZLOOPINGrRZ DEBUGGINGZCONTEXTMANAGERSNcCs||_||_dSr)_input_output)r8inputr1rrrrs zHelper.__init__cC |jptjSr)rrrrrrrrr;z Helper.inputcCrr)rrrrrrrr1r;z Helper.outputcCs2tdddkr|dSd|jj|jjfS)NrJrX?rCz<%s.%s instance>)rstackr+rrrrrr__repr__s zHelper.__repr__cCs8||jur ||dS|||jddS)Na 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. )_GoInteractiverintrointeractr1r r8Zrequestrrr__call__s zHelper.__call__c Cs|jd z |d}|sWdSWn ttfyYdSw|}t|dkrJ|d|dkr8dvrJnn|d|ddvrJ|dd}|d vrRdS|d kr[|n| |q) NrITzhelp> rKrrrbrJ)rquitr) r1r getliner EOFErrorrLrMrrrrrrrrs"  ,   zHelper.interactcCs4|jtjur t|S|j||j|jS)z.Read one line, using input() when appropriate.)rrrr1r r#r)r8promptrrrrs    zHelper.getlinecCs8t|tdur|}|dkr|n|dkr|nv|dkr'|nm|dkr0|nd|dddkrB||dnR||jvrM||nG|d vrYt t |d n;||j vrd| |n0||j vro| |n%|rzt |d |jd nt td |jd nt|tr|nt |d |jd |jd dS) NrCkeywordssymbolstopicsrzmodules rJ)r:r8r9z Help on %s:)r1rI)r?rL listkeywords listsymbols listtopics listmodulesr r showsymbolr;evalr showtopicrrr@rr7r1r rrrrrs$z Helper.helpcCs$|jddtjdddS)Na Welcome to Python {0}'s help utility! If this is your first time using Python, you should definitely check out the tutorial on the internet at https://docs.python.org/{0}/tutorial/. 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, symbols, or topics, type "modules", "keywords", "symbols", or "topics". Each module also comes with a one-line summary of what it does; to list the modules whose name or summary contain a given string such as "spam", type "modules spam". z%d.%drK)r1r rrrrrrrrsz Helper.introrPc Cstt|}||}t||d|}t|D];}t|D].}|||}|t|krL|j||||dkrL|jdd|dt||q|jdqdS)NrJrrI)r-rrMr,r1r ) r8itemscolumnsr%Zcolwr.rowr/rrrrr-%s      $z Helper.listcC |jd||jdS)NzN Here is a list of the Python keywords. Enter any keyword to get more help. )r1r r-rrgrrrrr2 zHelper.listkeywordscCr)Nzx Here is a list of the punctuation symbols which Python assigns special meaning to. Enter any symbol to get more help. )r1r r-rrgrrrrr9s zHelper.listsymbolscCr)NzN Here is a list of available topics. Enter any topic name to get more help. )r1r r-rrgrrrrrArzHelper.listtopicsc Cs*zddl}Wnty|jdYdSw|j||j|}|s0|jdt|dSt|tdur>| ||S|\}}z|jj|}Wnt y^|jdt|YdSw| d}|ro|pjdd|}|rddl }dd |d} || d } |d d | 7}t|dS) Nrt Sorry, topic and keyword documentation is not available because the module "pydoc_data.topics" could not be found. zno documentation found for %s rCrIrRelated help topics: rKHz %s )pydoc_data.topicsrr1r rrrrr?rKeyErrorrLtextwraprNr Zwrapr) r8topic more_xrefs pydoc_datatargetlabelxrefsr;rrVZ wrapped_textrrrrHs8        zHelper.showtopiccCszddl}Wn tyYdSw|j||j|}|s"tdt|tr-|||S|\}}|jj|}|rA|p.callbackcsd|ddSrrrrrronerrorsz#Helper.listmodules..onerrorrz Enter any module name to get more help. Or, type "modules spam" to search for modules whose name or summary contain the string "spam". )r1r rapropos ModuleScannerrunr-rg)r8rjrrrrrrs    zHelper.listmodulesr)rrr)!r)rrrZ _strprefixesZ_symbols_inverserrrZsymbols_rrrrr.rr1rrrrrrrrr-rrrrrrrrrrrr7s       !"#'          !"%&'(*+-./012345679:;<=>?@ABCDEFGHIJKLMNOP W         r7c@seZdZdZdddZdS)rz7An interruptible scanner that searches module synopses.Nc Cs|r|}d|_i}tjD]8}|dkrFd||<|dur#|d|dqt|jp)d}|dd}|d|}||dkrF|d||qtj |dD]\} }} |jrWn|durb|d|dqMzt | |} Wn t ysYqMw| j } t | d rz| |} Wnty|r||YqMwtt| pd}t | d r| |}n-d}n*ztj| }Wnty|r||YqMw|jr|jdnd}t|d d}|d|}||dkr||||qM|r|dSdS) NF__main__rJrCrIrrr get_source get_filenamert)rrrrrr=r rrfr4 _get_specrrrrrrr!StringIOrrrrrrr!)r8rrjZ completerrseenrQr$rrprqrrsourcerrrrrrsj              zModuleScanner.runr)r)rrr=rrrrrrsrcCsZdd}dd}ttdtj|||dWddS1s&wYdS)zAPrint all the one-line module summaries that contain a substring.cSs6|dddkr|ddd}t||od|dSNrrrz- )r0rrQrrrrrszapropos..callbackcSdSrrrrrrrrzapropos..onerrorignorerN)warningscatch_warningsfilterwarningsrr)rjrrrrrrs   "rcsddlddlddlddlGdddjjGfdddjjGfdddj}||||}||j sP|j sPt d |j sP|j rE|S) aAStart an HTTP server thread on a specific port. Start an HTML/text server thread, so HTML or text documents can be browsed dynamically and interactively with a web browser. Example use: >>> import time >>> import pydoc Define a URL handler. To determine what the client is asking for, check the URL and content_type. Then get or generate some text or HTML code and return it. >>> def my_url_handler(url, content_type): ... text = 'the URL sent was: (%s, %s)' % (url, content_type) ... return text Start server thread on port 0. If you use port 0, the server will pick a random port number. You can then use serverthread.port to get the port number. >>> port = 0 >>> serverthread = pydoc._start_server(my_url_handler, port) Check that the server is really started. If it is, open browser and get first page. Use serverthread.url as the starting page. >>> if serverthread.serving: ... import webbrowser The next two lines are commented out so a browser doesn't open if doctest is run on this module. #... webbrowser.open(serverthread.url) #True Let the server do its thing. We just need to monitor its status. Use time.sleep so the loop doesn't hog the CPU. >>> starttime = time.monotonic() >>> timeout = 1 #seconds This is a short timeout for testing purposes. >>> while serverthread.serving: ... time.sleep(.01) ... if serverthread.serving and time.monotonic() - starttime > timeout: ... serverthread.stop() ... break Print any errors that may have occurred. >>> print(serverthread.error) None rNc@seZdZddZddZdS)z!_start_server..DocHandlercSsX|jdr d}nd}|d|dd|||j||j|ddS) zProcess a request from an HTML browser. The URL received is in self.path. Get an HTML page from self.urlhandler and send it. z.csstext/css text/htmlz Content-Typez%s; charset=UTF-8rN) rrZ send_responseZ send_headerZ end_headersZwfiler  urlhandlerr)r8 content_typerrrdo_GET0 s   z(_start_server..DocHandler.do_GETcWrrr)r8rrrr log_message@ sz-_start_server..DocHandler.log_messageN)r)rrrrrrrr DocHandler. s rcs(eZdZddZfddZddZdS)z _start_server..DocServercSs6||_|j|f|_||_|j||j|jd|_dSNF)hostZaddressrr:rhandlerr)r8rportrrrrrF s   z)_start_server..DocServer.__init__csB|js|jgggd\}}}|r||jr|dSrb)rselectZsocketr Zhandle_requestZ server_close)r8ZrdZwrZexrrrserve_until_quitM s  z1_start_server..DocServer.serve_until_quitcSs$|j||jr||dSdSr)r:server_activaterrrrrrT s z0_start_server..DocServer.server_activateN)r)rrrrrrrrr DocServerD s  rcs:eZdZfddZfddZddZddZd S) z#_start_server..ServerThreadcs2||_||_t||_j|d|_d|_dSr)rrrBrThreadrservingerror)r8rrr) threadingrrr[ s    z,_start_server..ServerThread.__init__c szz&jj__jj_t|j_|j |j |j }||_ | WdSty<}z ||_WYd}~dSd}~ww)zStart the server.N)server HTTPServerr:rrZMessageZ MessageClass staticmethodrrrready docserverrrr)r8Zdocsvre)rremailhttprrrc s   z'_start_server..ServerThread.runcSs,d|_|j|_|j|_d|j|jf|_dS)NTz http://%s:%d/)rrZ server_portrr8)r8rrrrrp sz)_start_server..ServerThread.readycSs&d|j_|d|_d|_d|_dS)z&Stop the server and this thread nicelyTNF)rrrNrr8rrrrstopv s  z(_start_server..ServerThread.stopN)r)rrrrrrr)rrrrrrr ServerThreadY s   rg{Gz?) Z http.serverZ email.messagerrrZBaseHTTPRequestHandlerrrrHrrtimesleep)rhostnamerrthreadr)rrrrrrr _start_servers8 '   rrcs,Gfdddt}|fddfddfddfd d fd d fd dfddfddfdd}|drU|dd}|dkrtjtjt}tj||}t|}d| WdS1swYn|dkr||St d||f)aThe pydoc url handler for use with the pydoc server. If the content_type is 'text/css', the _pydoc.css style sheet is read and returned if it exits. If the content_type is 'text/html', then the result of get_html_page(url) is returned. cseZdZfddZdS)z_url_handler.._HTMLDoccsd}d|}d|||fS)rzpydoc_data/_pydoc.cssz1a  Pydoc: %s %s%s
%s
r)r8rrcss_pathZcss_link html_navbarrrr s z#_url_handler.._HTMLDoc.pageN)r)rrrrrrr_HTMLDoc srcs>dttdtf}d|tjddfS)Nz %s [%s, %s]raZ
Python %s
%s
T)Zterse)r rZpython_versionZ python_buildZpython_compiler)rmr2rrr s  z!_url_handler..html_navbarcsdd}ddd}ddtjD}||}|dd dd |g}i}tjD] }|||q*|d d d |fS)zModule Index page.cS d||fSNr5rr$rrr bltinlink r z3_url_handler..html_index..bltinlinkz7Index of ModulesrXrYcSsg|]}|dkr|qS)rr)rr$rrrr sz4_url_handler..html_index..z

zBuilt-in Modulesr`z|

pydoc by Ka-Ping Yee<ping@lfw.org>zIndex of ModulesrC) r#rrr0r'rr rrN)rr#namesrrrrrr html_index s"  z _url_handler..html_indexc sgfdd}ttddd}tj|||dWdn1s)wYdd }g}d d d }D] \}}||||q=|d |d dd|}d|fS)zSearch results page.cs:|dddkr|ddd}||od|fdSrrlrZ search_resultrrr sz3_url_handler..html_search..callbackrcSrrrrrrrr rz2_url_handler..html_search..onerrorrNcSrrrrrrrr r z4_url_handler..html_search..bltinlinkz5Search ResultsrXrYzkey = %sr`
zSearch Results) rrrrrr#r r'rN) rjrrrrr#r$rrrrr html_search s&    z!_url_handler..html_searchcsLdd}ddd}ttj}||}|ddd|}d|fS)zIndex of topic texts available.cSrNz%srrrrrr r z4_url_handler..html_topics..bltinlink,INDEXrXrYZTopicsr`)r#rr7rrgr0r')rr#rrrrr html_topics s z!_url_handler..html_topicscsLddd}ttj}dd}||}|ddd|}d|fS)zIndex of keywords.r rXrYcSrrrrrrrr r z6_url_handler..html_keywords..bltinlinkZKeywordsr`)r#rr7rrgr0r')r#rrrrrr html_keywords s z#_url_handler..html_keywordscst}t||}||\}}||jvrd}nd}d|dd}d|}|dd|}|rLt| }dd } ||} d dd|}d ||fd |||ffS) zTopic or keyword help page.ZKEYWORDZTOPICrTrXrYz

%s
r`cSrrrrrrrr& r z7_url_handler..html_topicpage..bltinlinkrz%s %srC) r!rr7rrr#rJr'rr r0r&rN)rZbufZhtmlhelprrrr#rrrrhtml_topicpage s,     z$_url_handler..html_topicpagecs@t|dd}|dur|dkrtdt|}||}||fS)NrJ)rr9zcould not find object)r)rr'r)r8r7rcontentrrr html_getobj/ s  z!_url_handler..html_getobjcsPddd}dfddtt||D}||dd|}d||fS) Nz,ErrorrXrYrc3s|]}|VqdSr)r rrrrr; rz3_url_handler..html_error..z#bb0000z Error - %s)r#rNrr?r')r8rr#rrrr html_error7 s   z _url_handler..html_errorc s`|}|dr |dd}z|dvr\}}nw|dkr"\}}nm|dkr,\}}ncd|vr|d\}}}|dkrC|\}}nL|d kr_z|\}}Wn?ty^|\}}Yn1w|d kr|dvrm\}}n"z|\}}Wnty|\}}Yn wtd |\}}Wnty}z ||\}}WYd}~nd}~ww||S) zGenerate an HTML page for url.rN)rCrrrrz search?keyz topic?keyzget?keyz bad pydoc url)rrrrr)r8Z complete_urlrr opr}r)r2rrrr rr r rr get_html_pageA sH          z#_url_handler..get_html_pagerrJNrrCrz"unknown content type %r for url %s) rrr rdirnamerealpathrtrNr readlinesrA)r8rrrZ path_hererfpr) r2rrrr rrr r r _url_handler s,          (   "rT localhost) open_browserrc Csddl}tt||}|jrt|jdS|jr|d}|r!||jzMz.td|jt||jrOtd}| }|dkr=n|dkrH||jnt||js0Wnt t fy^tYnwW|jrm| tddSdS|jr{| tdwwdS) zStart the enhanced pydoc web server and open a web browser. Use port '0' to start the server on an arbitrary port. Set open_browser to False to suppress opening a browser. rNz"Server commands: [b]rowser, [q]uitzServer ready atzserver> rrzServer stopped) webbrowserrrrr0rrr8rrr rr)rrrrZ serverthreadZserver_help_msgrrrrbrowsev sD        rcCst|to |tjdkSr)rr@rr sep)rorrrispath srcCsvd|vstj|vst|vrdStjt}tj|}|}||vr1tj||s1||| dt|S)zEnsures current directory is on returned path, and argv0 directory is not Exception: argv0 dir is left alone if it's also pydoc's directory. Returns a new path entry list, or None if no adjustment is needed. rCNr) r curdirgetcwdrrrtcopysamefileremoveinsert)Z given_pathZargv0Z stdlib_dirZ script_dir revised_pathrrr_get_revised_path s    r%cCs0ttjtjd}|dur|tjdd<dSdS)zEnsures current directory is on sys.path, and __main__ directory is not. Exception: __main__ dir is left alone if it's also pydoc's directory. rN)r%rrargv)r$rrr_adjust_cli_sys_path sr'c Csddl}Gdddt}tz|tjddd\}}d}d}d}d}d}|D].\} } | d kr5d }d }| d krAt| WdS| d krId }| }| d krOd }| dkrWd }| }q)|rdt|||dWdS|sh||D]W} t| rtj | st d| WdSz+t| rtj | rt | } |rt| rtj | rt| n t| nt| Wqjty} z t | WYd} ~ qjd} ~ wwWdS|j|fytj tj tjdd} t dj| tjdYdSw)z@Command-line interface (looks at sys.argv to decide what to do).rNc@s eZdZdS)zcli..BadUsageN)r)rrrrrrBadUsage rr(rJzbk:n:p:wFrz-bTz-kz-pz-wz-n)rrzfile %r does not existapydoc - the Python documentation tool {cmd} ... 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 '{sep}', 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. {cmd} -k Search for a keyword in the synopsis lines of all available modules. {cmd} -n Start an HTTP server with the given hostname (default: localhost). {cmd} -p Start an HTTP server on the given port on the local machine. Port number 0 can be used to get an arbitrary unused port. {cmd} -b Start an HTTP server on an arbitrary unused port and open a web browser to interactively browse documentation. This option can be used in combination with -n and/or -p. {cmd} -w ... Write out the HTML documentation for a module to a file in the current directory. If contains a '{sep}', it is treated as a filename; if it names a directory, documentation is written for all the contents. )rr)getoptrr'rr&rrrr rexistsr0rrr r6r3rrrrrrr)r)r(ZoptsrZwritingZ start_serverrrroptvalargrkrrrrcli sl     r.rr)r)r+rN)rCN)r)`r=rarxryr{rZimportlib._bootstraprZimportlib._bootstrap_externalimportlib.machineryimportlib.utilrr!r rfrrDrrrrrZ urllib.parserbr collectionsrreprlibr tracebackrrrr%r<r5rBrHrPrRrUrWr\r> IGNORECASEr]r_rarfrprrrrrrrrrrrrrrrrrrrrrrrrr'r)rVr/r2r*r.r;r3r6r7rrrrrrrr%r'r.r)rrrrs&      3     ' 0:*; " ,    = n% U