a
    ze                     @   s&  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	d
 Zdd Zdd Z dd Z!dd Z"dd Z#dd Z$dd Z%dd Z&dd Z'dd Z(dd  Z)e*d!ej+Z,d"d# Z-d$d% Z.d&d' Z/d(d) Z0dd*d+Z1d,d- Z2d.d/ Z3d0d1 Z4d2d3 Z5i fd4d5Z6G d6d7 d7e7Z8d8d9 Z9di fd:d;Z:G d<d= d=Z;G d>d? d?eZ<G d@dA dAe;Z=G dBdC dCeZ>G dDdE dEe;Z?G dFdG dGe?Z@dHdI aAdJdK ZBdLdM ZCdNdO ZDdPdQ ZEdRdS ZFdTdU ZGdVdW ZHdXdY ZIddZd[ZJe? ZKe@ ZLe= ZMdd\d]ZNdd_d`ZOddadbZPddcddZQddfdgZRG dhdi diZSeS ZTG djdk dkZUdldm ZVdndo ZWddqdrZXddsdtdudvdwZYdxdy ZZdzd{ Z[d|d} Z\d~d Z]e^dkr"e]  dS )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                  C   s\   g } g }t jD ]H}tj|pd}tj|}||vrtj|r| | || q| S N.)syspathosabspathnormcaseisdirappend)dirsZnormdirsdirnormdir r   /usr/lib/python3.9/pydoc.pypathdirsR   s    

r   c                 C   s   t | ot| tj S N)inspectZisclass
isinstancetypesGenericAliasobjectr   r   r   _isclass^   s    r   c                 C   sN   t j| j}|d u rd S | jdd d D ]}t||}q.t|sJd S |S )Nr   )r   modulesget
__module____qualname__splitgetattrr   )funcclsnamer   r   r   
_findclassa   s    r'   c              	   C   s  t | rH| jj}| j}t|r>tt||d d| ju r>|}n|j}n"t | r|| j}t	| }|d u svt||| urzd S nt 
| r| j}| j}t|r|jd | | jkr|}n|j}nt| tr| j}|j}t	|}|d u st||| urd S ntt | st | rf| j}| j}t||| ur.d S t | rjt|dd }t|trj||v rj|| S nd S |jD ]F}ztt||}W n ty   Y qpY n0 |d urp|  S qpd S )N__func__r   	__slots__)r   ismethodr(   __name____self__r   r#   	__class__
isfunctionr'   	isbuiltinr!   r   propertyfgetZismethoddescriptorisdatadescriptor__objclass__ismemberdescriptordict__mro__
_getowndocAttributeError)objr&   selfr%   r$   slotsbasedocr   r   r   _finddock   sZ    







r>   c                 C   sd   zJt | d}|d u rW d S | turFt| j}t|trF||krFW d S |W S  ty^   Y d S 0 d S )N__doc__)r   __getattribute__typer?   r   strr8   )r9   r=   Ztypedocr   r   r   r7      s    
r7   c              	   C   sN   t | }|d u r6zt| }W n ttfy4   Y d S 0 t|tsDd S t|S r   )r7   r>   r8   	TypeErrorr   rB   r   Zcleandoc)r   r=   r   r   r   _getdoc   s    
rD   c                 C   s,   t | pt| }|r(tdd| p*dS )Nz^ *
 )rD   r   Zgetcommentsresubrstrip)r   resultr   r   r   getdoc   s    rJ   c                 C   sf   |   d}t|dkr&|d dfS t|dkrX|d  sX|d d|dd  fS dd|fS )N
   r   rE      )stripr"   lenrH   join)r=   linesr   r   r   splitdoc   s    rR   c                 C   s"   | j }| j|kr| jd | }|S r   )r+   r    )r   modnamer&   r   r   r   	classname   s    
rT   c                 C   s<   t | p8t| p8t | p8t | p8t | p8t |  S r   )r   ismoduler   	isroutineZisframeZistracebackZiscoder   r   r   r   isdata   s    rW   c                 G   s.   |r*|d  | |d } |dd  }q | S )NrL   r   rM   )rP   r"   )textpairsr   r   r   replace   s    rZ   c                 C   sX   t | |krTtd|d d }td|d | }| d | d | t | | d   S | S )Nr      rM   ...)rO   max)rX   maxlenpreZpostr   r   r   cram   s
    $r`   z at 0x[0-9a-f]{6,16}(>+)$c                 C   s   t d| S )Nz\1)_re_stripidrG   rX   r   r   r   stripid   s    rc   c                 C   s<   t | rdS t | r8t| dd }t |p4|d u  S dS )NTr,   F)r   r*   r/   r#   rU   )fnr:   r   r   r   _is_bound_method   s    

re   c                 C   s^   i }t | t jD ]\}}d||< q| jD ]}|t| q*| D ]}t| |||< qF|S NrL   )r   
getmembersrV   	__bases__update
allmethodskeysr#   )clmethodskeyvaluer<   r   r   r   rj      s    

rj   c                 C   s8   g }g }| D ]"}||r$| | q| | q||fS r   r   )s	predicateZyesnoxr   r   r   _split_list  s    ru   c                 C   s\   | dv rdS |  dr$| dr$dS |  dr<t|dr<dS |d urL| |v S |  d S d S )N>   r+   __credits__r!   __file____path____spec____package__
__cached____version__
__author__
__loader____date__r)   __builtins__r    r?   r   __rL   __fieldsT)
startswithendswithhasattr)r&   allr9   r   r   r   visiblename  s    r   c                 C   sX   g }t | D ]D\}}}}t |r@d}t|tr@|jd u r@d}|||||f q|S )Ndata descriptorreadonly property)r   classify_class_attrsr2   r   r0   fsetr   )r   resultsr&   kindr%   ro   r   r   r   r   )  s    
r   c                    sZ   t |dg zfddtD  W n ty<   i  Y n0  fdd}| j|d d S )Nr   c                    s   i | ]\}}||t   qS r   )rO   ).0ir&   )fieldsr   r   
<dictcomp>:      z#sort_attributes.<locals>.<dictcomp>c                    s     | d d| d fS Nr   )r   )attr)field_orderr   r   <lambda>=  r   z!sort_attributes.<locals>.<lambda>rn   )r#   	enumeraterC   sort)attrsr   Zkeyfuncr   )r   r   r   sort_attributes4  s    
r   c                 C   s:   t j| r6dD ]$}t jt j| d| r dS qdS )N)z.pyz.pyc__init__TF)r
   r	   r   isfilerP   )r	   extr   r   r   	ispackageB  s
    r   c                 C   s   |   }|d d dks | s0|   }|sq0q| }|d d dkrT|dd  }|d d dkr|dd  }|dd  dkr|d d }| s|   }|sqq|dd	  }nd }|S )
NrL   #   zr"""r[   """r   \r   )readlinerN   r"   )filelinerI   r   r   r   source_synopsisJ  s    r   c           
      C   s2  t | j}|| d\}}|d u s.||k r.| ttjjrJtjj	}n | ttjj
rftjj}nd }|d u rzt| }W n ty   Y d S 0 | t|}W d    n1 s0    Y  n^|d| }tjjd| |d}ztj|}	W n   Y d S 0 tjd= |	jr|	j d nd }||f|| < |S )N)NNZ__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mtimeZ
lastupdaterI   Z
loader_clsr   r   specmoduler   r   r   synopsis[  s6    

(

r   c                   @   s   e Zd Zdd Zdd ZdS )ErrorDuringImportc                 C   s   || _ |\| _| _| _d S r   )r   excro   tb)r:   r   exc_infor   r   r   r     s    zErrorDuringImport.__init__c                 C   s   | j j}d| j|| jf S )Nzproblem in %s - %s: %s)r   r+   r   ro   )r:   r   r   r   r   __str__  s    zErrorDuringImport.__str__N)r+   r    r!   r   r   r   r   r   r   r     s   r   c           	      C   s   t jj}t| d"}||t|k}W d    n1 s:0    Y  tj| }tj	|\}}|rtt j
|| }nt j
|| }t jj|| |d}zt j|W S    t| t Y n0 d S )Nrbr   )r   r   MAGIC_NUMBERr   readrO   r
   r	   basenamesplitext_bootstrap_externalr   SourceFileLoaderr   r   r   r   r   r   )	r	   magicr   Zis_bytecoder   r&   r   r   r   r   r   r   
importfile  s    0r   c              	      s  z^|rT t jv rT t jvrT fddt jD } g| D ]}t j| ||< t j|= q8t }W nz   t   \}}}}	 t jv rtt j  j|	n>|tu rt|j|	n(t	|t
r|j krY d S t t  Y n0  ddd  D ],}
zt||
}W q ty   Y  d S 0 q|S )Nc                    s   g | ]}|  d  r|qS )r   )r   )r   mr	   r   r   
<listcomp>  r   zsafeimport.<locals>.<listcomp>r   rL   )r   r   builtin_module_names
__import__r   r   rw   SyntaxErrorr   
issubclassImportErrorr&   r"   r#   r8   )r	   	forceloadr   Zsubsrn   r   r   ro   r   infopartr   r   r   
safeimport  s*    


r   c                   @   sf   e Zd Zejddejdd  ZdddZ	dddZ
e
 Z Z Z Z ZZed	fd
dZdS )Doc
PYTHONDOCSz%https://docs.python.org/%d.%d/libraryNrM   c                 G   s   ||f| }zDt |r$| j| W S t|r8| j| W S t |rN| j| W S W n tyb   Y n0 t |rx| j	| S | j
| S r   )r   rU   	docmoduler   docclassrV   
docroutiner8   r2   docdatadocother)r:   r   r&   argsr   r   r   document  s    zDoc.documentc                 G   s*   d|odt | t|jf }t|d S )Nz.don't know how to document object%s of type %s )reprrA   r+   rC   )r:   r   r&   r   messager   r   r   fail  s    zDoc.failZstdlibc                 C   s   zt |}W n ty$   d}Y n0 tjd| j}tj|}t	|t
tr|jdv sx||r|tj|ds|jdvr|drd|d|j f }qtj||j d	 }nd }|S )
N
(built-in)r   )
errno
exceptionsgcZimpmarshalposixsignalr   _threadZ	zipimportzsite-packages)z	xml.etreeztest.pydoc_mod)zhttp://zhttps://z%s/%s/.html)r   
getabsfilerC   r
   environr   r   r	   r   r   rA   r+   r   rP   rH   lower)r:   r   Zbasedirr   doclocr   r   r   	getdocloc  s(    

zDoc.getdocloc)N)N)r+   r    r!   r
   r   r   r   version_infor   r   r   r   r   r   r   docpropertyr   	sysconfigZget_pathr   r   r   r   r   r     s   

r   c                   @   sD   e Zd Zdd Zdd Zdd Zdd Zd	d
 ZeZdd Z	eZ
dS )HTMLReprc                 C   s,   t |  d | _| _d| _d | _| _d S N   
   d   r   r   maxlistmaxtuplemaxdict	maxstringmaxotherr:   r   r   r   r   
  s    
zHTMLRepr.__init__c                 C   s   t |ddddddS )N&z&amp;<z&lt;>z&gt;)rZ   r:   rX   r   r   r   escape  s    zHTMLRepr.escapec                 C   s   t | |S r   )r   r   r:   r   r   r   r   r     s    zHTMLRepr.reprc                 C   sZ   t t|dr@ddt|j  }t | |r@t| |||S | ttt	|| j
S Nr+   repr_r   )r   rA   rP   r+   r"   r#   r  r`   rc   r   r  r:   rt   levelZ
methodnamer   r   r   repr1  s
    
zHTMLRepr.repr1c                 C   s^   t || j}t|}d|v rJdt|ddvrJd|d  | | |d  S tdd| |S )Nr   \\rE   rr   z-((\\[\\abfnrtv\'"]|\\[0-9]..|\\x..|\\u....)+)z<font color="#c040c0">\1</font>)r`   r  r   rZ   r  rF   rG   r:   rt   r  testZtestreprr   r   r   repr_string  s    zHTMLRepr.repr_stringc                 C   s@   z|  ttt|| jW S    |  d|jj  Y S 0 d S Nz<%s instance>)r  r`   rc   r   r  r-   r+   r:   rt   r  r   r   r   repr_instance*  s    zHTMLRepr.repr_instanceN)r+   r    r!   r   r  r   r  r  repr_strr  Zrepr_unicoder   r   r   r   r     s   r   c                   @   s   e Zd Ze ZejZejZdd Zd0ddZd1d	d
Z	dd Z
dd Zd2ddZdd Zdd Zdd Zdd Zdd Zdd Zdi i i fddZd3d d!Zd4d"d#Zddi i fd$d%Zd&d' Zddi i i dfd(d)Zd5d*d+ZeZd6d,d-Zd7d.d/ZdS )8HTMLDocc                 C   s   d||f S )Nz<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: %s</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body bgcolor="#f0f0f8">
%s
</body></html>r   )r:   titlecontentsr   r   r   page;  s    zHTMLDoc.pagerE   c                 C   s   d|||||pdf S )Na'  
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="%s">
<td valign=bottom>&nbsp;<br>
<font color="%s" face="helvetica, arial">&nbsp;<br>%s</font></td
><td align=right valign=bottom
><font color="%s" face="helvetica, arial">%s</font></td></tr></table>
    &nbsp;r   )r:   r  fgcolbgcolextrasr   r   r   headingE  s    zHTMLDoc.heading   Nr  c	           
      C   s^   |d u rdd|  d }d|||f }	|r@|	d||||f  }	n|	d|||f  }	|	d|  S )Nz<tt>r  z</tt>z<p>
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="%s">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="%s" face="helvetica, arial">%s</font></td></tr>
    zR
<tr bgcolor="%s"><td rowspan=2>%s</td>
<td colspan=2>%s</td></tr>
<tr><td>%s</td>z(
<tr><td bgcolor="%s">%s</td><td>%s</td>z'
<td width="100%%">%s</td></tr></table>r   )
r:   r  r   r!  r  widthZpreludeZ
marginaliaZgaprI   r   r   r   sectionP  s    
zHTMLDoc.sectionc                 G   s   d| }| j |g|R  S )Nz<big><strong>%s</strong></big>)r&  )r:   r  r   r   r   r   
bigsectionf  s    zHTMLDoc.bigsectionc              
   C   s&   |  | }t|dddddddd	S )N

z
 
r   r  rK   <br>
)r  
expandtabsrZ   r
  r   r   r   	preformatk  s    zHTMLDoc.preformatr   c                 C   s   d}t || d | }t|D ]X}|dd|   }t|| || | D ]$}|t |k rJ||||  d }qJ|d }q d| S )NrE   rL   z<td width="%d%%" valign=top>r   r)  z</td>z7<table width="100%%" summary="list"><tr>%s</tr></table>)rO   range)r:   listformatZcolsrI   rowscolr   r   r   r   multicolumnq  s    
zHTMLDoc.multicolumnc                 C   s   d| S )Nz<font color="#909090">%s</font>r   r
  r   r   r   grey}  r   zHTMLDoc.greyc                 G   s*   |D ] }||v rd|| |f   S q|S )N<a href="%s">%s</a>r   )r:   r&   Zdictsr5   r   r   r   namelink  s    zHTMLDoc.namelinkc                 C   sN   |j tj|j }}t||rDt|||u rDd|j |t||f S t||S )Nz<a href="%s.html#%s">%s</a>)r+   r   r   r   r    r   r#   rT   )r:   r   rS   r&   r   r   r   r   	classlink  s    zHTMLDoc.classlinkc                 C   s   d|j |j f S Nz<a href="%s.html">%s</a>)r+   r  r   r   r   
modulelink  s    zHTMLDoc.modulelinkc                 C   sR   |\}}}}|r|  |S |r,d||f }nd| }|rBd| }n|}d||f S )Nz
%s.%s.htmlz%s.htmlz"<strong>%s</strong>&nbsp;(package)r3  )r2  )r:   Z
modpkginfor&   r	   r   shadowedurlrX   r   r   r   
modpkglink  s    

zHTMLDoc.modpkglinkc                 C   s   d||f S )Nz<a href="file:%s">%s</a>r   )r:   r9  r	   r   r   r   filelink  s    zHTMLDoc.filelinkc                 C   s  |p| j }g }d}td}|||}	|	s0qh|	 \}
}|||||
  |	 \}}}}}}|r||dd}|d||f  n|rdt| }|d|||f  n|rdt| }|d|||f  n|r"|||d  d	kr|d
| 	||  n|d|  n@|||d  d	krP|| 	|||| n|| 	|| |}q||||d   d
|S )Nr   zJ\b((http|https|ftp)://\S+[\w/]|RFC[- ]?(\d+)|PEP[- ]?(\d+)|(self\.)?(\w+))"z&quot;r3  z'http://www.rfc-editor.org/rfc/rfc%d.txtz)https://www.python.org/dev/peps/pep-%04d/rL   (zself.zself.<strong>%s</strong>rE   )r  rF   compilesearchspanr   groupsrZ   intr4  rP   )r:   rX   r  funcsclassesrm   r   herepatternmatchstartendr   schemeZrfcZpepZselfdotr&   r9  r   r   r   markup  s8    

zHTMLDoc.markupc           
      C   s   d}|D ]}t |t du r|\}}|d }|| || }|r||fkrg }|D ]}	|| |	| qR|d d| d }|d }qt |t g u r|d| |||  }qd	| S )
NrE   r   z"<dt><font face="helvetica, arial">r=  , )z
</font></dt>z<dd>
%s</dd>
z<dl>
%s</dl>
)rA   r5  r   rP   
formattree)
r:   treerS   parentrI   entrycbasesparentsr<   r   r   r   rN    s"    

zHTMLDoc.formattreec           #   
      s  |j }z
|j}W n ty&   d }Y n0 |d}g }tt|d D ],}|dd|d |d  || f  qFd||dd   }	d|	 }
z&t	|}t
j|} ||}W n ty   d}Y n0 g }t|dr2t|j}|d d d	kr|dd  d
kr|dd  }|d |  t|drT| t|j |rl|
dd|  }
 |}|d urdt  }nd} |
ddd| | }t|tj}g i  }}t|tD ]Z\}}|d ust|p||u rt|||r|||f d|  ||< ||< q|D ]\}}|jD ]n}|j |j }}tj !|}||kr:|r:t||r:t"|||u r:||vr:|d |  ||< ||< q:q,g i  }}t|tj#D ]p\}}|d ust$|st||u rt|||r|||f d| ||< t%|r|| ||< qg }t|t&D ]&\}}t|||rH|||f qH 't(| j)||}|od| }|d|  }t|drg }t*+|j,D ]\}}} |||| df q|-   .| j/}!| 0ddd|! }n.|r6 .| fdd}!| 0ddd|! }|rd d! |D }" 1t2|"d|g}!|D ]"\}}|! 3||||| qd| 0d"dd#d$|! }|rg }!|D ]"\}}|! 3||||| q| 0d%dd&d$|! }|r4g }!|D ]\}}|! 3|| q| 0d'dd(d)|! }t|d*rh 't|j4 j)}!| 0d+dd|! }t|d,r 't|j5 j)}!| 0d-dd|! }|S ).Nr   rL   z5<a href="%s.html"><font color="#ffffff">%s</font></a>r   )<big><big><strong>%s</strong></big></big>r   r|      $Revision: $z
version %sr   z (%s)rL  z-<br><a href="%(docloc)s">Module Reference</a>rE   #ffffff#7799eez<a href=".">index</a><br>r   z.html#z#-z<tt>%s</tt>z
<p>%s</p>
rx   r   zPackage Contentsz#aa55ccc                    s     | d S rf   )r7  tr  r   r   r   9  r   z#HTMLDoc.docmodule.<locals>.<lambda>ZModulesc                 S   s   g | ]\}}|qS r   r   r   rn   ro   r   r   r   r   >  r   z%HTMLDoc.docmodule.<locals>.<listcomp>ZClasses#ee77aar   Z	Functionsz#eeaa77ZDataz#55aa55r)  r}   ZAuthorrv   ZCredits)6r+   __all__r8   r"   r,  rO   r   rP   r   r   urllibparsequoter;  rC   r   rB   r|   rN   r  r   r   localsr#  rg   rU   r   	getmoduler   rh   r    r   r   r   r#   rV   r/   r.   rW   rK  rJ   r+  pkgutiliter_modulesrx   r   r1  r:  r'  rN  getclasstreer   r}   rv   )#r:   r   r&   modignoredr   partsZlinksr   Z
linkednameheadr	   r9  r;  r   versionr   rI   r   rD  Zcdictrn   ro   r<   rS   r   rC  Zfdictdatar=   modpkgsimporterispkgr  	classlistr   r  r   r     s    





$






 

zHTMLDoc.docmodulec              	      s  j }|p|}j}g }	|	jG fddd}
|
 tt}t|dkr  d |D ]}d|j	  qdd  fdd}fd	d
} fdd}fddt
D }i |D ]j\}}}}d| d |  |< }zt|}W n ty2   Y n0 z||< W q tyT   Y q0 q|rf|rn| n|d d t|fdd\}}tjurtju r|}qXn"u rd}ndj	 }|d7 }t| |d| |dd }|d| |dd }|d| |dd }|d| |dd }|d| |d d }|d!| |d"d }|}qXd#|	}	||krd$||f }nd%|||f }|rg }|D ]}||j	 q|d&d'|  }d#}zt}W n ttfy    d }Y n0 |r2t|}|r2|d(kr2|| d) }t}|rN||pJd# }|j }|ond*| }|d+d,|	d-|S ).Nc                       s    e Zd Zdd Z fddZdS )z(HTMLDoc.docclass.<locals>.HorizontalRulec                 S   s
   d| _ d S r   Zneedoner  r   r   r   r   h  s    z1HTMLDoc.docclass.<locals>.HorizontalRule.__init__c                    s   | j r d d| _ d S )Nz<hr>
rL   rr  r  pushr   r   maybej  s    z.HTMLDoc.docclass.<locals>.HorizontalRule.maybeNr+   r    r!   r   ru  r   rs  r   r   HorizontalRuleg  s   rw  rM   z&<dl><dt>Method resolution order:</dt>
z<dd>%s</dd>
</dl>
c                    s   t ||\}}|r  |  |D ]b\}}}}zt|}W n$ tyd   || Y n0 ||  d q&|S )NrK   ru   ru  r#   	Exceptionr   r   msgr   rr   okr&   r   homeclsro   rD  rC  hrmdictrh  r   rt  r:   r   r   spillz  s    
zHTMLDoc.docclass.<locals>.spillc                    sJ   t ||\}}|rF   |  |D ]\}}}}|| q&|S r   ru   ru  r   r{  r  rh  rt  r:   r   r   spilldescriptors  s    z*HTMLDoc.docclass.<locals>.spilldescriptorsc           
         s   t ||\}}|r  |  |D ]r\}}}}t||}t|}	|	s`d|  n0t|j }	d|	 }	d||	f  d q&|S )Nz<dl><dt>%s</dl>
z<dd><tt>%s</tt>z<dl><dt>%s%s</dl>
rK   )ru   ru  r   r#   rJ   rK  r+  )
r|  r   rr   r}  r&   r   r~  ro   r<   r=   r  r   r   	spilldata  s     
z#HTMLDoc.docclass.<locals>.spilldatac                    s,   g | ]$\}}}}t | d r||||fqS )r9   r   r   r&   r   r%   ro   r   r   r   r     s   
z$HTMLDoc.docclass.<locals>.<listcomp>r   -r   c                    s   | d  u S NrM   r   r[  	thisclassr   r   r     r   z"HTMLDoc.docclass.<locals>.<lambda>defined hereinherited from %sz:<br>
z
Methods %sc                 S   s   | d dkS NrL   methodr   r[  r   r   r   r     r   zClass methods %sc                 S   s   | d dkS NrL   zclass methodr   r[  r   r   r   r     r   zStatic methods %sc                 S   s   | d dkS NrL   zstatic methodr   r[  r   r   r   r     r   zReadonly properties %sc                 S   s   | d dkS NrL   r   r   r[  r   r   r   r     r   zData descriptors %sc                 S   s   | d dkS NrL   r   r   r[  r   r   r   r     r   zData and other attributes %sc                 S   s   | d dkS NrL   rm  r   r[  r   r   r   r     r   rE   z*<a name="%s">class <strong>%s</strong></a>z/<strong>%s</strong> = <a name="%s">class %s</a>(%s)rL  ()r(  z<tt>%s<br>&nbsp;</tt>z#000000z#ffc8d8r[   )r+   rh   r   r   r   getmrorO   ru  r5  r    r   r#   rz  rC   popleftru   builtinsr   r   rP   	signature
ValueErrorrB   r  rJ   rK  r+  r&  )r:   r   r&   rh  rC  rD  ri  realnamerS  r  rw  mror<   r  r  r  r   rn   r   r~  ro   anchor	inheritedtagr  rT  declr  argspecr=   r   )	rD  rC  r  r  rh  r   rt  r:   r  r   r   \  s    

	












zHTMLDoc.docclassc                 C   s   |  d| | S N=)r2  r   r  r   r   r   formatvalue  s    zHTMLDoc.formatvaluec              	   C   s  |j }|p|}|r|j pdd | }	d}
d}t|r|jj}|rZ||urd| || }
n0|jd urzd| |jj| }
nd| || }
t|st|rd}nd}||krd|	|f }nD|rt||g |u rd	|j d | |f }d
}n|}d|	||f }d }t	|rjzt
|}W n ttfy<   d }Y n0 |rjt|}|dkrjd| }|d
d }|std}|| | | |
o| d|
  }|rd| S | t|| j|||}|od| }d||f S d S )NrE   r  r    from  method of %s instance unbound %s methodasync z$<a name="%s"><strong>%s</strong></a>z<a href="#%s">%s</a>rL   z)<a name="%s"><strong>%s</strong></a> = %s<lambda>z$<strong>%s</strong> <em>lambda</em> r   (...)z'<font face="helvetica, arial">%s</font>z<dl><dt>%s</dt></dl>
z<dd><tt>%s</tt></dd>z<dl><dt>%s</dt>%s</dl>
)r+   re   r,   r-   r5  r   iscoroutinefunctionisasyncgenfunctiongetattr_staticrV   r  r  rC   rB   r  r2  rK  rJ   r+  )r:   r   r&   rh  rC  rD  rm   rl   r  r  noteskipdocsimclassasyncqualifierr  Zreallinkr  r  r  r=   r   r   r   r     sl    



zHTMLDoc.docroutinec                 C   sN   g }|j }|r|d|  | t|| j}|r<|d|  |d d|S )Nz!<dl><dt><strong>%s</strong></dt>
z<dd><tt>%s</tt></dd>
rx  rE   )r   rK  rJ   r+  rP   r:   r   r&   rh  rl   r   rt  r=   r   r   r   r   C  s    zHTMLDoc.docdatac                 G   s   |rd| pd}||  | S )Nz<strong>%s</strong> = rE   r   )r:   r   r&   rh  ri  Zlhsr   r   r   r   S  s    zHTMLDoc.docotherc                 C   s   g }|d u ri }t |gD ]<\}}}tdd |D r:q||d|||v f d||< q|  | || j}| |dd|S )Nc                 s   s*   | ]"}d t |  kodkn  V  qdS )i   i  N)ordr   Zchr   r   r   	<genexpr>]  r   z HTMLDoc.index.<locals>.<genexpr>rE   rL   rY  r^  )re  rf  anyr   r   r1  r:  r'  )r:   r   r8  rn  ro  r&   rp  r  r   r   r   indexX  s    
zHTMLDoc.index)rE   )r$  rE   Nr  )r   )N)NN)NNN)NN)N)r+   r    r!   r   _repr_instancer   r  r  r#  r&  r'  r+  r1  r2  r4  r5  r7  r:  r;  rK  rN  r   r   r  r   r   r   r   r  r   r   r   r   r  2  s<   

  

+

y #
A

r  c                   @   s0   e Zd Zdd Zdd Zdd ZeZdd Zd	S )
TextReprc                 C   s,   t |  d | _| _d| _d | _| _d S r   r   r  r   r   r   r   k  s    
zTextRepr.__init__c                 C   sT   t t|dr@ddt|j  }t | |r@t| |||S ttt|| j	S r  )
r   rA   rP   r+   r"   r#   r`   rc   r   r  r  r   r   r   r  q  s
    
zTextRepr.repr1c                 C   sH   t || j}t|}d|v rDdt|ddvrDd|d  | |d  S |S )Nr   r  rE   r  r   )r`   r  r   rZ   r  r   r   r   r  x  s
    zTextRepr.repr_stringc                 C   s4   zt tt|| jW S    d|jj  Y S 0 d S r  )r`   rc   r   r  r-   r+   r  r   r   r   r    s    zTextRepr.repr_instanceN)r+   r    r!   r   r  r  r  r  r   r   r   r   r  i  s
   	r  c                   @   sz   e Zd Ze ZejZdd ZdddZdd Zdd
dZ	dddZ
dddZdd ZdddZdddZeZdddZdS )TextDocc                 C   s   d dd |D S )NrE   c                 s   s   | ]}|d  | V  qdS )Nr   r  r   r   r   r    r   zTextDoc.bold.<locals>.<genexpr>)rP   r
  r   r   r   bold  s    zTextDoc.bold    c                    s>   |sdS  fdd| dD }|r4|d  |d< d|S )NrE   c                    s   g | ]} | qS r   r   r   r   prefixr   r   r     r   z"TextDoc.indent.<locals>.<listcomp>rK   r   )r"   rH   rP   )r:   rX   r  rQ   r   r  r   indent  s    zTextDoc.indentc                 C   s$   |  | }| |d | d S )NrK   r(  )r  rH   r  )r:   r  r  Zclean_contentsr   r   r   r&    s    zTextDoc.sectionNrE   c           
   	      s   d}|D ]}t |t du rr|\}}|| t|  }|rh||fkrh fdd|D }	|dd|	  }|d }qt |t g u r|| | ||d  }q|S )	NrE   r   c                 3   s   | ]}t | V  qd S r   rT   )r   rR  rS   r   r   r    r   z%TextDoc.formattree.<locals>.<genexpr>r  rL  rK   r  )rA   rT   rP   rN  )
r:   rO  rS   rP  r  rI   rQ  rR  rS  rT  r   r  r   rN    s    
zTextDoc.formattreec              	   C   s  |j }tt|\}}| d||o(d|  }t|dd }| |}|d ur`|| d|d  }|rt|| d| }g }	t|tD ]<\}
}|d ust	|p||u rt
|
||r|	|
|f qg }t|tjD ]B\}
}|d ust|st	||u rt
|
||r||
|f qg }t|tD ]&\}
}t
|
||r(||
|f q(g }t }t|drt|jD ]6\}}}|| |r||d  n
|| qr|  || d	d
| }g }t|tjD ]0\}
}|j |d r|
|vr||
 q|r0|  || dd
| }|	rdd |	D }| t|d|g}|	D ]\}
}|| ||
| q^|| dd
| }|rg }|D ]\}
}|| ||
| q|| dd
| }|r g }|D ]"\}
}|| j||
|dd q|| dd
| }t|drzt|j}|d d dkrj|dd  dkrj|dd  }|| d| }t|dr|| dt|j  }t|dr|| dt|j! }t|dr|| d t|j" }zt#|}W n t$y   d!}Y n0 || d"| }|S )#NNAME - r_  z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.
ZDESCRIPTIONrx   
 (package)zPACKAGE CONTENTSrK   r   Z
SUBMODULESc                 S   s   g | ]\}}|qS r   r   r]  r   r   r   r     r   z%TextDoc.docmodule.<locals>.<listcomp>rL   CLASSES	FUNCTIONSF   )r^   ZDATAr|   rV  rW  r   rX  VERSIONr   ZDATEr}   ZAUTHORrv   ZCREDITSr   FILE)%r+   rR   rJ   r&  r#   r   r   rg   r   rd  r   r   rV   r/   rW   setr   re  rf  rx   addr   rP   rU   r   rN  rg  r   r   rB   r|   rN   r   r}   rv   r   rC   )r:   r   r&   rh  ZsynopdescrI   r   r   rD  rn   ro   rC  rm  rn  Zmodpkgs_namesro  rS   rp  Z
submodulesrq  r  rl  r   r   r   r   r     s    
	



$
zTextDoc.docmodulec              	      sJ  j }|p|}j}jfdd}||kr:d| }n|d | }|rlt||}	|dd|	  }g }
|
jzt}W n t	t
fy   d }Y n0 |rt|}|r|dkrȈ|| d  t}|r|d  tt}t|d	kr(d
 |D ]}d||  qd tdd tD tjd}t|}d}|rd |d | D ]}d|  ql||krdt||  d  d G fddd}|   fdd} fdd} fdd}fddtD }|r|r(| n|d d	 t|fdd \}}tjurltju rl|}qn u r|d!}nd"tj }t| |d#| |d$d  }|d%| |d&d  }|d'| |d(d  }|d)| |d*d  }|d+| |d,d  }|d-| |d.d  }|}qd|
}
|
s.|d S |d |
 d/ d S )0Nc                 S   s
   t | |S r   r  )rR  r   r   r   r   makename  s    z"TextDoc.docclass.<locals>.makenameclass z	 = class r  rL  r  rK   rM   zMethod resolution order:r  rE   c                 s   s.   | ]&}|j d s|jdkrt|j V  qdS )r   r  N)r+   r   r    rB   )r   r%   r   r   r   r  C  s   z#TextDoc.docclass.<locals>.<genexpr>r   r   zBuilt-in subclasses:z    ... and z other subclassesc                       s    e Zd Zdd Z fddZdS )z(TextDoc.docclass.<locals>.HorizontalRulec                 S   s
   d| _ d S r   rr  r  r   r   r   r   U  s    z1TextDoc.docclass.<locals>.HorizontalRule.__init__c                    s   | j r d d| _ d S )NzF----------------------------------------------------------------------rL   rr  r  rs  r   r   ru  W  s    z.TextDoc.docclass.<locals>.HorizontalRule.maybeNrv  r   rs  r   r   rw  T  s   rw  c              
      s   t ||\}}|r|   |  |D ]T\}}}}zt|}W n$ tyd   || Y q&0 || q&|S r   ry  r{  r  rh  r   rt  r:   r   r   r  ]  s    zTextDoc.docclass.<locals>.spillc                    sJ   t ||\}}|rF   |  |D ]\}}}}|| q&|S r   r  r{  r  r   r   r  n  s    z*TextDoc.docclass.<locals>.spilldescriptorsc           
   	      s   t ||\}}|r   |  |D ]\\}}}}t|}zt|}	W n tyd   |j| }	Y n0 j|	|d|dd  q&|S )Nr  )r^   r=   rK   )ru   ru  rJ   r#   r8   __dict__r   )
r|  r   rr   r}  r&   r   r~  ro   r=   r9   r  r   r   r  w  s    z#TextDoc.docclass.<locals>.spilldatac                    s,   g | ]$\}}}}t | d r||||fqS r  r  r  r   r   r   r     s   
z$TextDoc.docclass.<locals>.<listcomp>r   c                    s   | d  u S r  r   r[  r  r   r   r     r   z"TextDoc.docclass.<locals>.<lambda>r  r  zMethods %s:
c                 S   s   | d dkS r  r   r[  r   r   r   r     r   zClass methods %s:
c                 S   s   | d dkS r  r   r[  r   r   r   r     r   zStatic methods %s:
c                 S   s   | d dkS r  r   r[  r   r   r   r     r   zReadonly properties %s:
c                 S   s   | d dkS r  r   r[  r   r   r   r     r   zData descriptors %s:
c                 S   s   | d dkS r  r   r[  r   r   r   r     r   zData and other attributes %s:
c                 S   s   | d dkS r  r   r[  r   r   r   r     r   z |  )r+   rh   r    r  maprP   r   r   r  r  rC   rB   rJ   r   r  rO   sortedrA   __subclasses__r   r   r  ru   r  r   rT   r   r  rH   )r:   r   r&   rh  ri  r  rS  r  r  rT  r  r  r  r=   r  r<   Z
subclassesZno_of_subclassesZMAX_SUBCLASSES_TO_DISPLAYZsubclassnamerw  r  r  r  r   r  r  r   )r  rh  r   rt  r:   r  r   r     s    



	










zTextDoc.docclassc                 C   s   d|  | S r  r  r  r   r   r   r    s    zTextDoc.formatvaluec              	   C   s  |j }|p|}d}d}t|rn|jj}|rB||urndt|| }n,|jd ur`dt|jj| }ndt|| }t|st|rd}	nd}	||kr| |}
n,|rt	||g |u rd}| |d | }
d }t
|r:zt|}W n ttfy   d }Y n0 |r:t|}|d	kr:| |d
 }
|dd }|sDd}|	|
 | | }|rb|d S t|pnd}|d |o| | d  S d S )NrE   r   r  r  r  r  rL    = r  z lambda r   r  rK   )r+   re   r,   r-   rT   r   r  r  r  r  rV   r  r  rC   rB   rJ   r  rH   )r:   r   r&   rh  rl   r  r  r  r  r  r  r  r  r  r=   r   r   r   r     sT    



zTextDoc.docroutinec                 C   sT   g }|j }|r$|| | |d t|p.d}|rJ|| | |d d|S )NrK   rE   )r   r  rJ   r  rP   r  r   r   r   r     s    zTextDoc.docdatac           
      C   s   |  |}|rF|r|d pd| }|t| }	|	dk rF|d |	 d }|rX| |d pZd| }|slt|}|r|d| t| d 7 }|S )Nr  rE   r   r\   rK   )r   rO   r  rJ   r  rB   )
r:   r   r&   rh  rP  r^   r=   r   r   Zchopr   r   r   r     s    
zTextDoc.docother)r  )NrE   )NN)NN)NNN)NNN)NNNNN)r+   r    r!   r  r  r   r  r  r&  rN  r   r   r  r   r   r   r   r   r   r   r   r    s   


e
 
7
r  c                   @   s   e Zd Zdd ZdS )_PlainTextDocc                 C   s   |S r   r   r
  r   r   r   r    s    z_PlainTextDoc.boldN)r+   r    r!   r  r   r   r   r   r    s   r  c                 C   s   t  at|  d S r   )getpagerpagerrb   r   r   r   r    s    r  c               	      sZ  t tjdstS t tjds tS tj r4tj s8tS tjdpNtjd  rtj	dkrj fddS tjddv r fd	dS  fd
dS tjddv rtS tj	dkrdd S t tdrt
ddkrdd S dd l} |  \}}t| zRt tdr,t
d| dkr,dd W t| S tW t| S W t| nt| 0 d S )NisattyZMANPAGERZPAGERwin32c                    s   t t|  S r   tempfilepagerplainrb   Z	use_pagerr   r   r   #  r   zgetpager.<locals>.<lambda>ZTERM)ZdumbZemacsc                    s   t t|  S r   )	pipepagerr  rb   r  r   r   r   %  r   c                    s
   t |  S r   r  rb   r  r   r   r   '  r   c                 S   s   t t| dS )Nzmore <r  rb   r   r   r   r   +  r   systemz(less) 2>/dev/nullr   c                 S   s
   t | dS )NZlessr  rb   r   r   r   r   -  r   z	more "%s"c                 S   s
   t | dS )NZmorer  rb   r   r   r   r   4  r   )r   r   stdin
plainpagerstdoutr  r
   r   r   platformr  tempfilemkstempcloseunlinkttypager)r  fdr   r   r  r   r    s>    


 

r  c                 C   s   t dd| S )Nz.rE   )rF   rG   rb   r   r   r   r  :  s    r  c              	   C   s   dd l }|j|d|jd}zVtj|jdd2}z||  W n tyN   Y n0 W d    n1 sd0    Y  W n ty   Y n0 z|	  W qW q ty   Y q0 qd S )Nr   T)shellr  backslashreplace)errors)

subprocessPopenPIPEioTextIOWrapperr  writeKeyboardInterruptr   wait)rX   cmdr  procpiper   r   r   r  >  s    (r  c              	   C   s   dd l }| }tj|d}t|ddtjdkr<tdnd d}|	|  W d    n1 sd0    Y  t
|d | d  W d    n1 s0    Y  d S )	Nr   z	pydoc.outwr  r  )r  encodingz "r<  )r  TemporaryDirectoryr
   r	   rP   r   r   r  device_encodingr  r  )rX   r  r  tempdirr   r   r   r   r   r  U  s    
(r  c                 C   s$   t tjdd pd}| |d|S )Nr   utf-8r  )r#   r   r  encodedecode)rX   r   r   r   r   _escape_stdouta  s    r  c           
      C   s  t t| d}z2dd l}tj }||}|| dd }W n& t	t
tjfyj   d }dd }Y n0 zDzttjdd}W n ty   d}Y n0 |dkrd}|d  }}tjd|d | d  ||d  rtjd	 tj  | }	|	d
v rtjd qn,|	dv rFtjd||  d  |d }q|	dv rj|| | }|dk rjd}tjdd||||   d  || }qW |r|||j| n|r|||j| 0 d S )NrK   r   c                   S   s   t jdS rf   )r   r  r   r   r   r   r   r   n  r   zttypager.<locals>.<lambda>c                   S   s   t j d d d d S )Nr   rL   )r   r  r   r   r   r   r   r   q  r   LINESrL      z
-- more --)qQz          )rK   )bB)r  r  r"   ttyr   r  filenoZ	tcgetattrZ	setcbreakr   r8   r  UnsupportedOperationrB  r
   r   r   r  r  r  rP   flushZ	tcsetattrZ	TCSAFLUSH)
rX   rQ   r  r  oldZgetcharhr  ZincrR  r   r   r   r  f  sN    







&r  c                 C   s   t jtt|  d S r   )r   r  r  r  r  rb   r   r   r   r    s    r  c                 C   s   t | r>| jtjv r d| j S t| dr4d| j S d| j S t | rRd| j S t | rtd| jj	| jj| jf S t 
| rd| jj	| jj| jf S t| rd| j S t | rd	| j S t | rd
| j S t| jS )Nzbuilt-in module rx   zpackage zmodule zbuilt-in function zgetset descriptor %s.%s.%szmember descriptor %s.%s.%sr  z	function zmethod )r   rU   r+   r   r   r   r/   Zisgetsetdescriptorr3   r    r4   r   r.   r*   rA   )thingr   r   r   describe  s2    













r  c              	   C   s   dd |  dD }d\}}|t|k r\td|d |d  |}|r\||d  }}qq\q|rf|}nt}||d  D ]*}zt||}W qv ty   Y  d S 0 qv|S )Nc                 S   s   g | ]}|r|qS r   r   )r   r   r   r   r   r     r   zlocate.<locals>.<listcomp>r   r   rL   )r"   rO   r   rP   r  r#   r8   )r	   r   rj  r   nZ
nextmoduler   r   r   r   r   locate  s    r  c                 C   sV   t | tr0t| |}|d u r(td|  || fS t| dd }| t |trL|nd fS d S )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   rB   r  r   r#   )r  r   r   r&   r   r   r   resolve  s    

r   Python Library Documentation: %sc                 C   s   |d u rt }t| |\}}t|}t|}|rTd|v rT|d|d |d  7 }n|rn||urn|d|j 7 }t|st|st	|st
|st|st|dr|j}nt|}|d7 }|| d ||| S )Nr   z in z in module 
__origin__z objectr(  )rX   r  r  r   rd  rfindr+   rU   r   rV   r2   rD   r   r  rA   r   )r  r  r   Zrendererr   r&   r  r   r   r   r   
render_doc  s.    


r  c              
   C   sh   z2|d u rt t| || n|t| ||t W n0 ttfyb } zt| W Y d }~n
d }~0 0 d S r   )r  r  r  	plaintextr   r   print)r  r  r   outputro   r   r   r   r=     s    r=   c              
   C   s   ztt | |\}}tt|t||}t|d ddd}|| W d    n1 sZ0    Y  td|d  W n0 tt	fy } zt| W Y d }~n
d }~0 0 d S )Nr   r  r  )r   Zwrote)
r  htmlr  r  r   r   r  r   r   r   )r  r   r   r&   r  r   ro   r   r   r   writedoc  s    (r#  rE   c                 C   s2   |d u ri }t | g|D ]\}}}t| qd S r   )re  walk_packagesr#  )r   pkgpathdonero  rS   rp  r   r   r   	writedocs	  s    
r'  c                J   @   s.  e Zd Z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ddd$Zd d! d"D Zd#d$d%d&geR d'd(d)d*d+d,d-Zd.d/d0d1d2d3d4d5d6d7d8d9d9d:d:d;Ze D ]:\ZZ	e	D ],Z
ee
eZeevred< e Zeee
< qqd=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdLdMdNdOdPdQddRdSdSdTdUdVdWdXdYdZd[d\d]d^d_d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{ddd|d}d~ddIZdddZedd Zedd Zdd Ze ZefddZdd Zdd Zdd Zdd ZdddZdd Zdd Zdd ZdddZdddZdd ZdddZ dS )HelperrE   BOOLEANwith)assertrE   )asyncrE   )awaitrE   )break	while for)classzCLASSES SPECIALMETHODS)continuer/  )functionrE   )delBASICMETHODSif)elser/  try)forzbreak continue whileimport)globalznonlocal NAMESPACES)r5  
TRUTHVALUE)r9  MODULES)inSEQUENCEMETHODS
COMPARISON)lambdar  )nonlocalzglobal NAMESPACES)passrE   )raise
EXCEPTIONS)returnr  )r7  rD  )whilezbreak continue if TRUTHVALUE)r*  z CONTEXTMANAGERS EXCEPTIONS yield)yieldrE   )$FalseNoneTrue__peg_parser__andasr+  r,  r-  r.  r0  r1  defr3  elifr6  exceptfinallyr8  fromr:  r5  r9  r=  isr@  rA  notorrB  rC  rE  r7  rF  r*  rG  c                 C   s   g | ]}d D ]}|| qqS )'r<  r   )r   pr
  r   r   r   r   E  r   zHelper.<listcomp>)r  fr  urW  z'''r<  r   )+r  ***r   z//%<<>>r  |^~r  r	  <=>===!=<>)r  r	  rd  re  rf  rg  rh  )r  rc  )z+=z-=z*=z/=z%=z&=z|=z^=z<<=z>>=z**=z//=)r_  r`  r  ra  rb  rc  )jJ)STRINGS	OPERATORSr?  UNARYAUGMENTEDASSIGNMENTBITWISECOMPLEXzOPERATORS FORMATTINGPOWERzTUPLES LISTS FUNCTIONSz ATTRIBUTES FLOAT MODULES OBJECTSELLIPSISzSLICINGS DICTIONARYLITERALSz	def classrk  PRIVATENAMESzPRIVATENAMES SPECIALMETHODSZ
BACKQUOTESzTUPLES FUNCTIONS CALLSzLISTS SUBSCRIPTS SLICINGS)r^  r]  ,r   r\   :@r   r   r   `r=  rM  []r   )r   zRSTRINGS UNICODE NUMBERS SEQUENCES MAPPINGS FUNCTIONS CLASSES MODULES FILES inspect)stringsz4str UNICODE SEQUENCES STRINGMETHODS FORMATTING TYPES)zstring-methodszSTRINGS FORMATTING)Zformatstringsrl  )rz  z:encodings unicode SEQUENCES STRINGMETHODS FORMATTING TYPES)ZnumberszINTEGER FLOAT COMPLEX TYPES)Zintegersz	int range)Zfloatingz
float math)Z	imaginaryzcomplex cmath)Ztypesseqz$STRINGMETHODS FORMATTING range LISTSDICTIONARIES)Ztypesfunctionsz	def TYPES)Ztypesmethodszclass def CLASSES TYPES)zbltin-code-objectszcompile FUNCTIONS TYPES)zbltin-type-objectsztypes TYPESTYPES)zbltin-null-objectrE   )zbltin-ellipsis-objectSLICINGS)ZspecialattrsrE   )r   z!class SPECIALMETHODS PRIVATENAMES)Ztypesmodulesr9  )zoperator-summaryzlambda or and not in is BOOLEAN COMPARISON BITWISE SHIFTING BINARY FORMATTING POWER UNARY ATTRIBUTES SUBSCRIPTS SLICINGS CALLS TUPLES LISTS DICTIONARIESEXPRESSIONS)Zobjectsr|  )ZspecialnameszbBASICMETHODS ATTRIBUTEMETHODS CALLABLEMETHODS SEQUENCEMETHODS MAPPINGMETHODS NUMBERMETHODS CLASSES)Zcustomizationzhash repr str SPECIALMETHODS)zattribute-accesszATTRIBUTES SPECIALMETHODS)zcallable-typeszCALLS SPECIALMETHODS)sequence-typesz(SEQUENCES SEQUENCEMETHODS SPECIALMETHODS)r  zMAPPINGS SPECIALMETHODS)znumeric-typesz*NUMBERS AUGMENTEDASSIGNMENT SPECIALMETHODS)Z	execmodelz%NAMESPACES DYNAMICFEATURES EXCEPTIONS)Znamingz3global nonlocal ASSIGNMENT DELETION DYNAMICFEATURES)zdynamic-featuresrE   
NAMESPACES)r   ztry except finally raise)ZconversionsrE   )Zidentifierszkeywords SPECIALIDENTIFIERS)z
id-classesrE   )zatom-identifiersrE   )zatom-literalsz=STRINGS NUMBERS TUPLELITERALS LISTLITERALS DICTIONARYLITERALS	SEQUENCES)Z	exprlistszTUPLES LITERALS)ztypesseq-mutableLISTLITERALS)ZlistszLISTS LITERALS)ZtypesmappingDICTIONARYLITERALS)r5   zDICTIONARIES LITERALS)zattribute-referencesz(getattr hasattr setattr ATTRIBUTEMETHODS)Zsubscriptionsr>  )Zslicingsr>  )Zcallsr~  )Zpowerr~  )Zunaryr~  )binaryr~  )Zshiftingr~  )Zbitwiser~  )ZcomparisonszEXPRESSIONS BASICMETHODS)ZbooleanszEXPRESSIONS TRUTHVALUEr+  )Z
assignmentrn  )Z	augassignNUMBERMETHODSr3  rE  )Zcompoundzfor while break continue)truthz if while and or not BASICMETHODS)ZdebuggerZpdb)zcontext-managersr*  )Ir|  rk  ZSTRINGMETHODSZ
FORMATTINGUNICODEZNUMBERSZINTEGERFLOATrp  r  ZMAPPINGSr  ZMETHODSZCODEOBJECTSZTYPEOBJECTSZFRAMEOBJECTSZ
TRACEBACKSNONErr  ZSPECIALATTRIBUTESr  r<  ZPACKAGESr~  rl  Z
PRECEDENCEZOBJECTSZSPECIALMETHODSr4  ZATTRIBUTEMETHODSZCALLABLEMETHODSr>  ZMAPPINGMETHODSr  Z	EXECUTIONr  ZDYNAMICFEATURESZSCOPINGZFRAMESrD  ZCONVERSIONSZIDENTIFIERSZSPECIALIDENTIFIERSrs  ZLITERALSZTUPLESZTUPLELITERALSZLISTSr  r{  r  Z
ATTRIBUTESZ
SUBSCRIPTSr}  ZCALLSrq  rm  ZBINARYZSHIFTINGro  r?  r)  Z	ASSERTIONZ
ASSIGNMENTrn  ZDELETIONZ	RETURNINGZ	IMPORTINGZCONDITIONALZLOOPINGr;  Z	DEBUGGINGZCONTEXTMANAGERSNc                 C   s   || _ || _d S r   )_input_output)r:   inputr!  r   r   r   r     s    zHelper.__init__c                 C   s   | j p
tjS r   )r  r   r  r  r   r   r   r    s    zHelper.inputc                 C   s   | j p
tjS r   )r  r   r  r  r   r   r   r!    s    zHelper.outputc                 C   s2   t  d d dkr|   dS d| jj| jjf S )NrL   r[   ?rE   z<%s.%s instance>)r   stackr-   r    r!   r  r   r   r   __repr__  s    zHelper.__repr__c                 C   s6   || j ur| | n|   |   | jd d S )Na  
You are now leaving help and returning to the Python interpreter.
If you want to ask for help on a particular object directly from the
interpreter, you can type "help(object)".  Executing "help('string')"
has the same effect as typing a particular string at the help> prompt.
)_GoInteractiver   introinteractr!  r  r:   Zrequestr   r   r   __call__  s
    
zHelper.__call__c              	   C   s   | j d z| d}|s W qW n ttfy<   Y qY n0 | }t|dkr|d |d   krndv rn n |d |dd vr|dd }| dv rq|d	kr|   q| 	| qd S )
NrK   zhelp> rM   r   r   rV  rL   )r
  quitr   )
r!  r  getliner  EOFErrorrN   rO   r   r  r   r  r   r   r   r    s    

,
zHelper.interactc                 C   s8   | j tju rt |S | j| | j  | j  S d S r   )r  r   r  r!  r  r  r   )r:   promptr   r   r   r    s
    
zHelper.getlinec                 C   s<  t |t du r| }|dkr,|   n|dkr>|   n|dkrP|   n|dkrb|   n|d d dkr| | d  n|| jv r| | nj|d	v rt	t
|d
 nR|| jv r| | n<|| jv r| | n&|rt	|d
| jd nt	td
| jd n$t|tr|   nt	|d
| jd | jd d S )NrE   keywordssymbolstopicsr      zmodules rL   )rJ  rH  rI  zHelp on %s:)r!  rK   )rA   rN   listkeywordslistsymbols
listtopicslistmodulesr"   r  
showsymbolr=   evalr  	showtopicr  r  rB   r   r(  r!  r  r  r   r   r   r     s$    zHelper.helpc                 C   s$   | j ddtjd d   d S )Na  
Welcome to Python {0}'s help utility!

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at https://docs.python.org/{0}/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, symbols, or topics, type
"modules", "keywords", "symbols", or "topics".  Each module also comes
with a one-line summary of what it does; to list the modules whose name
or summary contain a given string such as "spam", type "modules spam".
z%d.%drM   )r!  r  r.  r   r   r  r   r   r   r    s    
zHelper.intror   P   c           	   
   C   s   t t|}|| }t|| d | }t|D ]v}t|D ]\}|| | }|t|k r<| j||  ||d k r<| jdd|d t||     q<| jd q0d S )NrL   r   rK   )r-  r  rO   r,  r!  r  )	r:   itemscolumnsr%  Zcolwr/  rowr0  r   r   r   r   r-  %  s    &zHelper.listc                 C   s    | j d | | j  d S )NzN
Here is a list of the Python keywords.  Enter any keyword to get more help.

)r!  r  r-  r  rk   r  r   r   r   r  2  s    zHelper.listkeywordsc                 C   s    | j d | | j  d S )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  rk   r  r   r   r   r  9  s    zHelper.listsymbolsc                 C   s    | j d | | j  d S )NzN
Here is a list of available topics.  Enter any topic name to get more help.

)r!  r  r-  r  rk   r  r   r   r   r  A  s    zHelper.listtopicsc                 C   s,  zdd l }W n  ty,   | jd Y d S 0 | j|| j|}|s`| jdt|  d S t|tdu r|| 	||S |\}}z|jj| }W n( t
y   | jdt|  Y d S 0 | d }|r|pdd | }|r dd l}dd|  d }	||	d	}
|d
d|
 7 }t| d S )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
rE   rK   r   Related help topics: rL  H   z
%s
)pydoc_data.topicsr   r!  r  r  r   r  r   rA   r  KeyErrorrN   textwraprP   r"   wrapr  )r:   topic
more_xrefs
pydoc_datatargetlabelxrefsr=   r  rX   Zwrapped_textr   r   r   r  H  s4    zHelper.showtopicc                 C   s   zdd l }W n ty    Y dS 0 | j|| j|}|sDtdt|trZ| ||S |\}}|jj| }|r|pxdd | }||fS )Nr   )r  rE   zcould not find topicrE   r   )	r  r   r  r   r  r  r   rB   	_gettopic)r:   r  r  r  r  r  r  r=   r   r   r   r  h  s    	
zHelper._gettopicc                 C   s*   | j | }|d\}}}| || d S )Nr   )r  	partitionr  )r:   symbolr  r  r   r  r   r   r   r    s    
zHelper.showsymbolc                    sv   |r | j d| t| nR| j d i }|fdd  fdd}t j |d | |  | j d d S )	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                 S   s>   |r$|dd  dkr$|d d d }| ddk r:d||< d S )N	.__init__r  r   r   rL   )find)r	   rS   r  r   r   r   r   callback  s    z$Helper.listmodules.<locals>.callbackc                    s    d | d  d S r   r   r  r  r   r   onerror  s    z#Helper.listmodules.<locals>.onerror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-  rk   )r:   rn   r   r  r   r  r   r    s    

zHelper.listmodules)NN)r   r  )rE   )rE   )rE   )!r+   r    r!   r  Z_strprefixesZ_symbols_inverser  r  r  Zsymbols_r  r   r  r   r0   r  r!  r  r   r  r  r  r  r   r  r-  r  r  r  r  r  r  r  r   r   r   r   r(    sD  (W


	

 
r(  c                   @   s   e Zd ZdddZdS )r  Nc              	   C   s  |r|  }d| _i }tjD ]p}|dkrd||< |d u rF|d |d qt|jpRd}|dd }|d | }|  |dkr|d || qtj	|dD ]V\}	}}
| jr q|d u r|d |d qzt
|	|}W n ty   Y qY n0 |j}t|d	rjz||}W n& ty6   |r.|| Y qY n0 tt|pJd}t|d
rd||}nd }n^ztj|}W n& ty   |r|| Y qY n0 |jr|j d nd}t|dd }|d | }|  |dkr|||| q|r |  d S )NF__main__rL   rE   rK   r   r  r  
get_sourceget_filenamerw   )r   r  r   r   r   r?   r"   r  re  r$  	_get_specr   r   r   r  rz  r   r  StringIOr  r   r   r   r   r   r#   )r:   r  rn   Z	completerr  seenrS   r&   r  ro  rp  r   r   sourcer	   r   r   r   r   r    s^    



zModuleScanner.run)NNN)r+   r    r!   r  r   r   r   r   r    s   r  c                 C   sX   dd }dd }t  , t d t j|| |d W d    n1 sJ0    Y  d S )Nc                 S   s6   |dd  dkr |d d d }t ||o.d|  d S Nr  r  r  z- )r   r	   rS   r  r   r   r   r    s    zapropos.<locals>.callbackc                 S   s   d S r   r   r  r   r   r   r    s    zapropos.<locals>.onerrorignorer  )warningscatch_warningsfilterwarningsr  r  )rn   r  r  r   r   r   r    s
    

r  c                    s   dd l dd ldd ldd lG dd djj G fdddjjG  fdddj}|| ||}|  |j	s|j
std q~|S )	Nr   c                   @   s   e Zd Zdd Zdd ZdS )z!_start_server.<locals>.DocHandlerc                 S   sX   | j drd}nd}| d | dd|  |   | j| | j |d d S )Nz.csstext/css	text/html   zContent-Typez%s; charset=UTF-8r  )	r	   r   Zsend_responseZsend_headerZend_headersZwfiler  
urlhandlerr  )r:   content_typer   r   r   do_GET0	  s    

z(_start_server.<locals>.DocHandler.do_GETc                 W   s   d S r   r   )r:   r   r   r   r   log_message@	  s    z-_start_server.<locals>.DocHandler.log_messageN)r+   r    r!   r  r  r   r   r   r   
DocHandler.	  s   r  c                       s(   e Zd Zdd Z fddZdd ZdS )z _start_server.<locals>.DocServerc                 S   s6   || _ | j |f| _|| _| j| | j| j d| _d S NF)hostaddressr  r<   r   handlerr  )r:   r  portr  r   r   r   r   F	  s
    z)_start_server.<locals>.DocServer.__init__c                    s>   | j s2 | j gg g d\}}}|r |   q |   d S rf   )r  selectsocketr  Zhandle_requestZserver_close)r:   Zrdwrexr  r   r   serve_until_quitM	  s
    
z1_start_server.<locals>.DocServer.serve_until_quitc                 S   s    | j |  | jr| |  d S r   )r<   server_activater  r  r   r   r   r  T	  s    z0_start_server.<locals>.DocServer.server_activateN)r+   r    r!   r   r  r  r   r  r   r   	DocServerD	  s   r  c                       s:   e Zd ZfddZ fddZdd Zdd Zd	S )
z#_start_server.<locals>.ServerThreadc                    s2   || _ || _t|| _ j|  d| _d | _d S r  )r  r  rB  r  Threadr   servingerror)r:   r  r  r  )	threadingr   r   r   [	  s    
z,_start_server.<locals>.ServerThread.__init__c              
      sz   zJj j_ _jj _t| j _| j	| j
| j}|| _|  W n* tyt } z|| _W Y d }~n
d }~0 0 d S r   )server
HTTPServerr<   r  r   ZMessageZMessageClassstaticmethodr  r  r  ready	docserverr  rz  r  )r:   Zdocsvre)r  r  emailhttpr   r   r  c	  s    

z'_start_server.<locals>.ServerThread.runc                 S   s,   d| _ |j| _|j| _d| j| jf | _d S )NTzhttp://%s:%d/)r  r  Zserver_portr  r9  )r:   r  r   r   r   r  p	  s    z)_start_server.<locals>.ServerThread.readyc                 S   s&   d| j _|   d | _ d| _d | _d S )NTF)r  r  rP   r  r9  r  r   r   r   stopv	  s
    z(_start_server.<locals>.ServerThread.stopN)r+   r    r!   r   r  r  r  r   )r  r  r  r  r  r   r   ServerThreadY	  s   r  g{Gz?)Zhttp.serverZemail.messager  r  r  ZBaseHTTPRequestHandlerr  r  rH  r  r  timesleep)r  hostnamer  r  threadr   )r  r  r  r  r  r  r   _start_server  s    8'r  r  c                    s6  G fdddt }|   fdd fdd fdd fd	d
 fdd fdd fdd fdd fdd}| dr| dd  } |dkrtjtjt}tj|| }t|}d|	 W  d    S 1 s0    Y  n|dkr"|| S t
d|| f d S )Nc                       s   e Zd Z fddZdS )z_url_handler.<locals>._HTMLDocc                    s   d}d| }d||  |f S )Nzpydoc_data/_pydoc.cssz1<link rel="stylesheet" type="text/css" href="%s">a  <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Pydoc: %s</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
%s</head><body bgcolor="#f0f0f8">%s<div style="clear:both;padding-top:.5em;">%s</div>
</body></html>r   )r:   r  r  css_pathZcss_linkhtml_navbarr   r   r  	  s    z#_url_handler.<locals>._HTMLDoc.pageN)r+   r    r!   r  r   r  r   r   _HTMLDoc	  s   r  c                     s>     dt t d t f } d|   tjddf S )Nz%s [%s, %s]r   aZ  
            <div style='float:left'>
                Python %s<br>%s
            </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>
            T)Zterse)r  r  Zpython_versionZpython_buildZpython_compiler)rl  r"  r   r   r  	  s    
z!_url_handler.<locals>.html_navbarc                     s   dd }   ddd}dd tjD } || }|d d	dd
| g}i }tjD ]}| || qT|d dd|fS )Nc                 S   s   d| | f S r6  r   r&   r   r   r   	bltinlink	  s    z3_url_handler.<locals>.html_index.<locals>.bltinlinkz7<big><big><strong>Index of Modules</strong></big></big>rY  rZ  c                 S   s   g | ]}|d kr|qS )r  r   )r   r&   r   r   r   r   	  s   z4_url_handler.<locals>.html_index.<locals>.<listcomp>z<p>zBuilt-in Modulesr^  z|<p align=right><font color="#909090" face="helvetica,arial"><strong>pydoc</strong> by Ka-Ping Yee&lt;ping@lfw.org&gt;</font>zIndex of ModulesrE   )	r#  r   r   r1  r'  r	   r   r  rP   )r  r#  namesr  r  r   r  r   r   
html_index	  s"    
z _url_handler.<locals>.html_indexc           	   	      s   g   fdd}t  4 t d dd }t j|| |d W d    n1 sR0    Y  dd }g }d	d
d} D ]\}}||||  qz|d|  d
dd| }d|fS )Nc                    s:   |dd  dkr |d d d }  ||o0d| f d S r  rp   r  Zsearch_resultr   r   r  	  s    z3_url_handler.<locals>.html_search.<locals>.callbackr  c                 S   s   d S r   r   r  r   r   r   r  	  s    z2_url_handler.<locals>.html_search.<locals>.onerrorr  c                 S   s   d| | f S r6  r   r  r   r   r   r  	  s    z4_url_handler.<locals>.html_search.<locals>.bltinlinkz5<big><big><strong>Search Results</strong></big></big>rY  rZ  zkey = %sr^  <br>zSearch Results)	r  r  r  r  r  r#  r   r'  rP   )	rn   r  r  r  r   r#  r&   r  r  r  r   r   html_search	  s$    

0z!_url_handler.<locals>.html_searchc                     sL   dd }   ddd}ttj } || }| ddd| }d|fS )Nc                 S   s   d| | f S Nz<a href="topic?key=%s">%s</a>r   r  r   r   r   r  	  s    z4_url_handler.<locals>.html_topics.<locals>.bltinlink,<big><big><strong>INDEX</strong></big></big>rY  rZ  ZTopicsr^  )r#  r  r(  r  rk   r1  r'  )r  r#  r  r  r  r   r   html_topics	  s    z!_url_handler.<locals>.html_topicsc                     sL     ddd} ttj }dd } ||}|  ddd| }d|fS )Nr  rY  rZ  c                 S   s   d| | f S r  r   r  r   r   r   r  
  s    z6_url_handler.<locals>.html_keywords.<locals>.bltinlinkZKeywordsr^  )r#  r  r(  r  rk   r1  r'  )r#  r  r  r  r  r   r   html_keywords
  s    z#_url_handler.<locals>.html_keywordsc                    s   t  }t||}|| \}}| |jv r0d}nd} d| dd}d | } | dd|}|rt|	 }dd	 } 
||} d
dd|}d|| f d|||ffS )NZKEYWORDZTOPICrU  rY  rZ  z<pre>%s</pre>r^  c                 S   s   d| | f S r  r   r  r   r   r   r  &
  s    z7_url_handler.<locals>.html_topicpage.<locals>.bltinlinkr  z%s %srE   )r  r  r(  r  r  r#  rK  r'  r  r"   r1  r&  rP   )r  bufZhtmlhelpr  r  r  r#  r  r  r   r   html_topicpage
  s,    


z$_url_handler.<locals>.html_topicpagec                    s@   t | dd}|d u r$| dkr$tdt|} || }||fS )NrL   )r   rI  zcould not find object)r  r  r  r   )r9  r9   r  contentr  r   r   html_getobj/
  s    z!_url_handler.<locals>.html_getobjc                    sP     ddd}d fddtt||D }| | dd| }d|  |fS )	Nz,<big><big><strong>Error</strong></big></big>rY  rZ  r  c                 3   s   | ]}  |V  qd S r   )r  r  r  r   r   r  ;
  r   z3_url_handler.<locals>.html_error.<locals>.<genexpr>z#bb0000z
Error - %s)r#  rP   r   rA   r'  )r9  r   r#  r  r  r   r   
html_error7
  s    z _url_handler.<locals>.html_errorc              
      sp  | }|  dr| d d } z| dv r2 \}}n| dkrF \}}n| dkrZ \}}nd| v r | d\}}} |dkr| \}}n|dkrz| \}}W n ty   | \}}Y n0 nZ|d	kr| dv r \}}n2z| \}}W n  ty   | \}}Y n0 ntd
n| \}}W n4 tyb } z||\}}W Y d }~n
d }~0 0  ||S )Nr   )rE   r  r  r  r  z
search?keyz	topic?keyzget?keyzbad pydoc url)r   r  r  rz  r  )r9  Zcomplete_urlr  r	  opr   r   )r"  r  r
  r  r  r  r  r  r   r   get_html_pageA
  s>    



$z#_url_handler.<locals>.get_html_pager   rL   r  rE   r  z"unknown content type %r for url %s)r  r   r
   r	   dirnamerealpathrw   rP   r   	readlinesrC   )r9  r  r  r  Z	path_herer  fpr   )	r"  r  r
  r  r  r  r  r  r  r   _url_handler	  s*    	
(


0
r  T	localhost)open_browserr  c             	   C   s   dd l }tt|| }|jr(t|j d S |jrd}|rB||j zzZtd|j t| |jrtd}|	 }|dkr|qqZ|dkr||j qZt| qZW n t
tfy   t  Y n0 W |jr|  td n|jr|  td 0 d S )Nr   z"Server commands: [b]rowser, [q]uitzServer ready atzserver> r
  r  zServer stopped)
webbrowserr  r  r  r   r  r   r9  r  r   r  r  r  )r  r  r  r  ZserverthreadZserver_help_msgr  r   r   r   browsev
  s8    

r  c                 C   s   t | to| tjdkS r   )r   rB   r  r
   sep)rt   r   r   r   ispath
  s    r  c                 C   sv   d| v st j| v st  | v r"d S t jt}t j|}|  }|| v rbt j||sb|| |	dt   |S )NrE   r   )
r
   curdirgetcwdr	   r  rw   copysamefileremoveinsert)Z
given_pathZargv0Z
stdlib_dirZ
script_dirrevised_pathr   r   r   _get_revised_path
  s    
r!  c                  C   s,   t tjtjd } | d ur(| tjd d < d S r   )r!  r   r	   argv)r   r   r   r   _adjust_cli_sys_path
  s    r#  c                  C   s  dd l } G dd dt}t  zx|  tjdd  d\}}d}d}d}d}d}|D ]\\}	}
|	dkrld	}d	}|	d
krt|
  W d S |	dkrd	}|
}|	dkrd	}|	dkrTd	}|
}qT|rt|||d W d S |s||D ]}t|rtj	
|std|   qz`t|r&tj	|r&t|}|rXt|rNtj	|rNt| nt| n
t| W q ty } zt| W Y d }~qd }~0 0 qW nL | j|fy   tj	tj	tjd d }tdj|tjd Y n0 d S )Nr   c                   @   s   e Zd ZdS )zcli.<locals>.BadUsageN)r+   r    r!   r   r   r   r   BadUsage
  r   r$  rL   zbk:n:p:wFr  z-bTz-kz-pz-wz-n)r  r  zfile %r does not exista  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  )getoptrz  r#  r   r"  r  r  r  r
   r	   existsr   r   r   r   r'  r#  r   r   r  r   r   r.  r  )r%  r$  Zoptsr   writingZstart_serverr  r  r  optvalargro   r  r   r   r   cli
  s`    

$r+  r  )NN)r   )r   )r  r   N)r  r   N)r   )rE   N)r  )r   )_r_  r}   r   rv   r  Zimportlib._bootstrapr   Zimportlib._bootstrap_externalZimportlib.machineryimportlib.utilr   r  r
   re  r  rF   r   r   r  r   r   urllib.parser`  r  collectionsr   reprlibr   	tracebackr   r   r   r'   r>   r7   rD   rJ   rR   rT   rW   rZ   r`   r>  
IGNORECASEra   rc   re   rj   ru   r   r   r   r   r   r   rz  r   r   r   r   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  rX   r  r"  r  r  r=   r#  r'  r(  r   r  r  r  r  r  r  r!  r#  r+  r+   r   r   r   r   <module>(   s   
3	

'
0:*    ;    ",

  
  


   = 
 n%
U
