
    Rh¹                       d Z dgZdZdZdZddlZddlZddlZddl	Zddl
ZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZ ddlmZ dd	lmZ d
 Zd Z d Z!d Z"d Z#d Z$d Z%d Z&d Z'd Z(d Z)d Z* ejV                  dejX                        Z-d Z.d Z/d Z0d Z1 e2ejf                        Z4dPdZ5d Z6d Z7d Z8d Z9i fd Z: G d! d"e;      Z<d# Z=di fd$Z> G d% d&      Z? G d' d(e      Z@ G d) d*e?      ZA G d+ d,e      ZB G d- d.e?      ZC G d/ d0eC      ZDd1 aEd2 ZFd3 ZGd4 ZHd5 ZId6 ZJd7 ZKd8 ZLd9 ZMdQd:ZN eC       ZO eD       ZP eA       ZQdQd;ZR	 	 dRd<ZS	 	 dSd=ZTdQd>ZUdTd?ZV G d@ dA      ZW eW       ZX G dB dC      ZYdD ZZdE Z[dUdFZ\dQdGdHdIdJZ]dK Z^dL Z_dM Z`dN ZaebdOk(  r ea        yy)Va^  Generate 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 <name>" to show documentation on something.  <name> 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 <keyword>" to search for a keyword in the synopsis lines
of all available modules.

Run "pydoc -n <hostname>" to start an HTTP server with the given
hostname (default: localhost) on the local machine.

Run "pydoc -p <port>" 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 <name>" to write out the HTML documentation for a module
to a file named "<name>.html".

Module docs for core modules are assumed to be in

    /usr/share/doc/pythonX.Y/html/library

if the pythonX.Y-doc package is installed or 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.
helpzKa-Ping Yee <ping@lfw.org>z26 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_onlyc                  J   g } g }t         j                  D ]  }t        j                  j                  |xs d      }t        j                  j	                  |      }||vsJt        j                  j                  |      sj| j                  |       |j                  |        | S )zAConvert sys.path into a list of absolute, existing, unique paths..)syspathosabspathnormcaseisdirappend)dirsnormdirsdirnormdirs       /usr/lib/python3.12/pydoc.pypathdirsr   V   s    DHxx %ggoocjS)''""3'("rww}}S'9KKOOG$% K    c                     t         j                  j                  | j                        }|y | j                  j                  d      d d D ]  }t        ||      } t        j                  |      sy |S )Nr   )	r	   modulesget
__module____qualname__splitgetattrinspectisclass)funcclsnames      r   
_findclassr$   b   sg    
++//$//
*C
{!!'',Sb1 !c4 !??3Jr   c                 ~   t        j                  |       rl| j                  j                  }| j                  }t        j
                  |      r't        t        ||d       d      | j                  u r|}n|j                  }nt        j                  |       r)| j                  }t        |       }|t        ||      | urCy t        j                  |       r\| j                  }| j                  }t        j
                  |      r"|j                  dz   |z   | j                  k(  r|}n|j                  }nt        | t              r4| j                  }|j                  }t        |      }|t        ||      | ury t        j                  |       st        j                   |       rb| j                  }| j"                  }t        ||      | ury t        j$                  |       r't        |dd       }t        |t&              r
||v r||   S y |j(                  D ]  }	 t+        t        ||            }||c S  y # t,        $ r Y -w xY w)N__func__r   	__slots__)r   ismethodr&   __name____self__r    r   	__class__
isfunctionr$   	isbuiltinr   
isinstancepropertyfgetismethoddescriptorisdatadescriptor__objclass__ismemberdescriptordict__mro__
_getowndocAttributeError)objr#   selfr"   r!   slotsbasedocs           r   _finddocr>   l   s   ||$$||OOD!GD$-z:cllJC..C			C	 ||o;'#t,C7			3	||||OOD!#d*c.>.>>C..C	C	"xx}};'#t,C7		#	#C	(G,D,DS,I||3S(%%c*Cd3E%&45=T{" 	WT401C ?J 	  		s   H00	H<;H<c                     	 t         j                  | d      }|y| t        ur+t        |       j                  }t	        |t
              r||k(  ry|S # t        $ r Y yw xY w)zUGet the documentation string for an object if it is not
    inherited from its class.__doc__N)object__getattribute__typer@   r.   strr8   )r9   r=   typedocs      r   r7   r7      sa    
%%c95;d?3i''G'3'GsN
 s   A 2A A 	AAc                     t        |       }|	 t        |       }t	        |t
              syt        j                  |      S # t        t        f$ r Y yw xY w)zGet the documentation string for an object.

    All tabs are expanded to spaces.  To clean up docstrings that are
    indented to line up with blocks of code, any whitespace than can be
    uniformly removed from the second line onwards is removed.N)r7   r>   r8   	TypeErrorr.   rD   r   cleandoc)rA   r=   s     r   _getdocrI      s[     V
C
{	6"C c3C  	 	* 		s   A   AAc                     t        |       xs t        j                  |       }|xr% t        j                  dd|j                               xs dS )z-Get the doc string or comments for an object.z^ *
 )rI   r   getcommentsresubrstrip)rA   results     r   getdocrQ      s>    V_; 3 3F ;F:bffWb&--/:@b@r   c                    | j                         j                  d      }t        |      dk(  r|d   dfS t        |      dk\  r,|d   j                         s|d   dj	                  |dd       fS ddj	                  |      fS )z>Split a doc string into a synopsis line (if any) and the rest.
   r   rK      N)stripr   lenrO   join)r=   liness     r   splitdocrZ      s{    IIKd#E
5zQQx|	Uqq!2Qx59---tyyr   c                 `    | j                   }| j                  |k7  r| j                  dz   |z   }|S )z@Get a class name and qualify it with a module name if necessary.r   )r)   r   rA   modnamer#   s      r   	classnamer^      s3    ??DG#  3&-Kr   c                     d| j                   v rA| j                   j                  d      d   }| j                  |k7  r| j                  dz   |z   S |S | j                  |k7  r| j                  S y)z_Get a name of the enclosing class (qualified it with a module name
    if necessary) or module.r   r   N)r   
rpartitionr   r\   s      r   
parentnamera      su     f!!!""--c215'$$s*T11K'$$$ (r   c                    t        j                  |       xsq t        j                  |       xsZ t        j                  |       xsC t        j                  |       xs, t        j
                  |       xs t        j                  |        S )z>Check if an object is of a type that probably means it's data.)r   ismoduler    	isroutineisframeistracebackiscode)rA   s    r   isdatarh      sy      ( FGOOF,C F!!&)F-4__V-DF##F+F/6~~f/EG Gr   c                 f    |r.|d   j                  | j                  |d               } |dd }|r.| S )z/Do a series of global replacements on a string.rT   r   rU   N)rX   r   )textpairss     r   replacerl      s;    
Qx}}TZZa12ab	  Kr   c                     t        |       |kD  r>t        d|dz
  dz        }t        d|dz
  |z
        }| d| dz   | t        |       |z
  d z   S | S )zCOmit part of a string if needed to make it fit in a maximum length.r      rU   N...)rW   max)rj   maxlenpreposts       r   cramrt      s`    
4y6!fQh]#1fQhsl#DSzE!DT4$999Kr   z at 0x[0-9a-f]{6,16}(>+)$c                 .    t         j                  d|       S )z>Remove the hexadecimal id from a Python object representation.z\1)_re_stripidrN   rj   s    r   stripidrx      s     ??5$''r   c                     t        j                  |       ryt        j                  |       r)t        | dd      }t        j                  |      xs |du  S y)zo
    Returns True if fn is a bound method, regardless of whether
    fn was implemented in Python or in C.
    Tr*   NF)r   r(   r-   r   rc   )fnr:   s     r   _is_bound_methodr{      sQ    
 r:t,$$T*<tt|==r   c                 
   i }t        j                  | t         j                        D ]
  \  }}d||<    | j                  D ]  }|j	                  t        |              |j                         D ]  }t        | |      ||<    |S NrT   )r   
getmembersrd   	__bases__update
allmethodskeysr   )clmethodskeyvaluer<   s        r   r   r     s    G((W->->? 
U )z$'()||~ (r3'(Nr   c                 v    g }g }| D ]-  } ||      r|j                  |       |j                  |       / ||fS )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	predicateyesnoxs        r   _split_listr     sE     C	B Q<JJqMIIaL	
 7Nr   c                 *   | dv ry| j                  d      r| j                  d      ry| j                  d      rt        |d      ry|t        ur.| t        v r&t        t        || d      t        j                        ry	|| |v S | j                  d       S )
z3Decide whether to show documentation on a variable.>   r@   __date____file__r)   __path____spec__r'   
__author__
__cached__
__loader__r   __credits____package____version____builtins__r   r   __rT   __fieldsTNF)
startswithendswithhasattr
__future___future_feature_namesr.   r   _Feature)r#   allr9   s      r   visiblenamer   %  s      H H tt!4QsY 7
*)>!>gc4.
0C0CD
s{??3'''r   c                    g }t        j                  |       D ]d  \  }}}}t        j                  |      r!d}t        |t              r!|j
                  d}n|dk(  rt        |      rd}|j                  ||||f       f |S )zUWrap inspect.classify_class_attrs, with fixup for data descriptors and bound methods.data descriptorreadonly propertymethodstatic method)r   classify_class_attrsr2   r.   r/   fsetr{   r   )rA   resultsr#   kindr"   r   s         r   r   r   =  s    G$+$@$@$H 1 tS%##E*$D%*uzz/A*X"25"9"DdC/01 Nr   c           	          t        |dg       }	 t        |      D ci c]  \  }}||t        |      z
   c}}fd}| j	                  |       yc c}}w # t        $ r i Y +w xY w)zGSort the attrs list in-place by _fields and then alphabetically by namer   c                 8    j                  | d   d      | d   fS Nr   )r   )attrfield_orders    r   <lambda>z!sort_attributes.<locals>.<lambda>S  s    KOODGQ7aA r   r   N)r   	enumeraterW   rG   sort)attrsrA   fieldsir#   keyfuncr   s         @r   sort_attributesr   J  sn     VY+F=Fv=NO	DtaFm+O BG	JJ7J	 P s!   A AA A A'&A'c                     t         j                  j                  |       rIdD ]D  }t         j                  j                  t         j                  j	                  | d|z               sD y y)z3Guess whether a path refers to a package directory.)z.pyz.pyc__init__TF)r   r
   r   isfilerX   )r
   exts     r   	ispackager   X  sM    	ww}}T" 	Cww~~bggll4c1ABC	 r   c                    | j                         }|d d dk(  s|j                         s-| j                         }|sn|d d dk(  r|j                         s-|j                         }|d d dk(  r|dd  }|d d dk(  rj|dd  }|dd  dk(  r|d d }|j                         s$| j                         }|sn|j                         s$|j                  d      d	   j                         }|S d }|S )
NrT   #   zr"""rn   """r   \r   )readlinerV   r   )filelinerP   s      r   source_synopsisr   `  s    ==?D
r(c/}}U r(c/ ::<DBQx6$qr(4BQx5ABx9T#2Yd**,==?D **, E"1%++-M &Mr   c                 t   t        j                  |       j                  }|j                  | d      \  }}|||k  rY| j	                  t        t        j                  j                              rt        j                  j                  }nO| j	                  t        t        j                  j                              rt        j                  j                  }nd}|-	 t        j                  |       }|5  t        |      }ddd       n |d|       }t        j                   j#                  d| |      }	 t        j$                  j'                  |      }	t(        j*                  d= |	j,                  r|	j,                  j/                         d   nd}||f|| <   |S # t        $ r Y yw xY w# 1 sw Y   !xY w#  Y yxY w)z.Get the one-line summary out of a module file.NNN__temp__loaderr   )r   statst_mtimer   r   tuple	importlib	machineryBYTECODE_SUFFIXESSourcelessFileLoaderEXTENSION_SUFFIXESExtensionFileLoadertokenizeopenOSErrorr   utilspec_from_file_location
_bootstrap_loadr	   r   r@   
splitlines)
filenamecachemtime
lastupdaterP   
loader_clsr   r   specmodules
             r   synopsisr   q  s   GGH&&E8\:JZ%/U9#6#6#H#HIJ",,AAJuY%8%8%K%KLM",,@@JJ}}X.
  /(./ /  
H5F>>99*hAG : ID"--33D9 J'7=~~V^^..034F &/hM)  / /s*   F 3F'4F3 	F$#F$'F03F7c                       e Zd ZdZd Zd Zy)ErrorDuringImportzEErrors that occurred while trying to import something to document it.c                    t        |t              sBt        |t              sJ t        |      | _        || _        |j                  | _        || _        y t        j                  dt               |\  | _        | _        | _        || _        y )NzCA tuple value for exc_info is deprecated, use an exception instance)r.   r   BaseExceptionrC   excr   __traceback__tbwarningswarnDeprecationWarningr   )r:   r   exc_infos      r   r   zErrorDuringImport.__init__  ss    (E*h666H~DH!DJ,,DG !	 MM_,. -5)DHdj$' r   c                 l    | j                   j                  }d| j                  d|d| j                  S )Nzproblem in  - z: )r   r)   r   r   )r:   r   s     r   __str__zErrorDuringImport.__str__  s&    hh+/==#tzzJJr   N)r)   r   r   r@   r   r    r   r   r   r     s    O!Kr   r   c                 x   t         j                  j                  }t        | d      5 }||j	                  t        |            k(  }ddd       t        j                  j                  |       }t        j                  j                  |      \  }}r!t         j                  j                  ||       }n t         j                  j                  ||       }t         j                  j                  || |      }	 t         j                  j                  |      S # 1 sw Y   xY w# t         $ r}	t#        | |	      d}	~	ww xY w)z<Import a Python source file or compiled file given its path.rbNr   )r   r   MAGIC_NUMBERr   readrW   r   r
   basenamesplitext_bootstrap_externalr   SourceFileLoaderr   r   r   r   r   )
r
   magicr   is_bytecoder   r#   r   r   r   errs
             r   
importfiler    s    NN''E	dD	 5TtyyU445ww%H  *ID#..CCD$O..??dK>>11$V1LD+##))$//5 5  +c**+s#   D4D D	D9(D44D9c                    	 |r| t         j                  v rv| t         j                  vrdt         j                  D cg c]  }|j                  | dz         s| }}| g|z   D ])  }t         j                  |   ||<   t         j                  |= + t	        j
                  |       }|S c c}w # t        $ r}| t         j                  v r't        t         j                  |    j                  |      t        |      t        u rt        |j                  |      t        |t              r|j                  | k(  rY d}~yt        | |      d}~ww xY w)a  Import a module; handle errors; return None if the module isn't found.

    If the module *is* found but an exception occurs, it's wrapped in an
    ErrorDuringImport exception and reraised.  Unlike __import__, if a
    package path is specified, the module at the end of the path is returned,
    not the package at the beginning.  If the optional 'forceload' argument
    is 1, we reload the module from disk (unless it's a dynamic extension).r   N)r	   r   builtin_module_namesr   r   import_moduler   r   r   rC   SyntaxErrorr   r.   ImportErrorr#   )r
   	forceloadr   msubsr   r   r  s           r   
safeimportr    s   /
 ,3333 $';;Ka!,,tcz2JKK 6D= )C!$S!1E#JC() ((. M) L  /3;;#CKK$5$>$>DD#Y+%#CLL#66[)chh$.> $D#../s6   8B( B#B#A	B( #B( (	E1A?E5EEc                       e Zd Zej                  j                  ddej                  dd z        Zd	dZ	d	dZ
e
xZxZxZxZxZZ ej$                  d      fdZy)
Doc
PYTHONDOCSz%https://docs.python.org/%d.%d/libraryNrU   c                 p   ||f|z   }	 t        j                  |      r | j                  | S t        j                  |      r | j                  | S t        j
                  |      r | j                  | S 	 t        j                  |      r | j                  | S  | j                  | S # t        $ r Y >w xY w)z%Generate documentation for an object.)r   rc   	docmoduler    docclassrd   
docroutiner8   r2   docdatadocother)r:   rA   r#   argss       r   documentzDoc.document  s    ~$
	'0E)Ev&}t}}d/C(C  ($1G*G( ##F+LDLL$4G-Gt}}d##  		s   #B) #B) #B) )	B54B5c                 n    d|xr dt        |      z   dt        |      j                  }t        |      )z+Raise an exception for unimplemented types.z!don't know how to document object z	 of type )reprrC   r)   rG   )r:   rA   r#   r  messages        r   failzDoc.fail  s6     %S4:%%tF|'<'<>  r   stdlibc                 H   	 t        j                  |      }t        j                  j                  d| j                        }t        j                  j                  |      }t        |t        t                    r|j                  dv so|j                  |      r|j                  t        j                  j                  |d            s|j                  t        j                  j                  |d            s|j                  dvr|j                  d      r;dj                  |j                  d	      |j                  j!                               }|S t        j                  j                  ||j                  j!                         d
z         }|S d}|S # t        $ r d}Y w xY w)z*Return the location of module docs or None
(built-in)r  )	errno
exceptionsgcmarshalposixsignalr	   _thread	zipimportzdist-packageszsite-packages)z	xml.etreeztest.test_pydoc.pydoc_mod)zhttp://zhttps://z
{}/{}.html/.htmlN)r   
getabsfilerG   r   environr   r  r
   r   r.   rC   r)   r   rX   formatrO   lower)r:   rA   basedirr   doclocs        r   	getdocloczDoc.getdocloc  sD   	 %%f-D doo>''""7+vtBx(__ !9 9 oog&//"'',,w"HI//"'',,w"HIOO#MM  !89%,,V]]3-?AVAVAXY
  ffoo.C.C.E.OP  F)  	 D	 s   F F! F!N)r)   r   r   r   r+  r   r	   version_infor  r  r  r  r  r  r  docpropertyr  	sysconfigget_pathr0  r   r   r   r  r    so     G"%"2"22A"6!78J$ ! LPOIOO:OO;(:	(:(:8(D r   r  c                   <    e Zd ZdZd Zd Zd Zd Zd ZeZ	d Z
eZy)	HTMLReprzBClass for safely making an HTML representation of a Python object.c                 t    t        j                  |        dx| _        | _        d| _        dx| _        | _        y N   
   d   r   r   maxlistmaxtuplemaxdict	maxstringmaxotherr:   s    r   r   zHTMLRepr.__init__&  1    d'))t}),,r   c           	      $    t        |dddddd      S )N&z&amp;<z&lt;>z&gt;)rl   r:   rj   s     r   escapezHTMLRepr.escape,  s    tS'3VDDr   c                 .    t        j                  | |      S r1  )r   r  r:   rA   s     r   r  zHTMLRepr.repr/  s    yyv&&r   c           	      B   t        t        |      d      rTddj                  t        |      j                  j	                               z   }t        | |      r t        | |      ||      S | j                  t        t        t        |            | j                              S Nr)   repr_r   )r   rC   rX   r)   r   r   rJ  rt   rx   r  rB  r:   r   level
methodnames       r   repr1zHTMLRepr.repr12  sy    47J' 388DG,<,<,B,B,D#EEJtZ(0wtZ0E::{{4Q 0$--@AAr   c                     t        || j                        }t        |      }d|v r/dt        |dd      vr d|d   z   | j	                  |      z   |d   z   S t        j                  dd| j	                  |            S )Nr   \\rK   rr   z-((\\[\\abfnrtv\'"]|\\[0-9]..|\\x..|\\u....)+)z<span class="repr">\1</span>)rt   rA  r  rl   rJ  rM   rN   r:   r   rQ  testtestreprs        r   repr_stringzHTMLRepr.repr_string9  s}    At~~&:4<D%(DD !$t{{4'888A;FFvvF5kk(+- 	-r   c           	          	 | j                  t        t        t        |            | j                              S #  | j                  d|j
                  j                  z        cY S xY wNz<%s instance>)rJ  rt   rx   r  rA  r+   r)   r:   r   rQ  s      r   repr_instancezHTMLRepr.repr_instanceF  sQ    	G;;tGDG$4dnnEFF	G;;1E1EEFFs	   69 *A%N)r)   r   r   r@   r   rJ  r  rS  rZ  repr_strr^  repr_unicoder   r   r   r7  r7  $  s4    L-E'B	- HG Lr   r7  c                      e Zd ZdZ e       Zej                  Zej                  Zd ZddZ		 	 ddZ
d Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zdi i i fdZddZddZddi i fdZd Zddi i i ddfdZddZeZddZddZy)HTMLDocz'Formatter class for HTML documentation.c                     d|d|dS )Format an HTML page.zN<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Python: z</title>
</head><body>
z
</body></html>r   )r:   titlecontentss      r   pagezHTMLDoc.pageW  s     H& 	&r   c                     d|d|xs ddS )zFormat a page heading.zU
<table class="heading">
<tr class="heading-text decor">
<td class="title">&nbsp;<br>z</td>
<td class="extra">&nbsp;z</td></tr></table>
    r   )r:   re  extrass      r   headingzHTMLDoc.headingc  s     &$H$& 	&r   Nc                     |dd|z  z   dz   }d|d|d}|r|d|d|d	|d
|d|dz   }n|d|d|d|dz   }|d|z  z   S )z Format a section with a heading.z<span class="code">ri  z</span>z-<p>
<table class="section">
<tr class="decor zD-decor heading-text">
<td class="section-title" colspan=3>&nbsp;<br>z</td></tr>
    z
<tr><td class="decor z-decor" rowspan=2>z</td>
<td class="decor z-decor" colspan=2>z</td></tr>
<tr><td></td>z-decor">z	</td><td>z.
<td class="singlecolumn">%s</td></tr></table>r   )	r:   re  r"   rf  widthprelude
marginaliagaprP   s	            r   sectionzHTMLDoc.sectionl  s{     .E1AAIMJ
 	
  :sGS: :F
 8;ZN NF IHTTTr   c                 2    d|z  } | j                   |g| S )z$Format a section with a big heading.z&<strong class="bigsection">%s</strong>)rr  )r:   re  r  s      r   
bigsectionzHTMLDoc.bigsection  s"    85@t||E)D))r   c                 f    | j                  |j                               }t        |dddddddd	      S )z!Format literal preformatted text.

z
 
r  ri  rS   <br>
)rJ  
expandtabsrl   rI  s     r   	preformatzHTMLDoc.preformat  s7    {{4??,-tVWfg (D(< 	<r   c                     d}t        |      dz   dz  }t        d      D ]F  }|dz   }t        ||z  ||z  |z         D ]"  }|t        |      k  s| |||         z   dz   }$ |dz   }H d|z  S )z0Format a list of items into a multi-column list.rK   rn   r   z<td class="multicolumn">rw  rm  z<table><tr>%s</tr></table>)rW   range)r:   listr,  rP   rowscolr   s          r   multicolumnzHTMLDoc.multicolumn  s    D	A!#8 	&C88F48T#Xd]3 As4y=#fT!Wo5@FA g%F	& ,f44r   c                     d|z  S )Nz<span class="grey">%s</span>r   rI  s     r   greyzHTMLDoc.grey  s    !?$!FFr   c                 8    |D ]  }||v sd||   d|dc S  |S )z:Make a link for an identifier, given name-to-URL mappings.	<a href=""></a>r   )r:   r#   dictsr5   s       r   namelinkzHTMLDoc.namelink  s0     	BDt|04T
DAA	B r   c           	          |j                   t        j                  j                  |j                        }}t        ||      r.t        ||      |u r d|j                   d|dt        ||      dS t        ||      S )zMake a link for a class.r  .html#r  r  )r)   r	   r   r   r   r   r   r^   )r:   rA   r]   r#   r   s        r   	classlinkzHTMLDoc.classlink  se    8I8I(Jf64 WVT%:f%Dy'AC C))r   c                    d}|j                   t        j                  j                  |j                        }}t        ||      rt        ||      |u rqd|j                  v rE|j                  j                  d      d   }|j                  |k7  r|j                   d|}n$d|z  }n|j                  |k7  rd|j                   z  }|rd|dt        ||      d	S t        ||      S )
z.Make a link for the enclosing class or module.Nr   r   r  z#%s%s.htmlr  r  r  )
r)   r	   r   r   r   r   r   r   r`   ra   )r:   rA   r]   linkr#   r   s         r   
parentlinkzHTMLDoc.parentlink  s    8I8I(Jf64 WVT%:f%Df)))**55c:1=$$/+1??DAD 4<D$$/$v6D,0*VW2MNNfg..r   c                 <    d|j                   d|j                   dS )zMake a link for a module.r  .html">r  )r)   rL  s     r   
modulelinkzHTMLDoc.modulelink  s    -3__fooNNr   c                 |    |\  }}}}|r| j                  |      S |r	|d|d}nd|z  }|rd|z  }n|}d|d|dS )z;Make a link for a module or package to display in an index.r   r)  r  z"<strong>%s</strong>&nbsp;(package)r  r  r  )r  )r:   
modpkginfor#   r
   r   shadowedurlrj   s           r   
modpkglinkzHTMLDoc.modpkglink  sV    *4'dIx99T?""&-Cd"C7$>DD(+T22r   c                     d|d|dS )zMake a link to source file.z<a href="file:r  r  r   )r:   r  r
   s      r   filelinkzHTMLDoc.filelink  s    -0$77r   c                    |xs | j                   }g }d}t        j                  d      }|j                  ||      x}	r|	j	                         \  }
}|j                   ||||
              |	j                         \  }}}}}}|r1 ||      j                  dd      }|j                  d|d|d       n|r-dt        |      z  }|j                  d|d ||      d       n|r-d	t        |      z  }|j                  d|d ||      d       n|rE|||d
z    dk(  r%|j                  d| j                  ||      z          ne|j                  d|z         nP|||d
z    dk(  r$|j                  | j                  ||||             n!|j                  | j                  ||             |}|j                  ||      x}	r|j                   |||d              dj                  |      S )zMark up some plain text, given a context of symbols to look for.
        Each context dictionary maps object names to anchor names.r   zJ\b((http|https|ftp)://\S+[\w/]|RFC[- ]?(\d+)|PEP[- ]?(\d+)|(self\.)?(\w+))"z&quot;r  r  r  z(https://www.rfc-editor.org/rfc/rfc%d.txtz!https://peps.python.org/pep-%04d/rT   (zself.zself.<strong>%s</strong>NrK   )rJ  rM   compilesearchspanr   groupsrl   intr  rX   )r:   rj   rJ  funcsclassesr   r   herepatternmatchstartendr   schemerfcpepselfdotr#   r  s                      r   markupzHTMLDoc.markup  s    &4;;** 3 4 ~~dD11e1JE3NN6$tE"23438<<>0Cc7DSk))#x8SAB@3s8KVC[IJ9CHDVC[IJ CE?c)NN7T]]4-I#IJNN#=#DEc#a%C't}}T7E7KLt}}T7;<D3 ~~dD11e14 	vd45k*+wwwr   c                 t   d}|D ]  }t        |t              rq|\  }}|dz   }|| j                  ||      z   }|rJ||fk7  rDg }|D ]#  }	|j                  | j                  |	|             % |dz   dj	                  |      z   dz   }|dz   }t        |t
              s|d| j                  ||      z  z   } d|z  S )	zAProduce HTML for a class tree as given by inspect.getclasstree().rK   z<dt class="heading-text">r  , )z
</dt>z<dd>
%s</dd>
z<dl>
%s</dl>
)r.   r   r  r   rX   r|  
formattree)
r:   treer]   parentrP   entrycbasesparentsr<   s
             r   r  zHTMLDoc.formattree  s     	'E%' 5"==$..G"<<Uvi/ G % Ft~~dG'DEF#c\DIIg,>>DF)+E4("3doo7A7' #' '	' !6))r   c           
          |j                   }	 |j                  }|j                  d      }g }t	        t        |      dz
        D ]2  }|j                  ddj                  |d|dz          d||   d       4 dj                  ||dd z         }	d|	z  }
	 t        j                  |      }t        j                  j                  |      } j                  ||      }g }t        |d
      r[t!        |j"                        }|dd dk(  r|dd dk(  r|dd j%                         }|j                  d j'                  |      z         t        |d      r3|j                   j'                  t!        |j(                                     |r|
ddj                  |      z  z   }
 j+                  |      }|dt-               z  }nd} j/                  |
d|z   |z         }t        j0                  |t        j2                        }g i }}t        j0                  |t        j4                        D ]Q  \  }}|t        j6                  |      xs ||u s$t9        |||      s2|j                  ||f       d|z   x||<   ||<   S |D ]  \  }}|j:                  D ]s  }|j                   |j<                  }}t>        j@                  jC                  |      }||k7  s@|sCt        ||      sPtE        ||      |u s_||vsd|dz   |z   x||<   ||<   u  g i }}t        j0                  |t        jF                        D ]{  \  }}|-t        jH                  |      st        j6                  |      |u s5t9        |||      sC|j                  ||f       d|z   ||<   t        jJ                  |      st||   ||<   } g }t        j0                  |tL              D ]&  \  }}t9        |||      s|j                  ||f       (  jO                  tQ        |       jR                  ||      }|xr d|z  }|d|z  z   }t        |d      rg }tU        jV                  |jX                        D ]  \  }}} |j                  ||| df        |j[                           j]                  | j^                        }!| ja                  dd|!      z   }n-|r+ j]                  | fd      }!| ja                  dd|!      z   }|r|D cg c]  \  }}|	 }"}} jc                  t        jd                  |"d      |      g}!|D ])  \  }}|!j                   jg                  |||||             + | ja                  d d!d"j                  |!            z   }|rUg }!|D ])  \  }}|!j                   jg                  |||||             + | ja                  d#d$d"j                  |!            z   }|rRg }!|D ]&  \  }}|!j                   jg                  ||             ( | ja                  d%d&d'j                  |!            z   }t        |d(      rE jO                  t!        |jh                         jR                        }!| ja                  d)d*|!      z   }t        |d+      rE jO                  t!        |jj                         jR                        }!| ja                  d,d-|!      z   }|S # t        $ r d}Y w xY w# t        $ r d	}Y w xY wc c}}w ).z/Produce HTML documentation for a module object.Nr   rT   r  z.html" class="white">r  r   !<strong class="title">%s</strong>r  r      $Revision: $z
version %sr   z (%s)r  z-<br><a href="%(docloc)s">Module Reference</a>rK   z<a href=".">index</a><br>r   r  z#-z<span class="code">%s</span>z
<p>%s</p>
r   r   zPackage Contentszpkg-contentc                 ,    j                  | d         S r}   )r  )tr:   s    r   r   z#HTMLDoc.docmodule.<locals>.<lambda>c  s    4??1Q4#8 r   ModulesClassesindexr  	Functions	functionsDatadatarw  r   Authorauthorr   Creditscredits)6r)   __all__r8   r   r{  rW   r   rX   r   r*  urllibparsequoter  rG   r   rD   r   rV   rJ  r   r0  localsrk  r~   rc   r    	getmoduler   r   r   r	   r   r   r   rd   r-   r,   rh   r  rQ   ry  pkgutiliter_modulesr   r   r  r  rt  r  getclasstreer  r   r   )#r:   rA   r#   modignoredr   partslinksr   
linkednameheadr
   r  r  infoversionr/  rP   r   r  cdictr   r   r<   r]   r   r  fdictr  r=   modpkgsimporterispkgrf  	classlists#   `                                  r   r  zHTMLDoc.docmodule  s   	..C 

3s5z!|$ 	3ALL%1+&a23	3 XXeeBCj01
2Z?	$%%f-D,,$$T*C}}S$/H 6=)&,,-Gs|11gbclc6I!"R...0KKt{{7';;<6:&KKC$89:'DIIdO33D'DvxOFFd$?($JV$ST$$VW-=-=>R!,,VW__E 	:JC""5)3V>sC0NNC<003c	9E#Ju	: " 	PJC P#}}dooW1d?v'&#2Fvs+t3"e|7>7IC7OOE#JtP	P 2u!,,VW5F5FG 	LJC!!%(G,=,=e,D,NsC0LL#u.!%E#J))%0s%,	L !,,VV< 	*JC3V,S%L)	* kk&.$..%G:4s:-#--6:&G,3,@,@,Q :('5ua89:LLN''AHdoo"M8= =F''8:Hdoo=(4 4F 3:;<C;I; 4 4Y BDIKH% O
UeS$u MNOdoo7CHHX$68 8FH# O
UeS$u MNOdoo[#((8*<> >FH" ;
UeS 9:;dooh 79 9F6<({{3v'8'8#94>>JHdooh(KKF6=){{3v'9'9#:DNNKHdooiHMMF]  	C	  	$#H	$L <s*   [ A[ *[&[[[#"[#c           
          !" j                   }|xs |}j                  }g }	|	j                  ! G !fdd      }
 |
       t        t	        j
                              }t        |      dkD  rLj                           !d       |D ]'  } !d j                  |j                        z         )  !d        ! fd}! fd} ! fd	}t              D cg c]  \  }}}}t        |
      r||||f }}}}}i  |D ]*  \  }}}}dz   dz   |z   x |<   }	 t        |      }	 | |<   , |r|r|j                         "n|d   d   "t!        |"fd      \  }}t"        j$                  ur"t"        j$                  u r|}V"u rd}nd j                  "j                        z  }|dz  }t'        |        |d|z  |d       } |d|z  |d       } |d|z  |d       } |d|z  |d       } |d|z  |d       } |d|z  |d       }|g k(  sJ |}|rdj)                  |	      }	|k(  r
d|d |d!}nd"|d#|d$|d%}|rKg }|D ]-  }|j                   j                  |j                               / |d&d'j)                  |      z  z   }d}	 t	        j*                        }|r)t/        |      }|r|d)k7  r| j1                  |      z   d*z   }t3              }|r	||xs dz   } j5                  | j6                         }|xr d+|z  } j9                  |d,|	d-|      S c c}}}}w # t        $ r Y w xY w# t        $ r Y Mw xY w# t,        t        f$ r d(}Y w xY w).z.Produce HTML documentation for a class object.c                       e Zd Zd Z fdZy)(HTMLDoc.docclass.<locals>.HorizontalRulec                     d| _         y r   needonerC  s    r   r   z1HTMLDoc.docclass.<locals>.HorizontalRule.__init__  	     r   c                 <    | j                   r d       d| _         y )Nz<hr>
rT   r  r:   pushs    r   maybez.HTMLDoc.docclass.<locals>.HorizontalRule.maybe      <<N r   Nr)   r   r   r   r  r  s   r   HorizontalRuler        !!r   r  rU   z&<dl><dt>Method resolution order:</dt>
z<dd>%s</dd>
</dl>
c                 (   t        ||      \  }}|rW
j                           |        |D ]:  \  }}}}	 t        |      } j                  ||	|              d       < |S # t        $ r  j                  ||             Y 0w xY w)NrS   r   r  r   r  	Exceptionr  )msgr   r   okr#   r   homeclsr   r  r  hrmdictr  rA   r  r:   s           r   spillzHTMLDoc.docclass.<locals>.spill  s    #E95IB
S	24 
.D$Q ' 5 T]]5$(-wvwP QJ
 L % = T\\%s;<=s   A,,"BBc                     t        ||      \  }}|r=j                           
|        |D ]   \  }}}} 
j                  ||	             " |S r1  r   r  r  r  r   r   r  r#   r   r  r   r  r  r  r:   s           r   spilldescriptorsz*HTMLDoc.docclass.<locals>.spilldescriptors  X    #E95IB
S	24 9.D$eT3789Lr   c                 d   t        ||      \  }}|rj                           |        |D ]  \  }}}}j                  t        |      |      }t	        |      }	|	s d|z         n;j                  t	        |      j                  
      }	d|	z  }	 d||	d        d        |S )Nz<dl><dt>%s</dl>
z <dd><span class="code">%s</span><dl><dt>r  rS   )r   r  r  r   rQ   r  ry  )r  r   r   r  r#   r   r  r   r<   r=   r  r  r  r  r  rA   r  r:   s             r   	spilldataz#HTMLDoc.docclass.<locals>.spilldata  s    #E95IB
S	24 
.D$==)>cJD -C0478"kk&-*/%A@3FdC@AJ
 Lr   r9   r   -r   c                     | d   u S NrU   r   r  	thisclasss    r   r   z"HTMLDoc.docclass.<locals>.<lambda>      AaDI<M r   defined hereinherited from %sz:<br>
z
Methods %sc                     | d   dk(  S NrT   r   r   r  s    r   r   z"HTMLDoc.docclass.<locals>.<lambda>      AaDH$4 r   zClass methods %sc                     | d   dk(  S NrT   zclass methodr   r  s    r   r   z"HTMLDoc.docclass.<locals>.<lambda>      AaDN$: r   zStatic methods %sc                     | d   dk(  S NrT   r   r   r  s    r   r   z"HTMLDoc.docclass.<locals>.<lambda>      AaDO$; r   zReadonly properties %sc                     | d   dk(  S NrT   r   r   r  s    r   r   z"HTMLDoc.docclass.<locals>.<lambda>      qt7J/J r   zData descriptors %sc                     | d   dk(  S NrT   r   r   r  s    r   r   z"HTMLDoc.docclass.<locals>.<lambda>       qt7H/H r   zData and other attributes %sc                     | d   dk(  S NrT   r  r   r  s    r   r   z"HTMLDoc.docclass.<locals>.<lambda>      ! r   rK   	<a name="z">class <strong></strong></a>z<strong>z</strong> = <a name="z">class r  (%s)r  N()rv  z&<span class="code">%s<br>&nbsp;</span>re  rn   )r)   r   r   r   r   getmrorW   r  r  r   r   r   r   r  rG   popleftr   builtinsrA   r   rX   	signature
ValueErrorrD   rJ  rQ   r  ry  rr  )#r:   rA   r#   r  r  r  r  realnamer  rf  r  mror<   r  r  r  r   r"   r   r   r   r  anchor	inheritedtagre  r  declr%  argspecr=   r  r  r  r  s#   `` ```                         @@@@r   r  zHTMLDoc.docclass  s"    ??x  	! 	!  GNN6*+s8a<HHJ:; J_t~~d6<6G6G(I I JJ O	 	$		 	& 0DF/K3 3+T4e&1 c5) 3 3 ). 	%Cw"%*s"2S"88E#J-
  &e	 KKM	!!HQK	*52MNE9X__,hoo1M!f$$)DNN9;A;L;L-N N9CE6* ,,e46E,s2E:<E-3U;=E$%=%CU%JLE$%:S%@%%HJE<sBE68EB;;EC F 778$8h E 
 dH&EG Ht~~dF4E4EFGHFTYYw%777E	))&1I )nG7d?dkk'22V;Vn#)$Ckk#t~~uguED>D||E7Ha==k3     n I& 	I	s<   1M
2M
?M/M* 
	MM	M'&M'*M>=M>c                 H    | j                  d| j                  |      z         S z)Format an argument default value as text.=)r  r  rL  s     r   formatvaluezHTMLDoc.formatvalue&  s    yytyy0011r   c	                     |j                   }	|xs |	}||}|dn|j                   dz   |z   }
d}d}d}t        |      ri|j                  }||u rt        |dd      }nt	        j
                  |      rd| j                  ||      z  }nd| j                  |j                  |      z  }nkt	        j                  |      st	        j                  |      r?	 |j                  }|d| j                  ||      z  }n||urd	| j                  ||      z   }n|}t	        j                  |      rS|Q|j                  |j                  k7  s|j                  |j                  d
z   |	z   k7  r| j                  ||      }|rd|z  }t	        j                   |      st	        j"                  |      rd}nd}||	k(  r
d|
d|	d}nW|Ht	        j$                  ||	g       |u r/d|j                   dz   |	z   d|	d}d}|j'                  d	      rd}n|	}d|
d|d|}d}t	        j(                  |      r>	 t	        j*                  |      }|r&t1        |      }|	dk(  rd|z  }|j2                  s|dd }|sd}||z   | j5                  |      z   |xr | j7                  d|z        z   }|rd|z  S | j9                  t;        |      | j<                  |||      }|xr d|z  }d|d|dS # t        $ r Y w xY w# t,        t.        f$ r d}Y w xY w) z;Produce HTML documentation for a function or method object.NrK   r  Fr&    class method of %s method of %s instance unbound %s method from r    from %sasync r  z
"><strong>r  z
<a href="#r  r  Tz</strong></a> = <lambda>z$<strong>%s</strong> <em>lambda</em> rT   r   (...)z$<span class="heading-text">%s</span>z<dl><dt>%s</dt></dl>
z%<dd><span class="code">%s</span></dd>r   z</dt>r  )r)   r{   r*   r   r   r    r  r+   r1   ismethodwrapperr3   r8   r,   r   r   r  iscoroutinefunctionisasyncgenfunctiongetattr_staticr   rd   r%  r&  rG   rD   __annotations__rJ  r  r  rQ   ry  )r:   rA   r#   r  r  r  r   r   r  r'  r)  noteskipdocsimfuncimselfobjclasspnameasyncqualifierre  reallinkr-  r%  r,  r=   s                           r   r  zHTMLDoc.docroutine*  s1    ??x?G
"s:TAF#__F| T:(,t~~fc/JJ/$..$$c3+ +((0%%f-D!.. :/$..32OODW,#dnnXs&CCDFf%'*=!3!337#7#7##=#HHOOFC0E!E)''/**62%NN8>DhOE&&r8R8FBKK#%0(<??8,D#h(EV$!#--f5	 i.z)BTIE "11")!B-G%G(<< AHyy?$FGI +d22++vwICGACGC15s;; " P 	* ! 	!s$   K 'K) 	K&%K&)K=<K=c                     g }|j                   }|r |d|z         | j                  t        |      | j                        }|r |d|z          |d       dj	                  |      S )z1Produce html documentation for a data descriptor.z!<dl><dt><strong>%s</strong></dt>
z&<dd><span class="code">%s</span></dd>
r  rK   )r   r  rQ   ry  rX   	r:   rA   r#   r  r   r  r   r  r=   s	            r   r  zHTMLDoc.docdata  s`    ~~5<=kk&.$..9:S@AYwwwr   c                 D    |xr d|z  xs d}|| j                  |      z   S )z-Produce HTML documentation for a data object.z<strong>%s</strong> = rK   r  )r:   rA   r#   r  r  lhss         r   r  zHTMLDoc.docother  s+    6/$6<"TYYv&&&r   c                 (   g }|i }t        j                  |g      D ]5  \  }}}t        d |D              r|j                  |d|||v f       d||<   7 |j	                          | j                  || j                        }| j                  |d|      S )z2Generate an HTML index for a directory of modules.c              3   N   K   | ]  }d t        |      cxk  xr dk  nc   yw)i   i  N)ord.0chs     r   	<genexpr>z HTMLDoc.index.<locals>.<genexpr>  s!     @RFc"g///@s   #%rK   rT   r  )r  r  anyr   r   r  r  rt  )r:   r   r  r  r  r#   r  rf  s           r   r  zHTMLDoc.index  s    X%,%9%93%%@ 	!HdE@4@@NND"eTX-=>?HTN	 	##GT__=sGX66r   rK   )   rK   Nri  r1  r   NNN)r)   r   r   r@   r7  _repr_instancer  rJ  rg  rk  rr  rt  ry  r  r  r  r  r  r  r  r  r  r  r  r  r1  r  r  r3  r  r  r   r   r   rb  rb  N  s    1 ZND""F
&& 3419U**
<
5 G*/&O38 #'b"b % R*&sj %)d"b `>D2 '+RdW<r  K'
7r   rb  c                   ,    e Zd ZdZd Zd Zd ZeZd Zy)TextReprzAClass for safely making a text representation of a Python object.c                 t    t        j                  |        dx| _        | _        d| _        dx| _        | _        y r9  r=  rC  s    r   r   zTextRepr.__init__  rD  r   c                 $   t        t        |      d      rTddj                  t        |      j                  j	                               z   }t        | |      r t        | |      ||      S t        t        t        |            | j                        S rN  )
r   rC   rX   r)   r   r   rt   rx   r  rB  rP  s       r   rS  zTextRepr.repr1  sp    47J' 388DG,<,<,B,B,D#EEJtZ(0wtZ0E::GDG$dmm44r   c                     t        || j                        }t        |      }d|v r dt        |dd      vrd|d   z   |z   |d   z   S |S )Nr   rU  rK   rV  r   )rt   rA  r  rl   rW  s        r   rZ  zTextRepr.repr_string  sV    At~~&:4<D%(DD !$t+hqk99r   c                     	 t        t        t        |            | j                        S #  d|j                  j
                  z  cY S xY wr\  )rt   rx   r  rA  r+   r)   r]  s      r   r^  zTextRepr.repr_instance  s=    	:Q($..99	:"Q[[%9%999s	   '* AN)	r)   r   r   r@   r   rS  rZ  r_  r^  r   r   r   rZ  rZ    s     K-5 H:r   rZ  c                       e Zd ZdZ e       Zej                  Zd ZddZd Z	ddZ
ddZddZd	 Zdd
ZddZeZdddddZy)TextDocz'Formatter class for text documentation.c                 2    dj                  d |D              S )z(Format a string in bold by overstriking.rK   c              3   ,   K   | ]  }|d z   |z     yw)Nr   rP  s     r   rS  zTextDoc.bold.<locals>.<genexpr>  s     5"rDy2~5s   )rX   rI  s     r   boldzTextDoc.bold  s    ww5555r   c                     |sy|j                  d      D cg c]  }||z   j                          }}dj                  |      S c c}w )z6Indent text by prepending a given prefix to each line.rK   rS   )r   rO   rX   )r:   rj   prefixr   rY   s        r   indentzTextDoc.indent  sE    B6:jj6FGd&4-'')GGyy Hs   Ac                 t    | j                  |      j                         }| j                  |      dz   |z   dz   S )z&Format a section with a given heading.rS   rv  )rg  rO   rd  )r:   re  rf  clean_contentss       r   rr  zTextDoc.section  s7    X.557yy$&7&@@r   Nc           	         d}|D ]  }t        |t              rG|\  }}||z   t        |      z   }|r(||fk7  r"fd|D        }	|ddj                  |	      z  z   }|dz   }Zt        |t              sk|| j                  ||dz         z   } |S )zBRender in text a class tree as returned by inspect.getclasstree().rK   c              3   6   K   | ]  }t        |        y wr1  r^   )rQ  r  r]   s     r   rS  z%TextDoc.formattree.<locals>.<genexpr>  s     DyG4Ds   r   r  rS       )r.   r   r^   rX   r|  r  )
r:   r  r]   r  rf  rP   r  r  r  r  s
     `       r   r  zTextDoc.formattree  s     
	8E%' 5&9Q+@@Uvi/DeDG#ftyy/A&AAF$E4($//7Av#8 8
	8 r   c           	      
   |j                   }t        t        |            \  }}| j                  d||xr d|z   z         }t	        |dd      }| j                  |      }	|	|| j                  d|	dz         z   }|r|| j                  d|      z   }g }
t        j                  |t        j                        D ]D  \  }}|t        j                  |      xs ||u s$t        |||      s2|
j                  ||f       F g }t        j                  |t        j                        D ]U  \  }}|-t        j                  |      st        j                  |      |u s5t        |||      sC|j                  ||f       W g }t        j                  |t              D ]&  \  }}t        |||      s|j                  ||f       ( g }t               }t!        |d      rt#        j$                  |j&                        D ]?  \  }}}|j)                  |       |r|j                  |d	z          /|j                  |       A |j+                          || j                  d
dj-                  |            z   }g }t        j                  |t        j.                        D ]:  \  }}|j                   j1                  |dz         s%||vs*|j                  |       < |r4|j+                          || j                  ddj-                  |            z   }|
r|
D cg c]  \  }}|	 }}}| j3                  t        j4                  |d      |      g}|
D ]'  \  }}|j                  | j7                  |||             ) || j                  ddj-                  |            z   }|rRg }|D ]'  \  }}|j                  | j7                  |||             ) || j                  ddj-                  |            z   }|rTg }|D ])  \  }}|j                  | j9                  |||d             + || j                  ddj-                  |            z   }t!        |d      rMt;        |j<                        }|dd dk(  r|dd dk(  r|dd j?                         }|| j                  d|      z   }t!        |d      r(|| j                  dt;        |j@                              z   }t!        |d      r(|| j                  dt;        |jB                              z   }t!        |d      r(|| j                  dt;        |jD                              z   }	 t        jF                  |      }|| j                  d!|      z   }|S c c}}w # tH        $ r d }Y *w xY w)"z5Produce text documentation for a given module object.NAMEr   r  NzMODULE 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.
DESCRIPTIONr   
 (package)zPACKAGE CONTENTSrS   r   
SUBMODULESrT   CLASSES	FUNCTIONSF   )rq   DATAr   r  r  r   r  VERSIONr   DATEr   AUTHORr   CREDITSr  FILE)%r)   rZ   rQ   rr  r   r0  r   r~   r    r  r   r   rd   r-   rh   setr   r  r  r   addr   rX   rc   r   r  r  r  r  rD   r   rV   r   r   r   r*  rG   )r:   rA   r#   r  r  synopdescrP   r   r/  r  r   r   r  r  r  modpkgs_namesr  r]   r  
submodulesr  rf  r  r   s                            r   r  zTextDoc.docmodule  s5   vf~.tfde.E&FGfi.'dll+=v I @  F dll=$??F!,,VW__E 	1JC%%e,66AsC0NNC<0	1 !,,VW5F5FG 	/JC!!%(G,=,=e,D,NsC0LL#u.	/ !,,VV< 	*JC3V,S%L)	* 6:&,3,@,@,Q ,('5!!'*NN7\#9:NN7+, LLNdll"DIIg$68 8F 
!,,VW5E5EF 	'JC~~((4M9Q!!#&	' OOdlldii
35 5F 189:39I9$$Y2D: ;H% A
UeS$ ?@Adll9dii6IJJFH# A
UeS$ ?@Adll;		(8KLLFH" L
UeS$r JKLdll6499X3FGGF6=)&,,-Gs|11gbclc6I!"R...0dll9g>>F6:&dll63v3GHHF6<(dll8S9J9J5KLLF6=)dll9c&:L:L6MNNF	 %%f-D $,,vt44G :@  	 D	 s   U2U$ $U21U2c           
           j                   }|xs |}j                  }j                  fd}||k(  rd j                  |      z   }n j                  |      dz   |z   }|r#t	        ||      }	|ddj                  |	      z  z   }g }
|
j                  	 t        j                        }|r t        |      }|r|dk7  r ||z   dz          t              }|r |dz          t        t        j                              }t        |      d	kD  r( d
       |D ]  } d ||      z            d       t!        d t"        j%                        D        t        j&                        }t        |      }d}|rD d       |d| D ]  } d|z           ||kD  r dt        ||z
        z   dz           d        G fdd      } |        fd} fd} fd}t)              D cg c]  \  }}}}t+        |      r||||f }}}}}|r|r|j-                          n|d   d	    t/        | fd      \  }}t0        j2                  ur t0        j2                  u r|}V u rd}ndt5         j                        z  }t7        |        |d|z  |d       } |d|z  |d        } |d!|z  |d"       } |d#|z  |d$       } |d%|z  |d&       } |d'|z  |d(       }|g k(  sJ |}|rdj                  |
      }
|
s|dz   S |dz    j9                  |
j;                         d)      z   dz   S # t        t        f$ r d}Y w xY wc c}}}}w )*z4Produce text documentation for a given class object.c                     t        | |      S r1  rl  )r  r
  s     r   makenamez"TextDoc.docclass.<locals>.makename]  s    Q?"r   class z	 = class r   r  Nr!  rS   rU   zMethod resolution order:rm  rK   c              3      K   | ]C  }|j                   j                  d       s&|j                  dk(  rt        |j                          E yw)r   r$  N)r)   r   r   rD   )rQ  r"   s     r   rS  z#TextDoc.docclass.<locals>.<genexpr>  s?      S3LL++C0S^^z5Q  Ss   A	Ar   r   zBuilt-in subclasses:z    ... and z other subclassesc                       e Zd Zd Z fdZy)(TextDoc.docclass.<locals>.HorizontalRulec                     d| _         y r   r  rC  s    r   r   z1TextDoc.docclass.<locals>.HorizontalRule.__init__  r  r   c                 <    | j                   r d       d| _         y )NzF----------------------------------------------------------------------rT   r  r  s    r   r  z.TextDoc.docclass.<locals>.HorizontalRule.maybe  r  r   Nr  r  s   r   r  r    r  r   r  c           
         t        ||      \  }}|rLj                           |        |D ]/  \  }}}}	 t        
|      } j                  ||	
|             1 |S # t        $ r  j                  ||	             Y Xw xY wr1  r  )r  r   r   r  r#   r   r  r   r  r  rA   r  r:   s           r   r  zTextDoc.docclass.<locals>.spill  s    #E95IB
S	24 	E.D$E ' 5 T]]5(,c67D E	E L % = T\\%s;<=s   A!!"BBc                     t        ||      \  }}|r=j                           
|        |D ]   \  }}}} 
j                  ||	             " |S r1  r  r  s           r   r  z*TextDoc.docclass.<locals>.spilldescriptors  r  r   c           
         t        ||      \  }}|r[
j                           |        |D ]>  \  }}}}t        |      }	 t        |      }	 j                  |	|d|      dz          @ |S # t        $ r |j
                  |   }	Y =w xY w)Nru  rq   r=   rS   )r   r  rQ   r   r8   __dict__r  )r  r   r   r  r#   r   r  r   r=   r9   r  r  rA   r  r:   s             r   r  z#TextDoc.docclass.<locals>.spilldata  s    #E95IB
S	24 .D$ -C5%fd3 sD#bcJ  L	 * 5%..t45s   A00B
Br  r   c                     | d   u S r  r   r  s    r   r   z"TextDoc.docclass.<locals>.<lambda>  r  r   r	  r
  zMethods %s:
c                     | d   dk(  S r  r   r  s    r   r   z"TextDoc.docclass.<locals>.<lambda>  r  r   zClass methods %s:
c                     | d   dk(  S r  r   r  s    r   r   z"TextDoc.docclass.<locals>.<lambda>  r  r   zStatic methods %s:
c                     | d   dk(  S r  r   r  s    r   r   z"TextDoc.docclass.<locals>.<lambda>  r  r   zReadonly properties %s:
c                     | d   dk(  S r  r   r  s    r   r   z"TextDoc.docclass.<locals>.<lambda>  r  r   zData descriptors %s:
c                     | d   dk(  S r  r   r  s    r   r   z"TextDoc.docclass.<locals>.<lambda>  r  r   zData and other attributes %s:
c                     | d   dk(  S r  r   r  s    r   r   z"TextDoc.docclass.<locals>.<lambda>  r  r   z |  )r)   r   r   rd  maprX   r   r   r%  r&  rG   rD   rQ   r   r"  rW   sortedrC   __subclasses__r-  r   r   r#  r   r$  rA   r^   r   rg  rO   )!r:   rA   r#   r  r  r'  r  r  re  r  rf  r%  r-  r=   r(  r<   
subclassesno_of_subclassesMAX_SUBCLASSES_TO_DISPLAYsubclassnamer  r  r  r  r   r"   r   r   r*  r+  r  r  r  s!   `` `                          @@@r   r  zTextDoc.docclassW  s   ??x   ++ 	# 8tyy22EIIdOk1H<E(E*GFTYYw%777E	))&1I )nG7d?TG^d*+Vnt GNN6*+s8a<+, .Vhtn,-.H S$*=*=f*E S		


 z?$%!'( *+E,E F ,Vl*+,";;^),EEFG() * H	! 	! 	 	"		 	  0DF/K3 3+T4e&1 c5) 3 3 KKM	!!HQK	*52MNE9X__,hoo1M!f$$)Ii6<6G6G-I I E6* /C/46E/#5u:<E036;=E$%@3%F%JLE$%=%CU%HJE?#Eu68E B;;EC F 99X&4<t|dkk(//*;VDDtKKE I& 	I	p3s   M M 
MMc                 *    d| j                  |      z   S r/  rK  rL  s     r   r1  zTextDoc.formatvalue  s    TYYv&&&r   c                 ^   |j                   }|xs |}||}d}d}d}	t        |      r]|j                  }
|
|u rt        |dd      }	nt	        j
                  |
      rdt        |
|      z  }nydt        |
j                  |      z  }n_t	        j                  |      st	        j                  |      r3	 |j                  }|dt        ||      z  }n||urdt        ||      z   }n|}	t	        j                  |	      rM|K|	j                  |j                  k7  s|	j                  |j                  d	z   |z   k7  rt        |	|      }|rd
|z  }t	        j                   |      st	        j"                  |      rd}nd}||k(  r| j%                  |      }nG|.t	        j&                  ||g       |u rd}|j)                  d      rd}| j%                  |      dz   |z   }d}t	        j*                  |      rM	 t	        j,                  |      }|r5t3        |      }|dk(  r%| j%                  |      dz   }|j4                  s|dd }|sd}||z   |z   |z   }|r|dz   S t7        |      xs d}|dz   |xr" | j9                  |      j;                         dz   z   S # t        $ r Y w xY w# t.        t0        f$ r d}Y w xY w)z;Produce text documentation for a function or method object.NrK   Fr&   r3  r4  r5  r6  r   r7  r8  T = r9  z lambda rT   r   r:  rS   )r)   r{   r*   r   r   r    r^   r+   r1   r;  r3   r8   r,   r   r   ra   r<  r=  rd  r>  r   rd   r%  r&  rG   rD   r?  rQ   rg  rO   )r:   rA   r#   r  r   r  r'  r@  rA  rB  rC  rD  rE  rF  re  r-  r%  r,  r=   s                      r   r  zTextDoc.docroutine  s   ??x?GF#__F| T:(,y/EE/)$$c3+ +((0%%f-?!.. :/)Hc2JJDW,#i#&>>DFf%'*=!3!337#7#7##=#HHvs+E!E)''/**62%NN8IIh'E&&r8R8FB??8,DIIdOe+h6EV$!#--f5	 i.z) IIdOj8E "11")!B-G%/$6$;.&BC$;#"J$++c*:*A*A*Cd*JKKo " H 	* ! 	!s$   0J +J 	JJJ,+J,c                     g }|j                   }|r || j                  |              |d       t        |      xs d}|r || j                  |              |d       dj	                  |      S )z1Produce text documentation for a data descriptor.rS   rK   )r   rd  rQ   rg  rX   rI  s	            r   r  zTextDoc.docdataD  sb    ~~4!JVn"S!"Jwwwr   r  c                $   | j                  |      }|r+|xr |dz   xs d|z   }	|t        |	      z
  }
|
dk  r|d|
 dz   }|xr | j                  |      dz   xs d|z   }	|st        |      }|r#|	d| j	                  t        |            z   dz   z  }	|	S )z-Produce text documentation for a data object.r  rK   r   Nro   rS   )r  rW   rd  rQ   rg  rD   )r:   rA   r#   r  r  rq   r=   r  r  r   chops              r   r  zTextDoc.docotherT  s     yy )TE\/R47DCI%DaxUde 304506B$>.CD4;;s3x00477Dr   )rm  )NrK   r   )NNNNrW  )r)   r   r   r@   rZ  rX  r  rd  rg  rr  r  r  r  r1  r  r  r3  r  r   r   r   r`  r`    se    1 ZND6 A cJXLt'ML^  K$r   r`  c                       e Zd ZdZd Zy)_PlainTextDocz2Subclass of TextDoc which overrides string stylingc                     |S r1  r   rI  s     r   rd  z_PlainTextDoc.bolde  s    r   N)r)   r   r   r@   rd  r   r   r   r  r  c  s
    <r   r  c                 .    t               at        |        y)zCThe first time this is called, determine what kind of pager to use.N)getpagerpagerrw   s    r   r  r  j  s     JE	$Kr   c                     t        t        j                  d      st        S t        t        j                  d      st        S t        j                  j                         rt        j                  j                         st        S t        j                  dk(  rt        S t        j                  j                  d      xs t        j                  j                  d      rCt        j                  dk(  rfdS t        j                  j                  d      dv rfd	S fd
S t        j                  j                  d      dv rt        S t        j                  dk(  rd S t        t        d      rt        j                  d      dk(  rd S t        t        d      rt        j                  d      dk(  rd S ddl} | j                         \  }}t        j                  |       	 t        t        d      r3t        j                  d|z        dk(  rd t        j                  |       S t        t        j                  |       S # t        j                  |       w xY w)z2Decide what method to use for paging through text.isatty
emscriptenMANPAGERPAGERwin32c                 .    t        t        |             S r1  tempfilepagerplainrj   	use_pagers    r   r   zgetpager.<locals>.<lambda>}  s    eDk9 E r   TERM)dumbemacsc                 .    t        t        |             S r1  )	pipepagerr  r  s    r   r   zgetpager.<locals>.<lambda>  s    	%+y A r   c                     t        |       S r1  r  r  s    r   r   zgetpager.<locals>.<lambda>  s    	$	 : r   c                 ,    t        t        |       d      S )Nzmore <r  rw   s    r   r   zgetpager.<locals>.<lambda>  s    M%+x@ r   systemz(pager) 2>/dev/nullr   c                     t        | d      S )Nr  r  rw   s    r   r   zgetpager.<locals>.<lambda>  s    IdG4 r   z(less) 2>/dev/nullc                     t        | d      S )Nlessr  rw   s    r   r   zgetpager.<locals>.<lambda>  s    IdF3 r   Nz	more "%s"c                     t        | d      S )Nmorer  rw   s    r   r   zgetpager.<locals>.<lambda>  s    	$ 7 r   )r   r	   stdin
plainpagerstdoutr  platformr   r+  r   r  tempfilemkstempcloseunlinkttypager)r  fdr   r  s      @r   r  r  p  s   399h'3::x(99SZZ%6%6%8
|||#

z*EbjjnnW.EI<<7"EEZZ^^F#'88AA::	zz~~f!22
||w@@r8+@!AQ!F44r8+?!@A!E33%%'NRHHRL2x RYY{X/E%F!%K7 			( 
		(		(s   "-I  %I   Ic                 0    t        j                  dd|       S )z%Remove boldface formatting from text.z.rK   )rM   rN   rw   s    r   r  r    s    66%T""r   c                 2   ddl }|j                  |d|j                  d      }	 |j                  5 }	 |j	                  |        ddd       	 	 |j                          y# t
        $ r Y &w xY w# 1 sw Y   +xY w# t        $ r Y 9w xY w# t
        $ r Y nw xY wL)z3Page through text by feeding it to another program.r   NTbackslashreplace)shellr  errors)
subprocessPopenPIPEr  writeKeyboardInterruptr   wait)rj   cmdr  procpipes        r   r  r    s    Ct:??#5  7D	ZZ 	4

4 	 	IIK %  	 	   ! 	 		 sW   A: A.AA: B	 	A+(A.*A++A..A73A: :	BB		BBc           	         ddl }|j                         5 }t        j                  j	                  |d      }t        |ddt        j                  dk(  rt        j                  d      nd      5 }|j                  |        ddd       t        j                  |dz   |z   d	z          ddd       y# 1 sw Y   0xY w# 1 sw Y   yxY w)
z<Page through text by invoking a program on a temporary file.r   Nz	pydoc.outwr  r  )r  encodingz "r  )r  TemporaryDirectoryr   r
   rX   r   r	   r  device_encodingr  r  )rj   r  r  tempdirr   r   s         r   r  r    s    		$	$	& /'77<<5(C(:,,') --a0/3 	 JJt		
 			#*x'#-./ /	 	/ /s$   AB:-B.?&B:.B7	3B::Cc                     t        t        j                  dd       xs d}| j                  |d      j	                  |      S )Nr  utf-8r  )r   r	   r  encodedecode)rj   r  s     r   _escape_stdoutr    s6    szz:t4?H;;x!34;;HEEr   c           	         t        t        |             j                  d      }	 ddl}t        j
                  j                         }|j                  |      }|j                  |       d }	 	 t        t        j                  j!                  dd            }|dk  rd}|dz
  x}}t        j$                  j'                  dj)                  |d|       dz          ||d rt        j$                  j'                  d	       t        j$                  j+                           |       }	|	d
v r t        j$                  j'                  d       n|	dv r.t        j$                  j'                  d||   z   dz          |dz   }|	dv r||z
  |z
  }|dk  rd}t        j$                  j'                  ddj)                  ||||z          z   dz          ||z   }||d r|r|j-                  |j.                         yy# t        t        t        j                  f$ r	 d}d }Y w xY w# t"        $ r d}Y w xY w# |r|j-                  |j.                         w w xY w)z%Page through text on a text terminal.rS   r   Nc                  @    t         j                  j                  d      S r}   )r	   r  r   r   r   r   r   zttypager.<locals>.<lambda>  s    #))..+ r   c                  J    t         j                  j                         d d d d S )Nr   rT   )r	   r  r   r   r   r   r   zttypager.<locals>.<lambda>  s!    #)),,.s3BQ7 r   LINESrT      z
-- more --)qQz          )rS   )bB)r  r  r   ttyr	   r  fileno	tcgetattr	setcbreakr  r8   ioUnsupportedOperationr  r   r+  r   r&  r  r  rX   flush	tcsetattr	TCSAFLUSH)
rj   rY   r  r  oldgetcharhrV  incr  s
             r   r  r    s   .&'--d3E8YYmmBb+
2	BJJNN7A./A 6Aa%C

5#;/$67ABiJJ\*JJ	AJ

  !12l"

  !1E!H!<t!CDE&&GcMq5a!JJTDIIeAaen$==DECA! ABi& MM"cmmS1 A )@)@A 878  	A	2 MM"cmmS1 s=   AG1 .)H D8H- 1#HHH*&H- )H**H- -"Ic                 f    t         j                  j                  t        t	        |                    y)z>Simply print unformatted text.  This is the ultimate fallback.N)r	   r  r  r  r  rw   s    r   r  r    s    JJU>$/01r   c                 h   t        j                  |       rU| j                  t        j                  v rd| j                  z   S t        | d      rd| j                  z   S d| j                  z   S t        j                  |       rd| j                  z   S t        j                  |       r=d| j                  j                  d| j                  j                  d| j                  S t        j                  |       r=d| j                  j                  d| j                  j                  d| j                  S t        j                  |       rd	| j                  z   S t        j                  |       rd
| j                  z   S t        j                  |       rd| j                  z   S t        |       j                  S )z/Produce a short description of the given thing.zbuilt-in module r   zpackage zmodule zbuilt-in function zgetset descriptor r   zmember descriptor r  z	function zmethod )r   rc   r)   r	   r  r   r-   isgetsetdescriptorr3   r   r4   r    r,   r(   rC   )things    r   describer    sW   >>S555%665*%..u~~--#enn44!!%())5+=+=+F+FNN 	 !!%())5+=+=+F+FNN 	 u%..((% U^^++5>>));r   c                 R   | j                  d      D cg c]  }|s|	 }}d\  }}|t        |      k  r;t        dj                  |d|dz          |      }|r||dz   }}nn|t        |      k  r;|r|}nt        }||d D ]  }	 t        ||      } |S c c}w # t        $ r Y  yw xY w)z@Locate an object by name or dotted path, importing as necessary.r   r   NrT   )r   rW   r  rX   r$  r   r8   )r
   r	  partr  r   n
nextmodulerA   s           r   locater    s    "jjo6dT6E6IFA
c%j.t! 5yA
:q1uqv c%j. ab	 	VT*F
 M 7  		s   BBB	B&%B&c                     t        | t              r t        | |      }|t        d| z        || fS t	        | dd      }| t        |t              r|fS dfS )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)   )r.   rD   r  r  r   )r  r	  rA   r#   s       r   resolver
  '  so    %y)> , /44 5 5 u}uj$/js3d====r   c                 (   |t         }t        | |      \  }}t        |      }t        j                  |      }|rd|v r|d|d|j                  d       z   z  }n|r||ur|d|j                  z   z  }t        j                  |      sst        j                  |      s^t        j                  |      sIt        j                  |      s4t        |      s)t        |d      r|j                  }nt        |      }|dz  }||z  dz   |j                  ||      z   S )zBRender text documentation, given an object or a path to an object.Nr   z in z in module 
__origin__z objectrv  )rj   r
  r  r   r  rfindr)   rc   r    rd   r2   rI   r   r  rC   r  )r  re  r	  rendererrA   r#   r  r   s           r   
render_docr  5  s    5),LFDFDv&Ft.tzz#///	F&(//V$oof%'&&v.fo 6<(&&F&\FID4<& 8#4#4VT#BBBr   c                 
   |	 t        t        | ||             y	 t        | ||t              }|j                  |       y# t        $ r}|r t        |       Y d}~yd}~ww xY w# t        $ r}t        |      }Y d}~Od}~ww xY w)zCDisplay text documentation, given an object or a path to an object.N)r  r  r  print	plaintextrD   r  )r  re  r	  outputis_clir   r   s          r   r=   r=   P  s|     ~	*UE956	5%I>A 	Q  	#JJ	  	CA	s.   A  A$  	A!	AA!$	B-A==Bc                    t        | |      \  }}t        j                  t        |      t        j	                  ||            }t        |dz   dd      5 }|j                  |       ddd       t        d|dz          y# 1 sw Y   xY w)z<Write HTML documentation to a file in the current directory.r)  r  r  )r  Nwrote)r
  htmlrg  r  r  r   r  r  )r  r	  rA   r#   rg  r   s         r   writedocr  a  ss    5),LFD99Xf%t}}VT'BCD	dWncG	4 

4	'4'>" s   A>>Bc                 b    |i }t        j                  | g|      D ]  \  }}}t        |        y)zAWrite out HTML documentation for all modules in a directory tree.N)r  walk_packagesr  )r   pkgpathdoner  r]   r  s         r   	writedocsr  i  s;    |BT$+$9$93%$I  '5
r   c                   T   e Zd Zi ddddddddddd	d
ddddddddddddddddddddddi d d!d"d#d$d%dd&d#d'd(d)d*d+d,d-d.d/d0dd1dd2d3d4d5d6d7dd8d9d:dd;d<d=iZd>D  cg c]  }d?D ]  }||z   	  c}}} Zd@dAdBdCgedDdEdFdGdHdIdJZdKdLdMdNdOdPdQdRdSdTdUdVdVdWdWdXZej                         D ]/  \  ZZ	e	D ]%  Z
ej                  e
e      ZeevredYz   ez   Zeee
<   ' 1 [[	[
[i dZd[dRd\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdZdxdZi dydzdOd{d|d}d~ddddd#ddddddddddddddddddddddi dddddddddddddddddddSdddddkdddddddndddi dddddddddLdddddddddēd+dœddƓdd	ddɓdd˓dddd6dd#ddddddӜZddՄZedք        Zedׄ        Zd؄ Z e       ZefdلZdڄ Zdۄ Zdd܄Zd݄ ZddބZd߄ Zd Zd ZddZddZd ZddZ yc c}}} w )HelperFalserK   NoneTrueandBOOLEANaswithassert)r'  rK   async)r(  rK   await)r)  rK   break)r*  	while forclass)r,  zCLASSES SPECIALMETHODScontinue)r-  r+  def)functionrK   del)r0  BASICMETHODSelififelse)r4  r+  excepttryfinallyfor)r8  zbreak continue whilefromimportglobal)r;  znonlocal NAMESPACES)r3  
TRUTHVALUE)r:  MODULESin)r>  SEQUENCEMETHODSis
COMPARISONlambda)rB  rt  nonlocal)rC  zglobal NAMESPACESnotorpass)rF  rK   raise)rG  
EXCEPTIONSreturn)rI  rt  )r6  rH  while)rJ  zbreak continue if TRUTHVALUE)r&  z CONTEXTMANAGERS EXCEPTIONS yieldyield)rK  rK   )r  frV  u'r  rO  z'''r  r   )+r  ***r(  z//%<<>>rF  |^~rG  rH  <=>===!=<>)rG  rH  rY  rZ  r[  r\  r]  )r  rX  )z+=z-=z*=z/=z%=z&=z|=z^=z<<=z>>=z**=z//=)rT  rU  rF  rV  rW  rX  )jJ)STRINGS	OPERATORSrA  UNARYAUGMENTEDASSIGNMENTBITWISECOMPLEXzOPERATORS FORMATTINGPOWERzTUPLES LISTS FUNCTIONSz ATTRIBUTES FLOAT MODULES OBJECTSELLIPSISzSLICINGS DICTIONARYLITERALSz	def classr`  PRIVATENAMESzPRIVATENAMES SPECIALMETHODS
BACKQUOTESzTUPLES FUNCTIONS CALLSzLISTS SUBSCRIPTS SLICINGS)rS  rR  ,r   ro   :@r   r   r   `r  r  []r  TYPES)typeszRSTRINGS UNICODE NUMBERS SEQUENCES MAPPINGS FUNCTIONS CLASSES MODULES FILES inspect)stringsz4str UNICODE SEQUENCES STRINGMETHODS FORMATTING TYPESSTRINGMETHODS)zstring-methodszSTRINGS FORMATTING
FORMATTING)formatstringsra  UNICODE)rr  z:encodings unicode SEQUENCES STRINGMETHODS FORMATTING TYPESNUMBERS)numberszINTEGER FLOAT COMPLEX TYPESINTEGER)integersz	int rangeFLOAT)floatingz
float mathre  )	imaginaryzcomplex cmath	SEQUENCES)typesseqz$STRINGMETHODS FORMATTING range LISTSMAPPINGSDICTIONARIESrt  )typesfunctionsz	def TYPESMETHODS)typesmethodszclass def CLASSES TYPESCODEOBJECTS)zbltin-code-objectszcompile FUNCTIONS TYPESTYPEOBJECTS)zbltin-type-objectsztypes TYPESFRAMEOBJECTS
TRACEBACKSNONE)zbltin-null-objectrK   )zbltin-ellipsis-objectSLICINGSSPECIALATTRIBUTES)specialattrsrK   rs  )rq  z!class SPECIALMETHODS PRIVATENAMESr=  )typesmodulesr:  PACKAGESEXPRESSIONS)zoperator-summaryzlambda or and not in is BOOLEAN COMPARISON BITWISE SHIFTING BINARY FORMATTING POWER UNARY ATTRIBUTES SUBSCRIPTS SLICINGS CALLS TUPLES LISTS DICTIONARIESra  
PRECEDENCEOBJECTS)objectsrp  SPECIALMETHODS)specialnameszbBASICMETHODS ATTRIBUTEMETHODS CALLABLEMETHODS SEQUENCEMETHODS MAPPINGMETHODS NUMBERMETHODS CLASSESr1  )customizationzhash repr str SPECIALMETHODSATTRIBUTEMETHODS)zattribute-accesszATTRIBUTES SPECIALMETHODSCALLABLEMETHODS)zcallable-typeszCALLS SPECIALMETHODSr?  )sequence-typesz(SEQUENCES SEQUENCEMETHODS SPECIALMETHODSMAPPINGMETHODS)r  zMAPPINGS SPECIALMETHODSNUMBERMETHODS)znumeric-typesz*NUMBERS AUGMENTEDASSIGNMENT SPECIALMETHODS	EXECUTION)	execmodelz%NAMESPACES DYNAMICFEATURES EXCEPTIONS
NAMESPACES)namingz3global nonlocal ASSIGNMENT DELETION DYNAMICFEATURESDYNAMICFEATURES)zdynamic-featuresrK   SCOPINGFRAMESrH  )r!  ztry except finally raiseCONVERSIONS)conversionsrK   IDENTIFIERS)identifierszkeywords SPECIALIDENTIFIERSSPECIALIDENTIFIERS)z
id-classesrK   )zatom-identifiersrK   LITERALS)zatom-literalsz=STRINGS NUMBERS TUPLELITERALS LISTLITERALS DICTIONARYLITERALSTUPLESTUPLELITERALS)	exprlistszTUPLES LITERALSLISTS)ztypesseq-mutableLISTLITERALSr  )listszLISTS LITERALS)typesmappingDICTIONARYLITERALSr  )r5   zDICTIONARIES LITERALS
ATTRIBUTES)zattribute-referencesz(getattr hasattr setattr ATTRIBUTEMETHODS
SUBSCRIPTS)subscriptionsr?  r  )slicingsr?  CALLS)callsr  )powerr  rb  )unaryr  BINARY)binaryr  SHIFTING)shiftingr  rd  )bitwiser  )comparisonszEXPRESSIONS BASICMETHODS)booleanszEXPRESSIONS TRUTHVALUE	ASSERTION
ASSIGNMENT)
assignmentrc  rc  )	augassignr  DELETION	RETURNING	IMPORTING)compoundzfor while break continue)truthz if while and or not BASICMETHODS)debuggerpdb)zcontext-managersr&  )CONDITIONALLOOPINGr<  	DEBUGGINGCONTEXTMANAGERSNc                      || _         || _        y r1  )_input_output)r:   inputr  s      r   r   zHelper.__init__   s    r   c                 >    | j                   xs t        j                  S r1  )r  r	   r  rC  s    r   r  zHelper.input$  s    {{'cii'r   c                 >    | j                   xs t        j                  S r1  )r  r	   r  rC  s    r   r  zHelper.output(  s    ||)szz)r   c                     t        j                         d   d   dk(  r |         yd| j                  j                  d| j                  j                  dS )NrT   rn   ?rK   rG  r   z
 instance>)r   stackr+   r   r   rC  s    r   __repr__zHelper.__repr__,  sO    ==?1a C'F ( &*^^%>%>%)^^%@%@B 	Br   c                 $   || j                   ur	 | j                  |       y | j                          | j                          | j                  j	                  d       y # t        $ r(}| j                  j	                  | d       Y d }~y d }~ww xY w)NrS   a  
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.
)_GoInteractiver   r  r  r  introinteract)r:   requestr  s      r   __call__zHelper.__call__4  sy    $---.		'" JJLMMOKK    .!!SE*--.s   A 	B'B

Bc                    | j                   j                  d       	 	 | j                  d      }|sy 	 |j                         }t        |      dkD  r"|d   |d   cxk(  rdv rn n|d   |dd vr|dd }|j                         dv ry |d	k(  r| j                          n| j                  |       # t        t        f$ r Y y w xY w)
NrS   zhelp> rU   r   r   rN  rT   )r  quitr   )
r  r  getliner  EOFErrorrV   rW   r-  r  r   )r:   r  s     r   r  zHelper.interactD  s    $,,x0w mmoG Gq WQZ72;%L*%L
'!B-7!!B-}}-/& 

		'"#  &x0 s   B. .C ?C c                     | j                   t        j                  u rt        |      S | j                  j	                  |       | j                  j                          | j                   j                         S )z.Read one line, using input() when appropriate.)r  r	   r  r  r  r  r   )r:   prompts     r   r  zHelper.getlineY  sQ    ::"= KKf%KK::&&((r   c                 X   t        |t              rM|j                         }|dk(  r| j                          nW|dk(  r| j	                          n@|dk(  r| j                          n)|dk(  r| j                          n|d d dk(  r#| j                  |j                         d          n|| j                  v r| j                  |       n|dv rt        t        |      d	|
       n|| j                  v r| j                  |       n|| j                  v r| j                  |       nk|rt        |d	| j                  |       nOt        t        d	| j                  |       n1t        |t               r |         nt        |d	| j                  |       | j"                  j%                  d       y )Nkeywordssymbolstopicsr      zmodules rT   )r"  r   r!  zHelp on %s:r  )r  r  rS   )r.   rD   rV   listkeywordslistsymbols
listtopicslistmodulesr   r  
showsymbolr=   evalr  	showtopicr  r  r  r  r  )r:   r  r  s      r   r   zHelper.helpb  s?   gs#mmoG*$d&7&7&9I%t'7'7'9H$doo&7I%t'7'7'9!
*  !34DLL($//'*B55DM=@DMM)4>>'+BDKK')@#g}T\\RXYc=fM($&'=fM$r   c                     | j                   j                  dj                  dt        j                  d d z               y )Na  Welcome to Python {0}'s help utility! If this is your first time using
Python, you should definitely check out the tutorial 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 get a list of available
modules, keywords, symbols, or topics, enter "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",
enter "modules spam".

To quit this help utility and return to the interpreter,
enter "q" or "quit".
z%d.%drU   )r  r  r,  r	   r2  rC  s    r   r  zHelper.introw  s7       F7S%%bq))*!	,r   c                    t        t        |            }||z  }t        |      |z   dz
  |z  }t        |      D ]  }t        |      D ]s  }||z  |z   }|t        |      k  s| j                  j                  ||          ||dz
  k  sA| j                  j                  dd|dz
  t        ||         z
  z  z          u | j                  j                  d        y )NrT   r  rS   )r|  r  rW   r{  r  r  )	r:   itemscolumnsrn  colwr}  rowr~  r   s	            r   r|  zHelper.list  s    VE]#E
W$q(W4; 	$CW~ R$J$s5z>KK%%eAh/Wq[())#tax#eAh-7O0P*PQR KKd#	$r   c                     | j                   j                  d       | j                  | j                  j	                                y )NzN
Here is a list of the Python keywords.  Enter any keyword to get more help.

)r  r  r|  r  r   rC  s    r   r  zHelper.listkeywords  s4      	 			$--$$&'r   c                     | j                   j                  d       | j                  | j                  j	                                y )Nzx
Here is a list of the punctuation symbols which Python assigns special meaning
to. Enter any symbol to get more help.

)r  r  r|  r  r   rC  s    r   r  zHelper.listsymbols  s4      	
 			$,,##%&r   c                     | j                   j                  d       | j                  | j                  j	                                y )NzN
Here is a list of available topics.  Enter any topic name to get more help.

)r  r  r|  r  r   rC  s    r   r  zHelper.listtopics  s4      	 			$++""$%r   c                    	 dd l }| j                  j                  || j                  j                  |            }|s(| j                  j                  dt        |      z         y t        |t              r| j                  ||      S |\  }}	 |j                  j                  |   }|j                         dz   }|r|xs ddz   |z   }|rRdd l}ddj                  |j                               z   dz   }	|j!                  |	d	      }
|d
dj                  |
      z  z  }t#        |       y # t        $ r | j                  j                  d       Y y w xY w# t        $ r* | j                  j                  dt        |      z         Y y w xY w)Nr   t
Sorry, topic and keyword documentation is not available because the
module "pydoc_data.topics" could not be found.
zno documentation found for %s
rS   rK   r  Related help topics: r  H   z
%s
)pydoc_data.topicsr  r  r  r  r   r  r  r.   rD   r  KeyErrorrV   textwraprX   r   wrapr  )r:   topic
more_xrefs
pydoc_datatargetlabelxrefsr=   r   rj   wrapped_texts              r   r  zHelper.showtopic  sg   	$ (9(9%(@AKK?$u+MNfc">>&*55u	##**51C iikD [bC'*4E*TYYu{{}-EELD#==r2L8dii555Cc
7  	KK   	   	KK?$u+MN	s#   D' E '$EE0FFc                 R   	 ddl }| j                  j                  || j                  j                  |            }|st        d      t        |t              r| j                  ||      S |\  }}|j                  j                  |   }|r|xs ddz   |z   }||fS # t        $ r Y yw xY w)a*  Return unbuffered tuple of (topic, xrefs).

        If an error occurs here, the exception is caught and displayed by
        the url handler.

        This function duplicates the showtopic method but returns its
        result directly so it can be formatted for display in an html page.
        r   N)r  rK   zcould not find topicrK   r  )	r  r  r  r   r  r&  r.   rD   	_gettopic)r:   r  r  r  r  r  r  r=   s           r   r
  zHelper._gettopic  s    	
$ (9(9%(@A344fc">>&*55u&&u-[bC'*4EEz  	

	
s   B 	B&%B&c                 p    | j                   |   }|j                  d      \  }}}| j                  ||       y )Nr  )r  	partitionr  )r:   symbolr  r  r   r  s         r   r  zHelper.showsymbol  s4    f% **3/q%ue$r   c                 n   |r6| j                   j                  dj                  |             t        |       y | j                   j                  d       i }|fdfd}t	               j                  |       | j                  |j                                | j                   j                  d       y )Nzy
Here is a list of modules whose name or summary contains '{}'.
If there are any, enter a module name to get more help.

zI
Please wait a moment while I gather a list of all available modules...

c                 \    |r|dd  dk(  r|d d dz   }|j                  d      dk  rd||<   y y )N	.__init__rq  r   r   rT   )find)r
   r]   r  r   s       r   callbackz$Helper.listmodules.<locals>.callback  sB    wrs|{:%crl\9G<<$q('(GG$ )r   c                      d | d        y r1  r   )r]   r  s    r   onerrorz#Helper.listmodules.<locals>.onerror 	  s    w-r   r  z
Enter any module name to get more help.  Or, type "modules spam" to search
for modules whose name or summary contain the string "spam".
)r  r  r,  aproposModuleScannerrunr|  r   )r:   r   r   r  r  s       @r   r  zHelper.listmodules  s    KK  F3K	
 CLKK   G6= )
.O':IIglln%KK  r   r   )F)r   P   rU  )!r)   r   r   r  _strprefixes_symbols_inverser  r  r  symbols_r  r   r  r   r/   r  r  r  rA   r  r  r  r  r   r  r|  r  r  r  r  r
  r  r  )rQ  pr  s   000r   r  r  p  sp   $$$ 	$ 	y	$
 	f$ 	.$ 	$ 	$ 	'$ 	4$ 	-$ 	$ 	&$ 	$ 	%$  	%!$" 	5#$$ 	.%$& 	'$( 	3)$* 	"+$, 	'-$. 	'/$0 	l1$2 	)3$4 	55$6 	y7$8 	i9$: 	;$< 	(=$> 	)?$@ 	$A$B 	:C$D 	<E$F 	G$HN $8LLaLAAELELL%e;l;N?!B4
 $%/*+%%((G" ,113 %x 	%F[[/FF"#-$GFO		%% 	xU =U 	 (U
 	AU 	4U 	 (U 	=U 	,U 	+U 	1U 	IU 	NU 	4U  	>!U" 	H#U$ 	<%U& 	'U( 	g)U* 	)+U, 	9-U. 	1/U0 	A1U2 	-3U4 	H5U6 	 .7U> 	]?U@ 	mAUB 	'CUD 	 4EUJ 	IKUL 	MMUN 	EOUP 	 /QUT 	GUUV 	 ,WUZ 	K[U\ 	W]U^ 	3_U` 	<aUb 	,cUd 	@eUf 	*gUh 	EiUj 	0kUl 	0mUn 	 8oUr 	+sUt 	9uUv 	5wUx 	3yUz 	>{U| 	?}U~ 	ZU@ 	:AUB 	3CUD 	)EUF 	)GUH 	)IUJ 	+KUL 	/MUN 	-OUP 	AQUR 	9SUT 	XUUV 	;WUX 	=YUZ 	E[U\ 	X]U^ 	X_U` ;C(7iUFn ( ( * *B XN-  #*) *,&$('&@6%
S
 Ms   9H#r  c                       e Zd ZdZddZy)r  z7An interruptible scanner that searches module synopses.Nc                    |r|j                         }d| _        i }t        j                  D ]|  }|dk7  s	d||<   | |d |d       t	        |      j
                  xs d}|j                  d      d   }|dz   |z   }|j                         j                  |      dk\  ss |d ||       ~ t        j                  |      D ]0  \  }	}}
| j                  r n| |d |d       $	 |	j                  |      }|j                  }t        |d	      rU	 |j                  |      }t!        t#        j$                  |            xs d}t        |d
      r|j'                  |      }n[d }nX	 t(        j*                  j-                  |      }|j
                  r|j
                  j1                         d   nd}t3        |dd       }|dz   |z   }|j                         j                  |      dk\  s' ||||       3 |r |        y y # t        $ r Y Kw xY w# t        $ r |r ||       Y ew xY w# t.        $ r |r ||       Y w xY w)NF__main__rT   rK   rS   r   r   r  
get_sourceget_filenamer   )r-  r  r	   r  
__import__r@   r   r  r  r  	find_specr  r   r   r"  r  r   r  StringIOr#  r   r   r   r  r   r   )r:   r  r   	completerr  seenr]   r#   r  r  r  r   r   sourcer
   r   s                   r   r  zModuleScanner.run	  sC   ciik	// 
	6G*$ !W;T7B/%g.66<"D::d+A.D"U?T1Dzz|((-2 w5
	6 )0(=(=g(N $	2$Hguyy{w+#--g6D 6<0!!'!2!27!;
 +2;;v+>?E2Dv~6%227;#!!*!5!5!;!;D!A
 >D^^6>>446q9QSD"6*T:D-::<$$S)Q.T7D1I$	2L K ; #  % !"#G, ! ' !"#G, !s6   &H H%H* 	HHH'&H'*I IrW  )r)   r   r   r@   r  r   r   r   r  r  	  s
    A8r   r  c                     d }d }t        j                         5  t        j                  d       t               j	                  || |       ddd       y# 1 sw Y   yxY w)zAPrint all the one-line module summaries that contain a substring.c                 J    |dd  dk(  r|d d dz   }t        ||xr d|z          y Nr  r  rq  z- )r  )r
   r]   r  s      r   r  zapropos.<locals>.callbackJ	  s3    23<;&crl\1Ggt+t,r   c                      y r1  r   r]   s    r   r  zapropos.<locals>.onerrorN	  s    r   ignorer  N)r   catch_warningsfilterwarningsr  r  )r   r  r  s      r   r  r  H	  sR    -		 	 	" <)Hc7;< < <s   2AAc                   	
 ddl ddlddl	ddl
 G d dj                  j
                         G 	fddj                  j                         G 
fdd
j                        } || ||      }|j                          |j                  sS|j                  r|j                  s;t        j                  d	       |j                  s|j                  s.|j                  s;|S )
aA  Start 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
   r   Nc                       e Zd Zd Zd Zy)!_start_server.<locals>.DocHandlerc                 8   | j                   j                  d      rd}nd}| j                  d       | j                  dd|z         | j	                          | j
                  j                  | j                  | j                   |      j                  d             y)	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.csstext/css	text/html   zContent-Typez%s; charset=UTF-8r  N)	r
   r   send_responsesend_headerend_headerswfiler  
urlhandlerr  )r:   content_types     r   do_GETz(_start_server.<locals>.DocHandler.do_GET	  s     yy!!&))*s#^-@<-OPJJT__		<))/:r   c                      y r1  r   )r:   r  s     r   log_messagez-_start_server.<locals>.DocHandler.log_message	  s    r   N)r)   r   r   r?  rA  r   r   r   
DocHandlerr4  	  s    	: 	r   rB  c                   $    e Zd Zd Z fdZd Zy) _start_server.<locals>.DocServerc                     || _         | j                   |f| _        || _        | j                  j	                  | | j                  | j
                         d| _        y NF)hostaddressr  r<   r   handlerr  )r:   rG  portr  s       r   r   z)_start_server.<locals>.DocServer.__init__	  sE    DI IIt,DL$DMIItT\\4<<@DIr   c                     | j                   sPj                  | j                  j                         gg g d      \  }}}|r| j	                          | j                   sP| j                          y r}   )r  selectsocketr  handle_requestserver_close)r:   rdwrexrL  s       r   serve_until_quitz1_start_server.<locals>.DocServer.serve_until_quit	  sZ    ii#]]DKK,>,>,@+A2r1M
B'') ii r   c                 v    | j                   j                  |        | j                  r| j                  |        y y r1  )r<   server_activater  rC  s    r   rU  z0_start_server.<locals>.DocServer.server_activate	  s,    II%%d+}}d# r   N)r)   r   r   r   rS  rU  )rL  s   r   	DocServerrD  	  s    		 	$r   rV  c                   4    e Zd ZfdZ fdZd Zd Zy)#_start_server.<locals>.ServerThreadc                     || _         || _        t        |      | _        j                  j                  |        d| _        d | _        d | _        y rF  )	r=  rG  r  rJ  Threadr   servingerror	docserver)r:   r=  rG  rJ  	threadings       r   r   z,_start_server.<locals>.ServerThread.__init__	  sE    (DODID	DI%%d+ DLDJ!DNr   c                 n   	 j                   j                  _        _        j                  j
                  _        t        | j                        _         | j                  | j                  | j                        }|| _        |j                          y# t        $ r}|| _        Y d}~yd}~ww xY w)zStart the server.N)server
HTTPServerr<   rI  r  MessageMessageClassstaticmethodr=  rG  rJ  readyr]  rS  r  r\  )r:   docsvrr  rB  rV  emailhttps      r   r  z'_start_server.<locals>.ServerThread.run	  s    	!!%!7!7	$.	!*/--*?*?
'(4T__(E
%"499diiD!''') ! 

!s   BB 	B4#B//B4c                     d| _         |j                  | _        |j                  | _        d| j                  | j                  fz  | _        y )NTzhttp://%s:%d/)r[  rG  server_portrJ  r  )r:   r`  s     r   re  z)_start_server.<locals>.ServerThread.ready	  s:    DLDI**DI&$))TYY)??DHr   c                 p    d| j                   _        | j                          d| _         d| _        d| _        y)z&Stop the server and this thread nicelyTNF)r]  r  rX   r[  r  rC  s    r   stopz(_start_server.<locals>.ServerThread.stop	  s.    "&DNNIIK "DN DLDHr   N)r)   r   r   r   r  re  rl  )rB  rV  rg  rh  r^  s   r   ServerThreadrX  	  s    	"	!	@	r   rm  g{Gz?)http.serveremail.messagerL  r^  r`  BaseHTTPRequestHandlerra  rZ  r  r\  r[  r]  timesleep)r=  hostnamerJ  rm  threadrB  rV  rg  rh  rL  r^  s        @@@@@@r   _start_serverru  V	  s    p T[[77 ,$DKK** $*& &y'' &P *h5F
LLN llFNNv7G7G

3 llFNNv7G7GMr   c                 ^  	
  G fddt               } |       fdfd
fdfdfdfdfd		fd
	
fd}| j                  d      r| dd } |dk(  rt        j                  j	                  t        j                  j                  t                    }t        j                  j                  ||       }t        |      5 }dj                  |j                               cddd       S |dk(  r ||       S t        d|d|       # 1 sw Y   xY w)a  The 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.
    c                       e Zd Z fdZy)_url_handler.<locals>._HTMLDocc           	      :    d}d|z  }d|d|d        d|d	S )rd  zpydoc_data/_pydoc.cssz1<link rel="stylesheet" type="text/css" href="%s">zH<!DOCTYPE>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Pydoc: z	</title>
z</head><body>z*<div style="clear:both;padding-top:.5em;">z</div>
</body></html>r   )r:   re  rf  css_pathcss_linkhtml_navbars        r   rg  z#_url_handler.<locals>._HTMLDoc.page	  s/    .HC  HkmX? ?r   N)r)   r   r   rg  )r|  s   r   _HTMLDocrx  	  s    	?r   r}  c                     j                  t        j                         dt        j                         d   dt        j                         d      } d| dj                  t        j                  d            d	S )
Nz [r   r  ro  z=
            <div style='float:left'>
                Python <br>T)tersea  
            </div>
            <div style='float:right'>
                <div style='text-align:center'>
                  <a href="index.html">Module Index</a>
                  : <a href="topics.html">Topics</a>
                  : <a href="keywords.html">Keywords</a>
                </div>
                <div>
                    <form action="get" style='display:inline;'>
                      <input type=text name=key size=15>
                      <input type=submit value="Get">
                    </form>&nbsp;
                    <form action="search" style='display:inline;'>
                      <input type=text name=key size=15>
                      <input type=submit value="Search">
                    </form>
                </div>
            </div>
            )rJ  r  python_versionpython_buildpython_compiler)r  r  s    r   r|  z!_url_handler.<locals>.html_navbar
  sg    ++x/F/F/H/7/D/D/Fq/I/7/G/G/IK L0 DKK(9(9(EF+H 	Hr   c                     d } j                  d      }t        j                  D cg c]	  }|dk7  r| }}j                  ||       }|dj	                  dd|      z   g}i }t        j
                  D ]#  }|j                  j                  ||             % |j                  d       dd	j                  |      fS c c}w )
zModule Index page.c                     d| d| dS Nr  r  r  r   r#   s    r   	bltinlinkz3_url_handler.<locals>.html_index.<locals>.bltinlink*
      15t<<r   z/<strong class="title">Index of Modules</strong>r!  z<p>zBuilt-in Modulesr  zf<p align=right class="heading-text grey"><strong>pydoc</strong> by Ka-Ping Yee&lt;ping@lfw.org&gt;</p>zIndex of ModulesrK   )	rk  r	   r  r  rt  r
   r   r  rX   )r  rk  r#   namesrf  r(  r   r  s          r   
html_indexz _url_handler.<locals>.html_index'
  s    	= ,,=
 #&":": ($J&  ( (##E95UT__&3 3 4 88 	3COODJJsD12	3 	'	( "2778#444(s   B>c                   	 g 		fd}t        j                         5  t        j                  d       d }t               j	                  || |       ddd       d }g }
j                  d      }	D ]  \  }}|j                   ||      |z          ! |
j                  d| z  d	d
j                  |            z   }d|fS # 1 sw Y   oxY w)zSearch results page.c                 Z    |dd  dk(  r|d d dz   }j                  ||xr d|z   f       y r,  r   )r
   r]   r  search_results      r   r  z3_url_handler.<locals>.html_search.<locals>.callbackD
  s=    rs|{*!#2,5  '4+?D4K!@Ar   r/  c                      y r1  r   r.  s    r   r  z2_url_handler.<locals>.html_search.<locals>.onerrorK
  s    r   r  Nc                     d| d| dS r  r   r  s    r   r  z4_url_handler.<locals>.html_search.<locals>.bltinlinkP
  r  r   z-<strong class="title">Search Results</strong>zkey = %sr  r  zSearch Results)	r   r0  r1  r  r  rk  r   rt  rX   )r   r  r  r  r   rk  r#   r  rf  r  r  s            @r   html_searchz!_url_handler.<locals>.html_search?
  s     	B
 $$& 	@##H-O#w?		@	= ,,;
 ( 	3JD$NN9T?T12	3T__gv{{7';= =))%	@ 	@s   5CC
c                      d } j                  d      }t        t        j                  j	                               }j                  ||       }|j                  dd|      z   }d|fS )zIndex of topic texts available.c                     d| d| dS Nz<a href="topic?key=r  r  r   r  s    r   r  z4_url_handler.<locals>.html_topics.<locals>.bltinlink`
      6:DAAr   $<strong class="title">INDEX</strong>Topicsr  )rk  r  r  r  r   r  rt  )r  rk  r  rf  r  s       r   html_topicsz!_url_handler.<locals>.html_topics]
  sn    	B ,,2
 v}}))+,##E95T__gx) )!!r   c                      j                  d      } t        t        j                  j	                               }d }j                  ||      }| j                  dd|      z   }d|fS )zIndex of keywords.r  c                     d| d| dS r  r   r  s    r   r  z6_url_handler.<locals>.html_keywords.<locals>.bltinlinkt
  r  r   Keywordsr  )rk  r  r  r  r   r  rt  )rk  r  r  rf  r  s       r   html_keywordsz#_url_handler.<locals>.html_keywordsm
  sn    ,,2
 v++-.	B ##E95T__+ +8##r   c                    t        j                         }t        ||      }|j                  |       \  }}| |j                  v rd}nd}j                  d|z        }dj                  |      z  }j                  | d|      }|rAt        |j                               }d }j                  ||      }j                  dd|      }|d| d	j                  |||f      fS )
zTopic or keyword help page.KEYWORDTOPICr  z<pre>%s</pre>r  c                     d| d| dS r  r   r  s    r   r  z7_url_handler.<locals>.html_topicpage.<locals>.bltinlink
  s    :>EEr   r  r  rK   )r  r&  r  r
  r  rk  r  rt  r  r   r  rr  rX   )	r  bufhtmlhelprf  r  re  rk  r  r  s	           r   html_topicpagez$_url_handler.<locals>.html_topicpage|
  s    kkm#s#",,U3%H%%%EE,,/%7
 #T[[%::??57H=5;;=)EF $$UI6ELL!8'5IE %((E235 	5r   c                     t        | d      }|| dk7  rt        d      t        |      }j                  ||       }||fS )NrT   )r	  r!  zcould not find object)r  r&  r  r  )r  r9   re  contentr  s       r   html_getobjz!_url_handler.<locals>.html_getobj
  sI    SA&;3&=455--S)g~r   c                     j                  d      }dj                  fdt        t        |      |      D              }|j	                  | d|      z   }d| z  |fS )Nz$<strong class="title">Error</strong>r  c              3   @   K   | ]  }j                  |        y wr1  )rJ  )rQ  r   r  s     r   rS  z3_url_handler.<locals>.html_error.<locals>.<genexpr>
  s       FTt{{40 Fs   r\  z
Error - %s)rk  rX   r   rC   rt  )r  r   rk  rf  r  s       r   
html_errorz _url_handler.<locals>.html_error
  sf    ,,2
 ;; F4T#YDF FT__S'8DDc!8++r   c                 J   | }| j                  d      r| dd } 	 | dv r 
       \  }}n| dk(  r        \  }}n| dk(  r        \  }}nsd| v rd| j                  d      \  }}} |dk(  r |       \  }}nI|d	k(  r	  |       \  }}n7|d
k(  r| dv r 
       \  }}n#	  	|       \  }}nt        d       	|       \  }}j	                  ||      S # t        $ r  	|       \  }}Y (w xY w# t        $ r  |       \  }}Y Bw xY w# t        $ r} ||      \  }}Y d}~`d}~ww xY w)zGenerate an HTML page for url.r)  N)rK   r  r  r  r0  z
search?keyz	topic?keyzget?keyzbad pydoc url)r   r  r&  r  rg  )r  complete_urlre  r  opr   r   r  r  r  r  r  r  r  r  s          r   get_html_pagez#_url_handler.<locals>.get_html_page
  sf   << cr(C 	;m#!+w!,w
"!.w ]]3/
As%%0%5NE7;&:)7)<w 9_m+)3wA-8-=NE7 %_55!,S!1w yy((% & :)4S)9w:  * A-;C-@NE7A  	;'c:NE7	;s`   AD :C D C) &D C&#D %C&&D )D =D ?D  D 	D"DD"r(  rT   Nr6  rK   r7  zunknown content type z	 for url )rb  r   r   r
   dirnamerealpathr   rX   r   	readlinesrG   )r  r>  r}  r  	path_hererz  fpr  r  r  r  r  r|  r  r  r  s          @@@@@@@@@r   _url_handlerr  	  s    ?7 ?$ :DH650*<" $52,&) &)P ~~c!"gz!GGOOBGG$4$4X$>?	77<<	3/(^ 	+r772<<>*	+ 	+		$S!!
L#N
OO	+ 	+s   D##D,T	localhost)open_browserrs  c                   ddl }t        t        ||       }|j                  rt	        |j                         y|j
                  rd}|r|j                  |j                         	 t	        d|j                         t	        |       |j
                  rZt        d      }|j                         }|dk(  rn9|dk(  r|j                  |j                         nt	        |       |j
                  rZ|j
                  r|j                          t	        d       yyy# t        t        f$ r t	                Y Ew xY w# |j
                  r|j                          t	        d       w w xY w)	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.
    r   Nz"Server commands: [b]rowser, [q]uitzServer ready atzserver> r  r  zServer stopped)
webbrowserru  r  r\  r  r[  r   r  r  r-  r  r  rl  )rJ  r  rs  r  serverthreadserver_help_msgr  s          r   browser  
  s/     x>Ll  !>OOL,,-	(#\%5%56/"&&J'iik#:CZOOL$4$45/* && ##!!#&' $'   "8, 	G	 ##!!#&' $s%   $BD D1.D4 0D11D4 4*Ec                 j    t        | t              xr" | j                  t        j                        dk\  S r   )r.   rD   r  r   sep)r   s    r   ispathr     s%    a5!&&.A"55r   c                    d| v s(t         j                  | v st        j                         | v ryt         j                  j	                  t
              }t         j                  j	                  |      }| j                         }|| v r1t         j                  j                  ||      s|j                  |       |j                  dt        j                                |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.
    rK   Nr   )
r   curdirgetcwdr
   r  r   copysamefileremoveinsert)
given_pathargv0
stdlib_dir
script_dirrevised_paths        r   _get_revised_pathr    s     
Z299
2biikZ6O *J'J??$LZ(8(8Z(PJ'299;'r   c                      t        t        j                  t        j                  d         } | | t        j                  dd yy)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.
    r   N)r  r	   r
   argv)r  s    r   _adjust_cli_sys_pathr    s4    
 %SXXsxx{;L"  r   c                     ddl }  G d dt              }t                	 | j                  t        j                  dd d      \  }}d}d}d}d}d}|D ]:  \  }	}
|	d	k(  rd
}d
}|	dk(  rt        |
        y|	dk(  rd
}|
}|	dk(  rd
}|	dk(  s7d
}|
}< |rt        |||       y|s||D ]  }t        |      rBt        j                  j                  |      s#t        d|z         t        j                  d       	 t        |      r*t        j                  j                  |      rt        |      }|rBt        |      r+t        j                  j                  |      rt!        |       n#t#        |       nt$        j%                  |d
        y# t&        t(        f$ r+}t        |       t        j                  d       Y d}~d}~ww xY w# | j*                  |f$ r} t        j                  j-                  t        j                  j/                  t        j                  d               d   }t        dj1                  |t        j2                               Y yw xY w)z@Command-line interface (looks at sys.argv to decide what to do).r   Nc                       e Zd Zy)cli.<locals>.BadUsageN)r)   r   r   r   r   r   BadUsager  ,  s    r   r  rT   zbk:n:p:wFr  z-bTz-kz-pz-wz-n)rs  r  zfile %r does not existr  a  pydoc - the Python documentation tool

{cmd} <name> ...
    Show text documentation on something.  <name> 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 <name> 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 <keyword>
    Search for a keyword in the synopsis lines of all available modules.

{cmd} -n <hostname>
    Start an HTTP server with the given hostname (default: localhost).

{cmd} -p <port>
    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 <name> ...
    Write out the HTML documentation for a module to a file in the current
    directory.  If <name> contains a '{sep}', it is treated as a filename; if
    it names a directory, documentation is written for all the contents.
)r  r  )getoptr  r  r	   r  r  r  r  r   r
   existsr  exitr   r  r   r  r  r   r  r   r\  r   r   r,  r  )r  r  optsr  writingstart_serverr  rJ  rs  optvalargr   r  s                 r   clir  )  s   #9#M!]]388AB<<
d 	HCd{##d{d{#d{d{#	  4(F8^ 	Cc{277>>##6.45#;277>>##6$S/Cc{rww}}S'9!# IIc$I/	  !23 e LL(# !ggrww//<=a@ : FsF;	!!sQ   AG 2G G AG 6BF	G 	G F>8G >GG BIIr!  r   )r   ) Python Library Documentation: %sr   N)r  r   NF)rK   N)r7  )cr@   r  r   r   r   r   r$  importlib._bootstrapr   importlib._bootstrap_externalimportlib.machineryimportlib.utilr   r  r   r  r  rM   r	   r4  rq  r   urllib.parser  r   collectionsr   reprlibr   	tracebackr   r   r$   r>   r7   rI   rQ   rZ   r^   ra   rh   rl   rt   r  
IGNORECASErv   rx   r{   r   r   r|  all_feature_namesr   r   r   r   r   r   r   r  r   r  r  r  r7  rb  rZ  r`  r  r  r  r  r  r  r  r  r  r  r  rj   r  r  r
  r  r=   r  r  r  r   r  r  ru  r  r  r  r  r  r  r)   r   r   r   <module>r     s`  )T ()
    $    	 	   	 
        +

1f! A
 %G bjj5r}}E(

" J889 (0
"   %NK	 K&+$  ! (X7 7v(t (TW	7c W	7v:t :@Xc XtG $L#0
/F
*2X2 6* yO	y> KLC6 DE!"#W Wr x; ;z
<VriPX (4+  (J68#T!l zE r   