AlkantarClanX12

Your IP : 18.191.97.133


Current Path : /opt/alt/python37/lib64/python3.7/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/__pycache__/pydoc.cpython-37.opt-1.pyc

B

� f���@sdZdgZdZdZdZddlZddlZddlZddl	Zddl
ZddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZddlmZdd	lmZd
d�Zdd
�Zdd�Z dd�Z!dd�Z"dd�Z#dd�Z$e�%dej&�Z'dd�Z(dd�Z)dd�Z*dd �Z+d!d"�Z,dzd#d$�Z-d%d&�Z.d'd(�Z/d)d*�Z0d+d,�Z1ifd-d.�Z2Gd/d0�d0e3�Z4d1d2�Z5difd3d4�Z6Gd5d6�d6�Z7Gd7d8�d8e�Z8Gd9d:�d:e7�Z9Gd;d<�d<e�Z:Gd=d>�d>e7�Z;Gd?d@�d@e;�Z<dAdB�a=dCdD�Z>dEdF�Z?dGdH�Z@dIdJ�ZAdKdL�ZBdMdN�ZCdOdP�ZDdQdR�ZEd{dSdT�ZFe;�ZGe<�ZHe9�ZId|dUdV�ZJd}dXdY�ZKd~dZd[�ZLdd\d]�ZMd�d_d`�ZNGdadb�db�ZOeO�ZPGdcdd�dd�ZQdedf�ZRdgdh�ZSd�djdk�ZTd�dldmdn�dodp�ZUdqdr�ZVdsdt�ZWdudv�ZXdwdx�ZYeZdyk�r�eY�dS)�aGenerate Python documentation in HTML or text for interactive use.

At the Python interactive prompt, calling help(thing) on a Python object
documents the object, and calling help() starts up an interactive
help session.

Or, at the shell command line outside of Python:

Run "pydoc <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

    https://docs.python.org/X.Y/library/

This can be overridden by setting the PYTHONDOCS environment variable
to a different URL or to a local directory containing the Library
Reference Manual pages.
�helpzKa-Ping Yee <ping@lfw.org>z26 February 2001z�Guido van Rossum, for an excellent programming language.
Tommy Burnette, the original creator of manpy.
Paul Prescod, for all his work on onlinehelp.
Richard Chamberlain, for the first implementation of textdoc.
�N)�deque)�Repr)�format_exception_onlycCs`g}g}xRtjD]H}tj�|p d�}tj�|�}||krtj�|�r|�|�|�|�qW|S)zAConvert sys.path into a list of absolute, existing, unique paths.�.)�sys�path�os�abspath�normcase�isdir�append)�dirsZnormdirs�dirZnormdir�r�*/opt/alt/python37/lib64/python3.7/pydoc.py�pathdirsPs
rcCs.t�|�pt�|�}|r*t�dd|���p,dS)z-Get the doc string or comments for an object.z^ *
�)�inspect�getdocZgetcomments�re�sub�rstrip)�object�resultrrrr\srcCsf|���d�}t|�dkr&|ddfSt|�dkrX|d��sX|dd�|dd��fSdd�|�fS)z>Split a doc string into a synopsis line (if any) and the rest.�
�rr�N)�strip�split�lenr�join)�doc�linesrrr�splitdocasr$cCs"|j}|j|kr|jd|}|S)z@Get a class name and qualify it with a module name if necessary.r)�__name__�
__module__)r�modname�namerrr�	classnamejs
r)cCs>t�|�p:t�|�p:t�|�p:t�|�p:t�|�p:t�|�S)z>Check if an object is of a type that probably means it's data.)r�ismodule�isclass�	isroutineZisframeZistracebackZiscode)rrrr�isdataqsr-cGs2x,|r,|d�|�|d��}|dd�}qW|S)z/Do a series of global replacements on a string.rrrN)r!r)�textZpairsrrr�replacewsr/cCsXt|�|krTtd|dd�}td|d|�}|d|�d|t|�|d�S|S)zCOmit part of a string if needed to make it fit in a maximum length.r�rNz...)r �max)r.�maxlenZpreZpostrrr�cram~s
$r3z at 0x[0-9a-f]{6,16}(>+)$cCst�d|�S)z>Remove the hexadecimal id from a Python object representation.z\1)�_re_stripidr)r.rrr�stripid�sr5cCs(t�|�p&t�|�p&t�|�p&t�|�S)N)r�
isfunction�ismethod�	isbuiltinZismethoddescriptor)�objrrr�_is_some_method�s


r:cCs<t�|�rdSt�|�r8t|dd�}t�|�p4|dkSdS)zo
    Returns True if fn is a bound method, regardless of whether
    fn was implemented in Python or in C.
    T�__self__NF)rr7r8�getattrr*)�fn�selfrrr�_is_bound_method�s

r?cCshi}x t�|t�D]\}}d||<qWx|jD]}|�t|��q.Wx|��D]}t||�||<qNW|S)Nr)r�
getmembersr:�	__bases__�update�
allmethods�keysr<)�cl�methods�key�value�baserrrrC�srCcCs<g}g}x*|D]"}||�r&|�|�q|�|�qW||fS)z�Split 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�	predicateZyesZno�xrrr�_split_list�s
rMcCs\|dkrdS|�d�r$|�d�r$dS|�d�r<t|d�r<dS|dk	rL||kS|�d�SdS)	z3Decide whether to show documentation on a variable.>�
__loader__�__credits__�__doc__�__file__�__spec__�
__cached__�__qualname__�	__slots__�__date__�__package__�__version__r%�__builtins__�__path__r&�
__author__r�__r�_�_fieldsTN)�
startswith�endswith�hasattr)r(�allr9rrr�visiblename�srccCsDg}x:t�|�D],\}}}}t�|�r*d}|�||||f�qW|S)zCWrap inspect.classify_class_attrs, with fixup for data descriptors.zdata descriptor)r�classify_class_attrs�isdatadescriptorr
)r�resultsr(�kind�clsrHrrrrd�s
rdcs\t|dg��y�fdd�t��D��Wntk
r>i�YnX�fdd�}|j|d�dS)zGSort the attrs list in-place by _fields and then alphabetically by namer^csi|]\}}|t��|�qSr)r )�.0�ir()�fieldsrr�
<dictcomp>�sz#sort_attributes.<locals>.<dictcomp>cs��|dd�|dfS)Nr)�get)�attr)�field_orderrr�<lambda>��z!sort_attributes.<locals>.<lambda>)rGN)r<�	enumerate�	TypeError�sort)�attrsrZkeyfuncr)rorkr�sort_attributes�s
rvcCs<tj�|�r8x*dD]"}tj�tj�|d|��rdSqWdS)z3Guess whether a path refers to a package directory.)z.pyz.pyc�__init__TF)r	rr�isfiler!)r�extrrr�	ispackage�s

rzcCs�|��}x*|dd�dks"|��s2|��}|s
Pq
W|��}|dd�dkrX|dd�}|dd�dkr�|dd�}|dd�dkr�|dd�}x|��s�|��}|s�Pq�W|�d�d	��}nd}|S)
Nr�#�zr"""r0z"""����\r)�readlinerr)�file�linerrrr�source_synopsis�s&
r�c
	Cst�|�j}|�|d�\}}|dks.||k�r|�ttjj��rJtjj	}n |�ttjj
��rftjj}nd}|dkr�yt�
|�}Wntk
r�dSX|�t|�}WdQRXnZ|d|�}tjjd||d�}ytj�|�}	Wn
dStjd=|	j�r|	j��dnd}||f||<|S)z.Get the one-line summary out of a module file.)NNNZ__temp__)�loaderr)r	�stat�st_mtimermr`�tuple�	importlib�	machinery�BYTECODE_SUFFIXES�SourcelessFileLoader�EXTENSION_SUFFIXES�ExtensionFileLoader�tokenize�open�OSErrorr��util�spec_from_file_location�
_bootstrap�_loadr�modulesrP�
splitlines)
�filename�cache�mtimeZ
lastupdaterZ
loader_clsr�r��spec�modulerrr�synopsis�s4



r�c@s eZdZdZdd�Zdd�ZdS)�ErrorDuringImportzEErrors that occurred while trying to import something to document it.cCs||_|\|_|_|_dS)N)r��excrH�tb)r>r��exc_inforrrrw'szErrorDuringImport.__init__cCs|jj}d|j||jfS)Nzproblem in %s - %s: %s)r�r%r�rH)r>r�rrr�__str__+szErrorDuringImport.__str__N)r%r&rTrPrwr�rrrrr�%sr�c		Cs�tjj}t|d��}||�t|��k}WdQRXtj�|�}tj�	|�\}}|r`tj
�||�}ntj
�||�}tjj
|||d�}ytj�|�St|t����YnXdS)z<Import a Python source file or compiled file given its path.�rbN)r�)r�r��MAGIC_NUMBERr��readr r	r�basename�splitext�_bootstrap_externalr��SourceFileLoaderr�r�r�r�rr�)	r�magicr�Zis_bytecoder�r(ryr�r�rrr�
importfile/sr�c	s"yb|rX�tjkrX�tjkrX�fdd�tjD�}x(�g|D]}tj|||<tj|=q:Wt��}Wnxt��\}}}}	�tjkr�ttj�j|	��n<|tkr�t|j|	��n&t	|t
�r�|j�kr�dSt�t����YnXx@��d�dd�D]*}
yt
||
�}Wq�tk
�rdSXq�W|S)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).csg|]}|��d�r|�qS)r)r_)ri�m)rrr�
<listcomp>Uszsafeimport.<locals>.<listcomp>Nrr)rr��builtin_module_names�
__import__r�r�rQ�SyntaxErrorr��
issubclass�ImportErrorr(rr<�AttributeError)r�	forceloadr�ZsubsrGr�r�rHr��info�partr)rr�
safeimportAs.


r�c@sfeZdZej�ddejdd��Zddd�Z	d
dd�Z
e
ZZZ
ZZZe�d	�fd
d�ZdS)�Doc�
PYTHONDOCSz%https://docs.python.org/%d.%d/libraryNrcGs�||f|}t�|�r |j|�St�|�r4|j|�Sy@t�|�rJ|j|�St�|�r^|j|�St�|�rr|j	|�SWnt
k
r�YnXt|t�r�|j
|�S|j|�S)z%Generate documentation for an object.)r�isgetsetdescriptor�docdata�ismemberdescriptorr*�	docmoduler+�docclassr,�
docroutiner��
isinstance�property�docproperty�docother)r>rr(�argsrrr�documentws"










zDoc.documentcGs*d|odt|�t|�jf}t|��dS)z+Raise an exception for unimplemented types.z.don't know how to document object%s of type %s� N)�repr�typer%rs)r>rr(r��messagerrr�fail�szDoc.failZstdlibcCs�yt�|�}Wntk
r&d}YnXtj�d|j�}tj�|�}t	|t
t��r�|jdksz|�|�r�|�tj�
|d��s�|jdkr�|�d�r�d|�d�|j��f}q�tj�
||j��d	�}nd
}|S)z*Return the location of module docs or Nonez
(built-in)r�)
�errno�
exceptionsZgcZimp�marshal�posix�signalr�_threadZ	zipimportz
site-packages)z	xml.etreeztest.pydoc_mod)zhttp://zhttps://z%s/%s�/z.htmlN)r�
getabsfilersr	�environrmr�rrr�r�r%r_r!r�lower)r>rZbasedirr��doclocrrr�	getdocloc�s 




z
Doc.getdocloc)N)N)r%r&rTr	r�rmr�version_infor�r�r�r�r�r�r�r�r��	sysconfigZget_pathr�rrrrr�qs

r�c@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZeZ	dd
�Z
eZdS)�HTMLReprzBClass for safely making an HTML representation of a Python object.cCs,t�|�d|_|_d|_d|_|_dS)N��
�d)rrw�maxlist�maxtuple�maxdict�	maxstring�maxother)r>rrrrw�s
zHTMLRepr.__init__cCst|dddddd�S)N�&z&amp;�<z&lt;�>z&gt;)r/)r>r.rrr�escape�szHTMLRepr.escapecCst�||�S)N)rr�)r>rrrrr��sz
HTMLRepr.reprcCsZtt|�d�r@dd�t|�j���}t||�r@t||�||�S|�ttt	|��|j
��S)Nr%�repr_r])rar�r!r%rr<r�r3r5r�r�)r>rL�level�
methodnamerrr�repr1�s

zHTMLRepr.repr1cCs^t||j�}t|�}d|krJdt|dd�krJd|d|�|�|dSt�dd|�|��S)Nr~z\\r�rrz-((\\[\\abfnrtv\'"]|\\[0-9]..|\\x..|\\u....)+)z<font color="#c040c0">\1</font>)r3r�r�r/r�rr)r>rLr��test�testreprrrr�repr_string�szHTMLRepr.repr_stringcCs8y|�ttt|��|j��S|�d|jj�SdS)Nz
<%s instance>)r�r3r5r�r��	__class__r%)r>rLr�rrr�
repr_instance�szHTMLRepr.repr_instanceN)r%r&rTrPrwr�r�r�r��repr_strr�Zrepr_unicoderrrrr��sr�c@seZdZdZe�ZejZejZdd�Zd5dd�Z	d6d
d�Z
dd
�Zdd�Zd7dd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdiiifdd �Zd8d!d"�Zd9d#d$�Zddiifd%d&�Zd'd(�Zddiiidfd)d*�Zd+d,�Zd:d-d.�Zd;d/d0�Zd<d1d2�Zd=d3d4�ZdS)>�HTMLDocz'Formatter class for HTML documentation.cCsd||fS)zFormat an HTML page.z�<!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�contentsrrr�page�szHTMLDoc.pagercCsd|||||pdfS)zFormat a page heading.a'
<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>
    z&nbsp;r)r>r��fgcol�bgcolZextrasrrr�heading�s	zHTMLDoc.heading�N�&nbsp;c	
Cs^|dkrdd|d}d|||f}	|r@|	d||||f}	n|	d|||f}	|	d|S)	z Format a section with a heading.Nz<tt>z&nbsp;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��widthZpreludeZ
marginaliaZgaprrrr�section�szHTMLDoc.sectioncGsd|}|j|f|��S)z$Format a section with a big heading.z<big><strong>%s</strong></big>)r�)r>r�r�rrr�
bigsectionszHTMLDoc.bigsectionc
Cs&|�|���}t|dddddddd�	S)z!Format literal preformatted text.z

z
 
r�z&nbsp;rz<br>
)r��
expandtabsr/)r>r.rrr�	preformatszHTMLDoc.preformatr|cCs�d}t|�|d|}xht|�D]\}|dd|}x>t|||||�D]$}|t|�krN||||�d}qNW|d}q"Wd|S)z0Format a list of items into a multi-column list.rrz<td width="%d%%" valign=top>r�z<br>
z</td>z7<table width="100%%" summary="list"><tr>%s</tr></table>)r �range)r>�list�formatZcolsr�rows�colrjrrr�multicolumnszHTMLDoc.multicolumncCsd|S)Nz<font color="#909090">%s</font>r)r>r.rrr�grey"rqzHTMLDoc.greycGs*x$|D]}||krd|||fSqW|S)z:Make a link for an identifier, given name-to-URL mappings.z<a href="%s">%s</a>r)r>r(Zdicts�dictrrr�namelink$s
zHTMLDoc.namelinkcCsN|jtj�|j�}}t||�rDt||�|krDd|j|t||�fSt||�S)zMake a link for a class.z<a href="%s.html#%s">%s</a>)r%rr�rmr&rar<r))r>rr'r(r�rrr�	classlink+s
zHTMLDoc.classlinkcCsd|j|jfS)zMake a link for a module.z<a href="%s.html">%s</a>)r%)r>rrrr�
modulelink3szHTMLDoc.modulelinkcCsR|\}}}}|r|�|�S|r,d||f}nd|}|rBd|}n|}d||fS)z;Make a link for a module or package to display in an index.z
%s.%s.htmlz%s.htmlz"<strong>%s</strong>&nbsp;(package)z<a href="%s">%s</a>)r)r>Z
modpkginfor(rrz�shadowed�urlr.rrr�
modpkglink7s

zHTMLDoc.modpkglinkcCsd||fS)zMake a link to source file.z<a href="file:%s">%s</a>r)r>r	rrrr�filelinkFszHTMLDoc.filelinkcCs�|p|j}g}d}t�d�}�xL|�||�}	|	s2P|	��\}
}|�||||
���|	��\}}
}}}}|
r�||��dd�}|�d||f�n�|r�dt|�}|�d|||�f�n�|r�dt|�}|�d|||�f�n�|�r$|||d�d	k�r|�d
|�	||��n|�d|�n@|||d�d	k�rR|�|�	||||��n|�|�	||��|}q W|�|||d���d
�
|�S)z�Mark up some plain text, given a context of symbols to look for.
        Each context dictionary maps object names to anchor names.rzD\b((http|ftp)://\S+[\w/]|RFC[- ]?(\d+)|PEP[- ]?(\d+)|(self\.)?(\w+))�"z&quot;z<a href="%s">%s</a>z'http://www.rfc-editor.org/rfc/rfc%d.txtz(http://www.python.org/dev/peps/pep-%04d/r�(zself.zself.<strong>%s</strong>Nr)r�r�compile�search�spanr
�groupsr/�intrr!)r>r.r��funcs�classesrFrf�here�pattern�match�start�endrbZschemeZrfcZpepZselfdotr(r	rrr�markupJs<

zHTMLDoc.markupc
Cs�d}x�|D]�}t|�td�kr�|\}}|d}||�||�}|r�||fkr�g}x|D]}	|�|�|	|��qVW|dd�|�d}|d}q
t|�tg�kr
|d|�|||�}q
Wd	|S)
zAProduce HTML for a class tree as given by inspect.getclasstree().rrz"<dt><font face="helvetica, arial">r
z, �)z
</font></dt>z
<dd>
%s</dd>
z
<dl>
%s</dl>
)r�rr
r!�
formattree)
r>�treer'�parentr�entry�c�bases�parentsrIrrrrus 


zHTMLDoc.formattreec#
s�|j}y
|j}Wntk
r(d}YnX|�d�}g}x@tt|�d�D],}|�dd�|d|d��||f�qJWd�||dd��}	d|	}
y&t�	|�}t
j�|�}��
||�}
Wntk
r�d}
YnXg}t|d��r:t|j�}|dd	�d
k�r&|dd�dk�r&|d	d���}|�d��|��t|d
��r\|���t|j���|�rt|
dd�|�}
��|�}|dk	�r�dt�}nd}��|
ddd|
|�}t�|tj�}gi}}xlt�|tj�D]Z\}}|dk	�st�|��p�||k�r�t|||��r�|�||f�d|||<||<�q�Wx�|D]�\}}xx|jD]n}|j|j}}tj �!|�}||k�rL|�rLt||��rLt"||�|k�rL||k�rL|d|||<||<�qLW�q<Wgi}}x�t�|tj#�D]p\}}|dk	�st�$|��st�|�|k�r�t|||��r�|�||f�d|||<t�%|��r�||||<�q�Wg}x6t�|t&�D]&\}}t|||��rd|�||f��qdW��'t(|��j)||�}|�o�d|}|d|}t|d��r*g}x.t*�+|j,�D]\}}} |�||| df��q�W|�-���.|�j/�}!|��0ddd|!�}n.|�rX��.|�fdd��}!|��0d dd|!�}|�r�d!d"�|D�}"��1t�2|"d�|�g}!x*|D]"\}}|!���3|||||���q�W|��0d#dd$d%�|!��}|�rg}!x*|D]"\}}|!���3|||||���q�W|��0d&dd'd%�|!��}|�rbg}!x$|D]\}}|!���3||���q(W|��0d(dd)d*�|!��}t|d+��r���'t|j4��j)�}!|��0d,dd|!�}t|d-��rʈ�'t|j5��j)�}!|��0d.dd|!�}|S)/z/Produce HTML documentation for a module object.Nrrz5<a href="%s.html"><font color="#ffffff">%s</font></a>r}z)<big><big><strong>%s</strong></big></big>z
(built-in)rX�z$Revision: �$z
version %srVz (%s)z, z-<br><a href="%(docloc)s">Module Reference</a>rz#ffffffz#7799eez<a href=".">index</a><br>r{z.html#z#-z<tt>%s</tt>z
<p>%s</p>
rZrzPackage Contentsz#aa55cccs��|d�S)Nr)r)�t)r>rrrp�rqz#HTMLDoc.docmodule.<locals>.<lambda>ZModulescSsg|]\}}|�qSrr)rirGrHrrrr��sz%HTMLDoc.docmodule.<locals>.<listcomp>ZClassesz#ee77aar�Z	Functionsz#eeaa77ZDataz#55aa55z<br>
r[ZAuthorrOZCredits)6r%�__all__r�rr�r r
r!rr��urllib�parseZquoterrsra�strrXrr�rVr��localsr�r@r*r+�	getmodulercrAr&rr�rmr<r,r8r6r-rrr��pkgutil�iter_modulesrZrtrr
r�r�getclasstreer�r[rO)#r>rr(�mod�ignoredrb�partsZlinksrjZ
linkedname�headrr	rr��versionr�rr�rZcdictrGrHrIr'r�rZfdict�datar"�modpkgs�importer�ispkgr��	classlistr)r>rr��s�


&


$




$

zHTMLDoc.docmodulec	sz�j}|p|}�j}g}	|	j�G�fdd�d�}
|
��tt����}t|�dkr�����d�x"|D]}�d��|�j	��qfW�d���������fdd�}
����fd	d
�}��������fdd�}�fd
d�t
��D�}i�xv|D]n\}}}}d|d|�|<}yt�|�}Wntk
�r:YnXy|�|<Wq�t
k
�r^Yq�Xq�Wx�|�rT|�r||���n|dd�t|�fdd��\}}�tjk�r�|}�qfn"��k�r�d}nd����j	�}|d7}t|��|
d||dd��}|
d||dd��}|
d||dd��}|d||dd��}|d||d d��}|}�qfWd!�|	�}	||k�rxd"||f}nd#|||f}|�r�g}x"|D]}|���|�j	���q�W|d$d%�|�}d!}yt���}Wntt
fk
�r�d&}YnX|�r(t|�}|�r(|d'k�r(|��|�d(}t��}|�rD||�p@d!}��|�j����}|�odd)|}��|d*d+|	d,|�S)-z.Produce HTML documentation for a class object.cs eZdZdd�Z�fdd�ZdS)z(HTMLDoc.docclass.<locals>.HorizontalRulecSs
d|_dS)Nr)�needone)r>rrrrw
sz1HTMLDoc.docclass.<locals>.HorizontalRule.__init__cs|jr�d�d|_dS)Nz<hr>
r)r9)r>)�pushrr�maybesz.HTMLDoc.docclass.<locals>.HorizontalRule.maybeN)r%r&rTrwr;r)r:rr�HorizontalRulesr<rz&<dl><dt>Method resolution order:</dt>
z<dd>%s</dd>
z</dl>
cs�t||�\}}|r�����|�xl|D]d\}}}}yt�|�}Wn&tk
rh���||���YnX���||��������d�q(W|S)Nr)rMr;r<�	Exception�_docdescriptorr�)�msgrurK�okr(rg�homeclsrH)rr�hr�mdictr/rr:r>rr�spillszHTMLDoc.docclass.<locals>.spillcsNt||�\}}|rJ����|�x&|D]\}}}}���||���q(W|S)N)rMr;r>)r?rurKr@r(rgrArH)rBr/r:r>rr�spilldescriptors1sz*HTMLDoc.docclass.<locals>.spilldescriptorsc
s�t||�\}}|r�����|�x�|D]�\}}}}��t�|�|��}t|�sZt�|�rht|dd�}	nd}	|	dkr��d|�n0��t|��j	����}	d|	}	�d||	f��d�q(W|S)NrPz<dl><dt>%s</dl>
z<dd><tt>%s</tt>z<dl><dt>%s%s</dl>
r)
rMr;r�r<�callablerrerrr�)
r?rurKr@r(rgrArHrIr")rrrBrCr/rr:r>rr�	spilldata:s"
z#HTMLDoc.docclass.<locals>.spilldatacs,g|]$\}}}}t|�d�r||||f�qS))r9)rc)rir(rgrhrH)rrrr�Os
z$HTMLDoc.docclass.<locals>.<listcomp>r{�-rcs|d�kS)Nrr)r%)�	thisclassrrrphrqz"HTMLDoc.docclass.<locals>.<lambda>zdefined herezinherited from %sz:<br>
z
Methods %scSs|ddkS)Nr�methodr)r%rrrrpxrqzClass methods %scSs|ddkS)Nrzclass methodr)r%rrrrpzrqzStatic methods %scSs|ddkS)Nrz
static methodr)r%rrrrp|rqzData descriptors %scSs|ddkS)Nrzdata descriptorr)r%rrrrp~rqzData and other attributes %scSs|ddkS)Nrr4r)r%rrrrp�rqrz*<a name="%s">class <strong>%s</strong></a>z/<strong>%s</strong> = <a name="%s">class %s</a>z(%s)z, Nz()z

z<tt>%s<br>&nbsp;</tt>z#000000z#ffc8d8r0)r%rAr
rr�getmror r;rr&rdr<r=rs�popleftrM�builtinsrrvr!�	signature�
ValueErrorr)r�rrr�r�)r>rr(r/rrr0�realnamer!r�r<�mrorIrDrErGrurGrgrArH�anchor�	inherited�tagr�r"�declrN�argspecr"r)	rrrBrCr/rr:r>rIrr�s�

	




















zHTMLDoc.docclasscCs|�d|�|��S)z)Format an argument default value as text.�=)rr�)r>rrrr�formatvalue�szHTMLDoc.formatvaluec	Cs�|j}|p|}|r|jpdd|}	d}
d}t|�r�|jj}|rZ||k	r�d|�||�}
n0|jdk	rzd|�|jj|�}
nd|�||�}
||kr�d|	|f}
nD|r�t�||g�|kr�d	|jd||f}d
}n|}d|	||f}
d}t�|��rNyt�|�}Wnt	t
fk
�r d}YnX|�rNt|�}|dk�rNd
|}
|d
d�}|�sXd}|
|�|�|
�ov|�
d|
�}|�r�d|S|�t|�|j|||�}|�o�d|}d||fSdS)z;Produce HTML documentation for a function or method object.rrHrz from Nz method of %s instancez unbound %s methodz$<a name="%s"><strong>%s</strong></a>z<a href="#%s">%s</a>rz)<a name="%s"><strong>%s</strong></a> = %sz<lambda>z$<strong>%s</strong> <em>lambda</em> r}z(...)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%r?r;r�rr�getattr_staticr,rNrOrsr)r�rrrr�)r>rr(r/rrrFrErPrR�note�skipdocs�imclassr�ZreallinkrVrNrUr"rrrr��sX


zHTMLDoc.docroutinecCsTg}|j}|r|d|�|jdk	rB|�t|�|j�}|d|�|d�d�|�S)Nz!<dl><dt><strong>%s</strong></dt>
z<dd><tt>%s</tt></dd>
z</dl>
r)r
rPrrr�r!)r>r(rHr/rfr:r"rrrr>�s
zHTMLDoc._docdescriptorcCs|�|||�S)z*Produce html documentation for a property.)r>)r>rr(r/rErrrr��szHTMLDoc.docpropertycGs|rd|pd}||�|�S)z-Produce HTML documentation for a data object.z<strong>%s</strong> = r)r�)r>rr(r/r0Zlhsrrrr��szHTMLDoc.docothercCs|�|||�S)z1Produce html documentation for a data descriptor.)r>)r>rr(r/rErrrr��szHTMLDoc.docdatacCs�g}|dkri}xLt�|g�D]<\}}}tdd�|D��r<q|�|d|||kf�d||<qW|��|�||j�}|�|dd|�S)z2Generate an HTML index for a directory of modules.Ncss*|]"}dt|�kodknVqdS)i�i��N)�ord)ri�chrrr�	<genexpr>sz HTMLDoc.index.<locals>.<genexpr>rrz#ffffffz#ee77aa)r,r-�anyr
rtrr
r�)r>rrr5r6r(r7r�rrr�index�sz
HTMLDoc.index)r)r�rNr�)r|)N)NN)NNN)NN)NNN)N)r%r&rTrPr��_repr_instancer�r�r�r�r�r�r�rrrrrr
rrrr�r�rXr�r>r�r�r�rarrrrr��s<



+

y$:


r�c@s4eZdZdZdd�Zdd�Zdd�ZeZdd	�Zd
S)�TextReprzAClass for safely making a text representation of a Python object.cCs,t�|�d|_|_d|_d|_|_dS)Nr�r�r�)rrwr�r�r�r�r�)r>rrrrws
zTextRepr.__init__cCsTtt|�d�r@dd�t|�j���}t||�r@t||�||�Sttt|��|j	�S)Nr%r�r])
rar�r!r%rr<r3r5r�r�)r>rLr�r�rrrr�s

zTextRepr.repr1cCsHt||j�}t|�}d|krDdt|dd�krDd|d||dS|S)Nr~z\\rr�r)r3r�r�r/)r>rLr�r�r�rrrr�s
zTextRepr.repr_stringcCs,yttt|��|j�Sd|jjSdS)Nz
<%s instance>)r3r5r�r�r�r%)r>rLr�rrrr�(szTextRepr.repr_instanceN)	r%r&rTrPrwr�r�r�r�rrrrrcs	rcc@s�eZdZdZe�ZejZdd�Zddd�Zdd�Z	ddd�Z
dd
d�Zd dd�Zdd�Z
d!dd�Zdd�Zd"dd�Zd#dd�Zd$dd�Zd	S)%�TextDocz'Formatter class for text documentation.cCsd�dd�|D��S)z(Format a string in bold by overstriking.rcss|]}|d|VqdS)�Nr)rir^rrrr_8szTextDoc.bold.<locals>.<genexpr>)r!)r>r.rrr�bold6szTextDoc.bold�    cs>|sdS�fdd�|�d�D�}|r4|d��|d<d�|�S)z6Indent text by prepending a given prefix to each line.rcsg|]}�|�qSrr)rir�)�prefixrrr�=sz"TextDoc.indent.<locals>.<listcomp>rr})rrr!)r>r.rhr#r)rhr�indent:szTextDoc.indentcCs$|�|���}|�|�d|dS)z&Format a section with a given heading.rz

)rirrf)r>r�r�Zclean_contentsrrrr�AszTextDoc.sectionNrc
	s�d}x�|D]�}t|�td�krt|\}}||t|��}|rj||fkrj�fdd�|D�}	|dd�|	�}|d}q
t|�tg�kr
||�|�||d�}q
W|S)	zBRender in text a class tree as returned by inspect.getclasstree().rrc3s|]}t|��VqdS)N)r))rir )r'rrr_Psz%TextDoc.formattree.<locals>.<genexpr>z(%s)z, rz    )r�r)r!r)
r>rr'rrhrrr r!r"r)r'rrHs

zTextDoc.formattreec	CsD|j}tt|��\}}|�d||o(d|�}t|dd�}|�|�}|dk	r`||�d|d�}|rt||�d|�}g}	xNt�|tj�D]<\}
}|dk	s�t�	|�p�||kr�t
|
||�r�|	�|
|f�q�Wg}xXt�|tj�D]F\}
}|dk	�st�
|��st�	|�|kr�t
|
||�r�|�|
|f�q�Wg}
x6t�|t�D]&\}
}t
|
||��r8|
�|
|f��q8Wg}t�}t|d��r�xFt�|j�D]6\}}}|�|�|�r�|�|d	�n
|�|��q�W|��||�d
d�|��}g}xBt�|tj�D]0\}
}|j�|d��r�|
|k�r�|�|
��q�W|�rJ|��||�d
d�|��}|	�r�dd�|	D�}|�t�|d�|�g}x&|	D]\}
}|�|�||
|���qzW||�dd�|��}|�r�g}x&|D]\}
}|�|�||
|���q�W||�dd�|��}|
�rFg}x*|
D]"\}
}|�|j||
|dd���q
W||�dd�|��}t|d��r�t|j�}|dd�dk�r�|dd�dk�r�|dd���}||�d|�}t|d��r�||�dt|j ��}t|d��r�||�dt|j!��}t|d ��r||�d!t|j"��}yt�#|�}Wnt$k
�r.d"}YnX||�d#|�}|S)$z5Produce text documentation for a given module object.�NAMEz - r&NzMODULE 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.
ZDESCRIPTIONrZz
 (package)zPACKAGE CONTENTSrrZ
SUBMODULEScSsg|]\}}|�qSrr)rirGrHrrrr��sz%TextDoc.docmodule.<locals>.<listcomp>r�CLASSES�	FUNCTIONS�F)r2ZDATArXr#z$Revision: r}r$ZVERSIONrVZDATEr[ZAUTHORrOZCREDITSz
(built-in)ZFILE)%r%r$rr�r<r�rr@r+r+rcr
r,r8r-�setrar,r-rZ�addrtr!r*r_rr.r�r�r)rXrrVr[rOr�rs)r>rr(r/Zsynop�descrrbr�rrGrHrr4r5Z
modpkgs_namesr6r'r7Z
submodulesr8r�r3r�rrrr�Xs�





$
zTextDoc.docmodulec	s��j}|p|}�j}�jfdd�}||kr:d��|�}n��|�d|}|rlt||�}	|dd�|	�}g}
|
j�yt���}Wnt	t
fk
r�d}YnX|r�t|�}|r�|dkrʈ||d	�t��}
|
r�|
d	�t
t����}t|�d
k�r.�d�x|D]}�d||���qW�d
�G�fdd�d�}|�������fdd�}����fdd�}�����fdd�}�fdd�t��D�}x�|�r||�r�|���n|dd
�t|�fdd��\}}�tjk�r�|}�q�n ��k�r�d}ndt��j�}t|��|d||dd��}|d||d d��}|d!||d"d��}|d#||d$d��}|d%||d&d��}|}�q�Wd	�|
�}
|
�s�|d	S|d	��|
��d'�d	S)(z4Produce text documentation for a given class object.cSs
t||�S)N)r))r r�rrr�makename�sz"TextDoc.docclass.<locals>.makenamezclass z	 = class z(%s)z, Nz()rrzMethod resolution order:z    rcs eZdZdd�Z�fdd�ZdS)z(TextDoc.docclass.<locals>.HorizontalRulecSs
d|_dS)Nr)r9)r>rrrrw�sz1TextDoc.docclass.<locals>.HorizontalRule.__init__cs|jr�d�d|_dS)NzF----------------------------------------------------------------------r)r9)r>)r:rrr;�sz.TextDoc.docclass.<locals>.HorizontalRule.maybeN)r%r&rTrwr;r)r:rrr<�sr<c
s�t||�\}}|r�����|�x^|D]V\}}}}yt�|�}Wn&tk
rh���||���Yq(X���||����q(W|S)N)rMr;r<r=r>r�)r?rurKr@r(rgrArH)rBr/rr:r>rrrD�szTextDoc.docclass.<locals>.spillcsNt||�\}}|rJ����|�x&|D]\}}}}���||���q(W|S)N)rMr;r>)r?rurKr@r(rgrArH)rBr/r:r>rrrEsz*TextDoc.docclass.<locals>.spilldescriptorsc
	s�t||�\}}|r�����|�x~|D]v\}}}}t|�sFt�|�rPt|�}nd}yt�|�}	Wntk
r�|j|}	YnX��j	|	|�d|d�d�q(W|S)Nrm)r2r"r)
rMr;rFrrerr<r��__dict__r�)
r?rurKr@r(rgrArHr"r9)rBr/rr:r>rrrG
s
z#TextDoc.docclass.<locals>.spilldatacs,g|]$\}}}}t|�d�r||||f�qS))r9)rc)rir(rgrhrH)rrrr�s
z$TextDoc.docclass.<locals>.<listcomp>rcs|d�kS)Nrr)r%)rIrrrp%rqz"TextDoc.docclass.<locals>.<lambda>zdefined herezinherited from %szMethods %s:
cSs|ddkS)NrrJr)r%rrrrp4rqzClass methods %s:
cSs|ddkS)Nrzclass methodr)r%rrrrp6rqzStatic methods %s:
cSs|ddkS)Nrz
static methodr)r%rrrrp8rqzData descriptors %s:
cSs|ddkS)Nrzdata descriptorr)r%rrrrp:rqzData and other attributes %s:
cSs|ddkS)Nrr4r)r%rrrrp<rqz |  )r%rAr&rf�mapr!r
rrNrOrsr)rrrKr rdrLrMrMrr)rvrir)r>rr(r/r0rPr!rqr�r"r�rNrVr"rQrIr<rDrErGrurSrTr)rBr/rr:r>rIrr��s�


	
















zTextDoc.docclasscCsd|�|�S)z)Format an argument default value as text.rW)r�)r>rrrrrXFszTextDoc.formatvaluec	Csr|j}|p|}d}d}t|�rn|jj}|rB||k	rndt||�}n,|jdk	r`dt|jj|�}ndt||�}||kr�|�|�}	n,|r�t�||g�|kr�d}|�|�d|}	d}
t�|��ryt�	|�}Wnt
tfk
r�d}YnX|�rt|�}
|d	k�r|�|�d
}	|
dd�}
|
�s&d}
|	|
|}|�r@|d
St
|��pLd}
|d
|
�oj|�|
���d
SdS)z;Produce text documentation for a function or method object.rrz from Nz method of %s instancez unbound %s methodrz = z<lambda>z lambda r}z(...)r)r%r?r;r�r)rfrrYr,rNrOrsr)rrir)r>rr(r/rErPrZr[r\r�rVrNrUr"rrrr�JsH


zTextDoc.docroutinecCsTg}|j}|r$||�|��|d�t|�p.d}|rJ||�|��|d�d�|�S)Nrr)r
rfrrir!)r>r(rHr/rfr:r"rrrr>{szTextDoc._docdescriptorcCs|�|||�S)z*Produce text documentation for a property.)r>)r>rr(r/rErrrr��szTextDoc.docpropertycCs|�|||�S)z1Produce text documentation for a data descriptor.)r>)r>rr(r/rErrrr��szTextDoc.docdatac
Cs�|�|�}|rF|r|dpd|}|t|�}	|	dkrF|d|	�d}|rX|�|�dpZd|}|dk	r~|d|�t|��7}|S)z-Produce text documentation for a data object.z = rrNz...r)r�r rfrir))
r>rr(r/rr2r"r�r�Zchoprrrr��s
zTextDoc.docother)rg)Nr)NN)NN)NNN)NNN)NNN)NNNNN)r%r&rTrPrcrbr�rfrir�rr�r�rXr�r>r�r�r�rrrrrd.s 


e


1

rdc@seZdZdZdd�ZdS)�
_PlainTextDocz2Subclass of TextDoc which overrides string stylingcCs|S)Nr)r>r.rrrrf�sz_PlainTextDoc.boldN)r%r&rTrPrfrrrrrt�srtcCst�at|�dS)zCThe first time this is called, determine what kind of pager to use.N)�getpager�pager)r.rrrrv�srvc	s8ttjd�stSttjd�s tStj��r4tj��s8tStj�d�pNtj�d���r�tj	dkrj�fdd�Stj�d�dkr��fd	d�S�fd
d�Stj�d�dkr�tStj	dkr�dd�Sttd�r�t�
d
�dkr�dd�Sddl}|��\}}t�
|�z0ttd��r t�
d|�dk�r dd�StSWdt�|�XdS)z2Decide what method to use for paging through text.�isattyZMANPAGERZPAGERZwin32cstt|���S)N)�
tempfilepager�plain)r.)�	use_pagerrrrp�rqzgetpager.<locals>.<lambda>ZTERM)ZdumbZemacscstt|���S)N)�	pipepagerry)r.)rzrrrp�rqcs
t|��S)N)r{)r.)rzrrrp�rqcSstt|�d�S)Nzmore <)rxry)r.rrrrp�rq�systemz(less) 2>/dev/nullrcSs
t|d�S)NZless)r{)r.rrrrp�rqNz	more "%s"cSs
t|d�S)NZmore)r{)r.rrrrp�rq)rar�stdin�
plainpager�stdoutrwr	r�rm�platformr|�tempfileZmkstemp�close�ttypager�unlink)r��fdr�r)rzrru�s6


 rucCst�dd|�S)z%Remove boldface formatting from text.z.r)rr)r.rrrry�sryc	Cs�ddl}|j|d|jd�}yDtj|jdd��*}y|�|�Wntk
rPYnXWdQRXWntk
rrYnXx(y|�	�PWqvtk
r�YqvXqvWdS)z3Page through text by feeding it to another program.rNT)�shellr}�backslashreplace)�errors)
�
subprocess�Popen�PIPE�io�
TextIOWrapperr}�write�KeyboardInterruptr��wait)r.�cmdr��proc�piperrrr{�s r{c	Cs`ddl}|��}t|ddd��}|�|�WdQRXzt�|d|d�Wdt�|�XdS)z<Page through text by invoking a program on a temporary file.rN�wr�)r�z "r)r�Zmktempr�r�r	r|r�)r.r�r�r�r�rrrrx�srxcCs$ttjdd�pd}|�|d��|�S)N�encodingzutf-8r�)r<rr�encode�decode)r.r�rrr�_escape_stdout�sr�c
Cs�tt|���d�}y2ddl}tj��}|�|�}|�|�dd�}Wn(t	t
tjfk
rld}dd�}YnX�z2yt
tj�dd��}Wntk
r�d}YnX|dkr�d	}|d}}tj�d�|d|��d�x�||d��r�tj�d
�tj��|�}	|	dk�rtj�d�Pn,|	d
k�rJtj�d||d�|d}q�|	dk�rn|||}|dk�rnd}tj�dd�||||��d�||}q�WWd|�r�|�||j|�XdS)z%Page through text on a text terminal.rrNcSstj�d�S)Nr)rr}r�rrrrrp�rqzttypager.<locals>.<lambda>cSstj��dd�dd�S)Nr}r)rr}rrrrrrprqZLINESr�z
-- more --)�q�Qz
          
)�
r)�b�B�)ryr�r�ttyrr}�filenoZ	tcgetattrZ	setcbreakr�r�r��UnsupportedOperationrr	r�rmrOrr�r!�flushZ	tcsetattrZ	TCSAFLUSH)
r.r#r�r��oldZgetchar�hr�Zincr rrrr��sL








&r�cCstj�tt|���dS)z>Simply print unformatted text.  This is the ultimate fallback.N)rrr�ryr�)r.rrrr~"sr~cCs�t�|�r>|jtjkr d|jSt|d�r4d|jSd|jSt�|�rRd|jSt�|�rtd|jj	|jj|jfSt�
|�r�d|jj	|jj|jfSt�|�r�d|jSt�|�r�d	|jSt�
|�r�d
|jSt|�jS)z/Produce a short description of the given thing.zbuilt-in module rZzpackage zmodule zbuilt-in function zgetset descriptor %s.%s.%szmember descriptor %s.%s.%szclass z	function zmethod )rr*r%rr�rar8r��__objclass__r&r�r+r6r7r�)�thingrrr�describe&s.
















r�c	Cs�dd�|�d�D�}d\}}xB|t|�kr^td�|d|d��|�}|rZ||d}}qPqW|rj|}nt}x8||d�D](}yt||�}Wq|tk
r�dSXq|W|S)z@Locate an object by name or dotted path, importing as necessary.cSsg|]}|r|�qSrr)rir�rrrr�Cszlocate.<locals>.<listcomp>r)NrNr)rr r�r!rMr<r�)rr�r1r��nZ
nextmodulerr�rrr�locateAs 
r�cCsVt|t�r0t||�}|dkr(td|��||fSt|dd�}|t|t�rL|ndfSdS)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�r)r�r�r<)r�r�rr(rrr�resolveZs


r�� Python Library Documentation: %scCs�|dkrt}t||�\}}t|�}t�|�}|rTd|krT|d|d|�d��7}n|rn||k	rn|d|j7}t�|�s�t�|�s�t�	|�s�t�
|�s�t�|�s�t|t
�s�t|�}|d7}||d|�||�S)zBRender text documentation, given an object or a path to an object.Nrz in z in module z objectz

)r.r�r�rr+�rfindr%r*r+r,r�r�r�r�r�r�)r�r�r�Zrendererrr(rpr�rrr�
render_dochs$






r�c
Csfy2|dkrtt|||��n|�t|||t��Wn.ttfk
r`}zt|�Wdd}~XYnXdS)zCDisplay text documentation, given an object or a path to an object.N)rvr�r��	plaintextr�r��print)r�r�r��outputrHrrrr"�sr"c
Cs�y`t||�\}}t�t|�t�||��}t|dddd��}|�|�WdQRXtd|d�Wn.tt	fk
r�}zt|�Wdd}~XYnXdS)z<Write HTML documentation to a file in the current directory.z.htmlr�zutf-8)r�NZwrote)
r��htmlr�r�r�r�r�r�r�r�)r�r�rr(r�r�rHrrr�writedoc�sr�rcCs6|dkri}x$t�|g|�D]\}}}t|�qWdS)zAWrite out HTML documentation for all modules in a directory tree.N)r,�
walk_packagesr�)r�pkgpathZdoner6r'r7rrr�	writedocs�s
r�cJ@s*eZdZddddddddddd	d
ddd
ddddddddddddddddddddd�#Zd d!�d"D�Zd�e�d'd(d)d*d+d,d-�Zd.d/d0d1d2d3d4d5d6d7d8d9d9d:d:d;�ZxJe��D]>\ZZ	x4e	D],Z
e�e
e�Zeekr�ed<eZeee
<q�Wq�Wd=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdLdMdNdOdPdQddRdSdSdTdUdVdWdXdYdZd[d\d]d^d_d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{ddd|d}d~dd��IZd�d�d��Z
ed�d���Zed�d���Zd�d��Ze�Zefd�d��Zd�d��Zd�d��Zd�d��Zd�d��Zd�d�d��Zd�d��Zd�d��Zd�d��Zd�d�d��Zd�d�d��Zd�d��Zd�d�d��Z d�S)��Helperr�BOOLEAN�with)�assertr)�asyncr)�awaitr)�breakz	while for)�classzCLASSES SPECIALMETHODS)�continuez	while for)Zfunctionr)�del�BASICMETHODS�if)�elsez	while for�try)�forzbreak continue while�import)�globalznonlocal NAMESPACES)r��
TRUTHVALUE)r��MODULES)�in�SEQUENCEMETHODS�
COMPARISON)�lambdarl)�nonlocalzglobal NAMESPACES)�passr)�raise�
EXCEPTIONS)�returnrl)r�r�)�whilezbreak continue if TRUTHVALUE)r�z CONTEXTMANAGERS EXCEPTIONS yield)�yieldr)#�False�None�True�and�asr�r�r�r�r�r��defr��elifr��except�finallyr��fromr�r�r�r��isr�r��not�orr�r�r�r�r�r�r�cCsg|]}dD]}||�qqS))�'rr)ri�pr�rrrr��szHelper.<listcomp>)r��fr��ur��'''r�""")�+rH�*z**r�z//�%z<<z>>r��|�^�~r�r�z<=z>=z==z!=z<>)r�r�z<=z>=z==z!=z<>)rHr�)z+=z-=z*=z/=z%=z&=z|=z^=z<<=z>>=z**=z//=)z<<z>>r�r�r�r�)�j�J)�STRINGS�	OPERATORSr��UNARY�AUGMENTEDASSIGNMENT�BITWISE�COMPLEXzOPERATORS FORMATTING�POWERzTUPLES LISTS FUNCTIONSz ATTRIBUTES FLOAT MODULES OBJECTS�ELLIPSISzSLICINGS DICTIONARYLITERALSz	def classr��PRIVATENAMESzPRIVATENAMES SPECIALMETHODSZ
BACKQUOTESzTUPLES FUNCTIONS CALLSzLISTS SUBSCRIPTS SLICINGS)r�z**�,rz...�:�@r~r]r\�`r
r�[�]r�)�typeszRSTRINGS UNICODE NUMBERS SEQUENCES MAPPINGS FUNCTIONS CLASSES MODULES FILES inspect)�stringsz4str UNICODE SEQUENCES STRINGMETHODS FORMATTING TYPES)zstring-methodszSTRINGS FORMATTING)Z
formatstringsr�)rz:encodings unicode SEQUENCES STRINGMETHODS FORMATTING TYPES)ZnumberszINTEGER FLOAT COMPLEX TYPES)Zintegersz	int range)Zfloatingz
float math)Z	imaginaryz
complex cmath)Ztypesseqz$STRINGMETHODS FORMATTING range LISTS�DICTIONARIES)Ztypesfunctionsz	def TYPES)Ztypesmethodszclass def CLASSES TYPES)zbltin-code-objectszcompile FUNCTIONS TYPES)zbltin-type-objectsztypes TYPES�TYPES)zbltin-null-objectr)zbltin-ellipsis-object�SLICINGS)Zspecialattrsr)r�z!class SPECIALMETHODS PRIVATENAMES)Ztypesmodulesr�)zoperator-summaryz�lambda or and not in is BOOLEAN COMPARISON BITWISE SHIFTING BINARY FORMATTING POWER UNARY ATTRIBUTES SUBSCRIPTS SLICINGS CALLS TUPLES LISTS DICTIONARIES�EXPRESSIONS)Zobjectsr)ZspecialnameszbBASICMETHODS ATTRIBUTEMETHODS CALLABLEMETHODS SEQUENCEMETHODS MAPPINGMETHODS NUMBERMETHODS CLASSES)Z
customizationzhash repr str SPECIALMETHODS)zattribute-accesszATTRIBUTES SPECIALMETHODS)zcallable-typeszCALLS SPECIALMETHODS)zsequence-typesz(SEQUENCES SEQUENCEMETHODS SPECIALMETHODS)zsequence-typeszMAPPINGS SPECIALMETHODS)z
numeric-typesz*NUMBERS AUGMENTEDASSIGNMENT SPECIALMETHODS)Z	execmodelz%NAMESPACES DYNAMICFEATURES EXCEPTIONS)Znamingz3global nonlocal ASSIGNMENT DELETION DYNAMICFEATURES)zdynamic-featuresr�
NAMESPACES)r�ztry except finally raise)Zconversionsr)Zidentifierszkeywords SPECIALIDENTIFIERS)z
id-classesr)zatom-identifiersr)z
atom-literalsz=STRINGS NUMBERS TUPLELITERALS LISTLITERALS DICTIONARYLITERALS�	SEQUENCES)Z	exprlistszTUPLES LITERALS)ztypesseq-mutable�LISTLITERALS)ZlistszLISTS LITERALS)Ztypesmapping�DICTIONARYLITERALS)rzDICTIONARIES LITERALS)zattribute-referencesz(getattr hasattr setattr ATTRIBUTEMETHODS)Z
subscriptionsr�)Zslicingsr�)Zcallsr)Zpowerr)Zunaryr)Zbinaryr)Zshiftingr)Zbitwiser)ZcomparisonszEXPRESSIONS BASICMETHODS)ZbooleanszEXPRESSIONS TRUTHVALUEr�)Z
assignmentr�)Z	augassign�
NUMBERMETHODSr�r�)Zcompoundzfor while break continue)�truthz if while and or not BASICMETHODS)ZdebuggerZpdb)zcontext-managersr�)Irr�Z
STRINGMETHODSZ
FORMATTING�UNICODEZNUMBERSZINTEGERZFLOATr�rZMAPPINGSrlZMETHODSZCODEOBJECTSZTYPEOBJECTSZFRAMEOBJECTSZ
TRACEBACKSZNONEr�ZSPECIALATTRIBUTESrkr�ZPACKAGESrr�Z
PRECEDENCEZOBJECTSZSPECIALMETHODSr�ZATTRIBUTEMETHODSZCALLABLEMETHODSr�ZMAPPINGMETHODSr	Z	EXECUTIONrZDYNAMICFEATURESZSCOPINGZFRAMESr�ZCONVERSIONSZIDENTIFIERSZSPECIALIDENTIFIERSr�ZLITERALSZTUPLESZ
TUPLELITERALSZLISTSrrrZ
ATTRIBUTESZ
SUBSCRIPTSrZCALLSr�r�ZBINARYZSHIFTINGr�r�r�Z	ASSERTIONZ
ASSIGNMENTr�ZDELETIONZ	RETURNINGZ	IMPORTINGZCONDITIONALZLOOPINGr�Z	DEBUGGINGZCONTEXTMANAGERSNcCs||_||_dS)N)�_input�_output)r>�inputr�rrrrwMszHelper.__init__cCs|jp
tjS)N)rrr})r>rrrrQszHelper.inputcCs|jp
tjS)N)r
rr)r>rrrr�Usz
Helper.outputcCs2t��dddkr|�dSd|jj|jjfS)Nrr0�?rz<%s.%s instance>)r�stackr�r&rT)r>rrr�__repr__Ys
zHelper.__repr__cCs6||jk	r|�|�n|��|��|j�d�dS)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>�requestrrr�__call__as
zHelper.__call__c	Cs�|j�d�x�y|�d�}|s PWnttfk
r<PYnX|��}t|�dkr�|d|dkrndkr�nn |d|dd�kr�|dd�}|��dkr�P|d	kr�|��q|�	|�qWdS)
Nrzhelp> rrr})r�rr)r��quitr)
r�r��getliner��EOFErrorrr r�rr)r>rrrrrns"
,
zHelper.interactcCs8|jtjkrt|�S|j�|�|j��|j��SdS)z.Read one line, using input() when appropriate.N)rrr}r�r�r�r)r>�promptrrrr�s

zHelper.getlinecCs<t|�td�k�r|��}|dkr,|��n�|dkr>|��n�|dkrP|��n�|dkrb|��n�|dd�dkr�|�|��d�n�||jkr�|�|�nj|d	kr�t	t
|�d
�nR||jkr�|�|�n<||j
kr�|�|�n&|r�t	|d
|jd�nt	td
|jd�n$t|t��r|�nt	|d
|jd�|j�d�dS)
Nr�keywords�symbols�topicsr��zmodules r)r�r�r�zHelp on %s:)r�r)r�r�listkeywords�listsymbols�
listtopics�listmodulesrr�
showsymbolr"�evalr�	showtopicrr
r)r�r�r�r�)r>rrrrr�s6






zHelper.helpcCs$|j�d�dtjdd���dS)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.%dr)r�r�r�rr�)r>rrrr�szHelper.intror|�Pc	
Cs�tt|��}||}t|�|d|}x�t|�D]z}xht|�D]\}|||}|t|�kr@|j�||�||dkr@|j�dd|dt||��q@W|j�d�q2WdS)Nrr�r)r��sortedr r�r�r�)	r>�items�columnsr�Zcolwr�rowrrjrrrr��s(zHelper.listcCs |j�d�|�|j���dS)NzN
Here is a list of the Python keywords.  Enter any keyword to get more help.

)r�r�r�rrD)r>rrrr�szHelper.listkeywordscCs |j�d�|�|j���dS)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�rrD)r>rrrr �szHelper.listsymbolscCs |j�d�|�|j���dS)NzN
Here is a list of available topics.  Enter any topic name to get more help.

)r�r�r�rrD)r>rrrr!�szHelper.listtopicscCs,yddl}Wn tk
r,|j�d�dSX|j�||j�|��}|s`|j�dt|��dSt|�td�kr||�	||�S|\}}y|jj|}Wn(t
k
r�|j�dt|��dSX|��d}|r�|p�dd|}|�r ddl}dd�
|���d}	|�|	d	�}
|d
d�
|
�7}t|�dS)Nrzt
Sorry, topic and keyword documentation is not available because the
module "pydoc_data.topics" could not be found.
zno documentation found for %s
rrr�zRelated help topics: z, �Hz
%s
)�pydoc_data.topicsr�r�r�rrmrr�r�r%�KeyErrorr�textwrapr!rZwraprv)r>�topic�
more_xrefs�
pydoc_data�target�label�xrefsr"r.r.Zwrapped_textrrrr%�s6zHelper.showtopiccCs�yddl}Wntk
r dSX|j�||j�|��}|sDtd��t|t�rZ|�||�S|\}}|jj|}|r�|pxdd|}||fS)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.
        rN)zt
Sorry, topic and keyword documentation is not available because the
module "pydoc_data.topics" could not be found.
rzcould not find topicrr�)	r,r�rrmrrOr�r)�	_gettopic)r>r/r0r1r2r3r4r"rrrr5�s	
zHelper._gettopiccCs*|j|}|�d�\}}}|�||�dS)Nr�)r�	partitionr%)r>�symbolr2r/r]r4rrrr#s
zHelper.showsymbolcsv|r |j�d�|��t|�nR|j�d�i}|fdd���fdd�}t�j�|d�|�|���|j�d�dS)	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...

cSs>|r$|dd�dkr$|dd�d}|�d�dkr:d||<dS)Ni����z	.__init__z
 (package)rrr)�find)rr'rpr�rrr�callback#sz$Helper.listmodules.<locals>.callbackcs�d|d�dS)Nr)r')r9rr�onerror(sz#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�rD)r>rGr�r:r)r9rr"s
zHelper.listmodules)r�r�rr�)NN)r|r&)r)r)r)!r%r&rTrZ_strprefixesZ_symbols_inverserr(r/Zsymbols_r7rmrrwr�rr�rrrrrrrrr�rr r!r%r5r#r"rrrrr��s6


	


 
r�c@seZdZdZddd�ZdS)r<z7An interruptible scanner that searches module synopses.Nc	Cs
|r|��}d|_i}xztjD]p}|dkrd||<|dkrH|d|d�qt|�jpTd}|�d�d}|d|}|���|�dkr|d||�qW�xdtj	|d�D�]R\}	}}
|jr�P|dkr�|d|d�q�yt�
|	|�}Wntk
r�w�YnX|j}t
|d	��rny|�|�}
Wn&tk
�r:|�r4||�w�YnXtt�|
���pNd}t
|d
��rh|�|�}nd}n^ytj�|�}Wn&tk
�r�|�r�||�w�YnX|j�r�|j��dnd}t|dd�}|d|}|���|�dkr�||||�q�W|�r|�dS)NF�__main__rrrrz - )r:�
get_source�get_filenamerQ)r�rrr�r�rPrr8r,r��	_get_specr�r�rar?r=r�r��StringIOr@r�r�r�r�r�r<)r>r9rGZ	completerr:�seenr'r(rpr6r7r�r��sourcerr�rrrr=6s`zModuleScanner.run)NNN)r%r&rTrPr=rrrrr<3sr<c	CsDdd�}dd�}t���"t�d�t�j|||d�WdQRXdS)zAPrint all the one-line module summaries that contain a substring.cSs6|dd�dkr |dd�d}t||o.d|�dS)Ni����z	.__init__z
 (package)z- )r�)rr'rprrrr9rszapropos.<locals>.callbackcSsdS)Nr)r'rrrr:vszapropos.<locals>.onerror�ignore)r:N)�warnings�catch_warnings�filterwarningsr<r=)rGr9r:rrrr;ps


r;cs�ddl�ddl�ddl�ddl�Gdd�d�jj��G�fdd�d�jj��G�����fdd�d�j�}||||�}|��x|j	s�|j
s�t�d	�q�W|S)
aAStart an HTTP server thread on a specific port.

    Start an HTML/text server thread, so HTML or text documents can be
    browsed dynamically and interactively with a Web browser.  Example use:

        >>> import time
        >>> import pydoc

        Define a URL handler.  To determine what the client is asking
        for, check the URL and content_type.

        Then get or generate some text or HTML code and return it.

        >>> def my_url_handler(url, content_type):
        ...     text = 'the URL sent was: (%s, %s)' % (url, content_type)
        ...     return text

        Start server thread on port 0.
        If you use port 0, the server will pick a random port number.
        You can then use serverthread.port to get the port number.

        >>> port = 0
        >>> serverthread = pydoc._start_server(my_url_handler, port)

        Check that the server is really started.  If it is, open browser
        and get first page.  Use serverthread.url as the starting page.

        >>> if serverthread.serving:
        ...    import webbrowser

        The next two lines are commented out so a browser doesn't open if
        doctest is run on this module.

        #...    webbrowser.open(serverthread.url)
        #True

        Let the server do its thing. We just need to monitor its status.
        Use time.sleep so the loop doesn't hog the CPU.

        >>> starttime = time.monotonic()
        >>> timeout = 1                    #seconds

        This is a short timeout for testing purposes.

        >>> while serverthread.serving:
        ...     time.sleep(.01)
        ...     if serverthread.serving and time.monotonic() - starttime > timeout:
        ...          serverthread.stop()
        ...          break

        Print any errors that may have occurred.

        >>> print(serverthread.error)
        None
   rNc@seZdZdd�Zdd�ZdS)z!_start_server.<locals>.DocHandlercSsX|j�d�rd}nd}|�d�|�dd|�|��|j�|�|j|��d��dS)	z�Process a request from an HTML browser.

            The URL received is in self.path.
            Get an HTML page from self.urlhandler and send it.
            z.cssztext/cssz	text/html��zContent-Typez%s; charset=UTF-8zutf-8N)	rr`Z
send_responseZsend_headerZend_headersZwfiler��
urlhandlerr�)r>�content_typerrr�do_GET�s

z(_start_server.<locals>.DocHandler.do_GETcWsdS)Nr)r>r�rrr�log_message�sz-_start_server.<locals>.DocHandler.log_messageN)r%r&rTrLrMrrrr�
DocHandler�srNcs(eZdZdd�Z�fdd�Zdd�ZdS)z _start_server.<locals>.DocServercSs6||_|j|f|_||_|j�||j|j�d|_dS)NF)�hostZaddressr9rIrw�handlerr)r>rO�portr9rrrrw�s
z)_start_server.<locals>.DocServer.__init__csBx4|js4��|j��gggd�\}}}|r|��qW|��dS)Nr)r�selectZsocketr�Zhandle_requestZserver_close)r>ZrdZwrZex)rRrr�serve_until_quit�s
z1_start_server.<locals>.DocServer.serve_until_quitcSs |j�|�|jr|�|�dS)N)rI�server_activater9)r>rrrrT�sz0_start_server.<locals>.DocServer.server_activateN)r%r&rTrwrSrTr)rRrr�	DocServer�srUcs:eZdZ�fdd�Z����fdd�Zdd�Zdd�Zd	S)
z#_start_server.<locals>.ServerThreadcs2||_||_t|�|_�j�|�d|_d|_dS)NF)rJrOrrQ�Threadrw�serving�error)r>rJrOrQ)�	threadingrrrw�s
z,_start_server.<locals>.ServerThread.__init__c
sxyJ�jj�_��_�jj�_t|j��_�|j	|j
|j�}||_|�
�Wn(tk
rr}z
||_Wdd}~XYnXdS)zStart the server.N)�server�
HTTPServerrIrPr�ZMessageZMessageClass�staticmethodrJrOrQ�ready�	docserverrSr=rX)r>Zdocsvr�e)rNrU�email�httprrr=�s

z'_start_server.<locals>.ServerThread.runcSs,d|_|j|_|j|_d|j|jf|_dS)NTz
http://%s:%d/)rWrOZserver_portrQr	)r>rZrrrr]�sz)_start_server.<locals>.ServerThread.readycSs&d|j_|��d|_d|_d|_dS)z&Stop the server and this thread nicelyTNF)r^rr!rWr	)r>rrr�stop	s
z(_start_server.<locals>.ServerThread.stopN)r%r&rTrwr=r]rbr)rNrUr`rarYrr�ServerThread�s
rcg{�G�z�?)
Zhttp.serverZ
email.messagerRrYrZZBaseHTTPRequestHandlerr[rVrrXrW�timeZsleep)rJ�hostnamerQrcZthreadr)rNrUr`rarRrYr�
_start_server~s8'rf�	text/htmlc	sG�fdd�dt�}|���fdd���fdd���fdd���fd	d
���fdd���fd
d���fdd���fdd����������fdd�}|�d�r�|dd�}|dkr�tj�tj�t��}tj�||�}t|��}d�|�	��SQRXn|dk�r||�St
d||f��dS)aThe pydoc url handler for use with the pydoc server.

    If the content_type is 'text/css', the _pydoc.css style
    sheet is read and returned if it exits.

    If the content_type is 'text/html', then the result of
    get_html_page(url) is returned.
    cseZdZ�fdd�ZdS)z_url_handler.<locals>._HTMLDoccsd}d|}d||��|fS)zFormat an HTML page.zpydoc_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_pathZcss_link)�html_navbarrrr�!	sz#_url_handler.<locals>._HTMLDoc.pageN)r%r&rTr�r)rirr�_HTMLDoc	srjcs>��dt��t��dt��f�}d|��tjdd��fS)Nz%s [%s, %s]raZ
            <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)Zterse)r�r�Zpython_versionZpython_buildZpython_compiler)r3)r�rrri1	s
z!_url_handler.<locals>.html_navbarcs�dd�}��ddd�}dd�tjD�}��||�}|d��d	dd
|�g}i}x tjD]}|���||��qVW|�d�dd
�|�fS)zModule Index page.cSsd||fS)Nz<a href="%s.html">%s</a>r)r(rrr�	bltinlinkO	sz3_url_handler.<locals>.html_index.<locals>.bltinlinkz7<big><big><strong>Index of Modules</strong></big></big>z#ffffffz#7799eecSsg|]}|dkr|�qS)r>r)rir(rrrr�U	sz4_url_handler.<locals>.html_index.<locals>.<listcomp>z<p>zBuilt-in Modulesz#ee77aaz|<p align=right><font color="#909090" face="helvetica,arial"><strong>pydoc</strong> by Ka-Ping Yee&lt;ping@lfw.org&gt;</font>zIndex of Modulesr)	r�rr�rr�rr
rar!)rkr��namesr�rCr)r�rr�
html_indexL	sz _url_handler.<locals>.html_indexc		s�g��fdd�}t���*t�d�dd�}t�j|||d�WdQRXdd	�}g}��d
dd�}x"�D]\}}|�||�|�qhW|��d
|ddd�|��}d|fS)zSearch results page.cs:|dd�dkr |dd�d}��||o0d|f�dS)Ni����z	.__init__z
 (package)z- )r
)rr'rp)�
search_resultrrr9j	sz3_url_handler.<locals>.html_search.<locals>.callbackrEcSsdS)Nr)r'rrrr:q	sz2_url_handler.<locals>.html_search.<locals>.onerror)r:NcSsd||fS)Nz<a href="%s.html">%s</a>r)r(rrrrkv	sz4_url_handler.<locals>.html_search.<locals>.bltinlinkz5<big><big><strong>Search Results</strong></big></big>z#ffffffz#7799eezkey = %sz#ee77aaz<br>zSearch Results)	rFrGrHr<r=r�r
r�r!)	rGr9r:rkrfr�r(rpr�)r�)rnr�html_searche	s 

z!_url_handler.<locals>.html_searchcsLdd�}��ddd�}ttj���}��||�}|��ddd|�}d|fS)zIndex of topic texts available.cSsd||fS)Nz<a href="topic?key=%s">%s</a>r)r(rrrrk�	sz4_url_handler.<locals>.html_topics.<locals>.bltinlinkz,<big><big><strong>INDEX</strong></big></big>z#ffffffz#7799eeZTopicsz#ee77aa)r�r'r�rrDrr�)rkr�rlr�)r�rr�html_topics�	sz!_url_handler.<locals>.html_topicscsL��ddd�}ttj���}dd�}��||�}|��ddd|�}d|fS)zIndex of keywords.z,<big><big><strong>INDEX</strong></big></big>z#ffffffz#7799eecSsd||fS)Nz<a href="topic?key=%s">%s</a>r)r(rrrrk�	sz6_url_handler.<locals>.html_keywords.<locals>.bltinlinkZKeywordsz#ee77aa)r�r'r�rrDrr�)r�rlrkr�)r�rr�
html_keywords�	sz#_url_handler.<locals>.html_keywordscs�t��}t||�}|�|�\}}||jkr0d}nd}��d|dd�}d��|�}��|dd|�}|r�t|�	��}dd	�}��
||�}��d
dd|�}d||fd�|||f�fS)
zTopic or keyword help page.ZKEYWORDZTOPICz)<big><big><strong>%s</strong></big></big>z#ffffffz#7799eez
<pre>%s</pre>z#ee77aacSsd||fS)Nz<a href="topic?key=%s">%s</a>r)r(rrrrk�	sz7_url_handler.<locals>.html_topicpage.<locals>.bltinlinkzRelated help topics: z%s %sr)
r�rBr�r5rr�rr�r'rrr�r!)r/ZbufZhtmlhelpr�r4r�r�rk)r�rr�html_topicpage�	s&



z$_url_handler.<locals>.html_topicpagecs@t|dd�}|dkr$|dkr$td��t|�}��||�}||fS)Nr)r�r�zcould not find object)r�rOr�r�)r	r9r��content)r�rr�html_getobj�	sz!_url_handler.<locals>.html_getobjcsP��ddd�}d��fdd�tt|�|�D��}|��|dd|�}d||fS)	Nz,<big><big><strong>Error</strong></big></big>z#ffffffz#7799eez<br>c3s|]}��|�VqdS)N)r�)rir�)r�rrr_�	sz3_url_handler.<locals>.html_error.<locals>.<genexpr>z#bb0000z
Error - %s)r�r!rr�r�)r	r�r�r�)r�rr�
html_error�	sz _url_handler.<locals>.html_errorc
sr|}|�d�r|dd�}�y|dkr2��\}}n�|dkrF��\}}n�|dkrZ��\}}n�d|k�r$|�d�\}}}|dkr��|�\}}n�|d	kr�y�|�\}}Wn tk
r��|�\}}YnXn\|d
k�r|dkr��\}}n4y�|�\}}Wn"tk
�r�|�\}}YnXntd��n�|�\}}Wn2tk
�rd}z�||�\}}Wdd}~XYnX��||�S)zGenerate an HTML page for url.z.htmlN���)rrarrrWz
search?keyz	topic?keyzget?keyz
bad pydoc url)r`r6rOr=r�)r	Zcomplete_urlr�rs�opr]r�)r�rurtrmrqrorrrprr�
get_html_page�	s>



 z#_url_handler.<locals>.get_html_pager�rNztext/cssrz	text/htmlz"unknown content type %r for url %s)r�r_r	r�dirname�realpathrQr!r��	readlinesrs)r	rKrjrxZ	path_hererh�fpr)	r�rurtrmrqrirorrrpr�_url_handler	s*	
(


r}T�	localhost)�open_browserrec	Cs�ddl}tt||�}|jr(t|j�dS|jr�d}|rB|�|j�z�y^td|j�t|�xD|jr�td�}|�	�}|dkr~Pq\|dkr�|�|j�q\t|�q\WWnt
tfk
r�t�YnXWd|jr�|��td�XdS)	z�Start the enhanced pydoc Web server and open a Web browser.

    Use port '0' to start the server on an arbitrary port.
    Set open_browser to False to suppress opening a browser.
    rNz"Server commands: [b]rowser, [q]uitzServer ready atzserver> r�r�zServer stopped)
�
webbrowserrfr}rXr�rWr�r	rr�r�rrb)rQrrer�ZserverthreadZserver_help_msgr�rrr�browse
s2
r�cCst|t�o|�tj�dkS)Nr)r�r)r8r	�sep)rLrrr�ispath(
sr�cCsvd|kstj|kst��|kr"dStj�t�}tj�|�}|��}||krbtj�||�sb|�|�|�	dt���|S)z�Ensures 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.
    rNr)
r	�curdir�getcwdrryrQ�copy�samefile�remove�insert)Z
given_pathZargv0Z
stdlib_dirZ
script_dir�revised_pathrrr�_get_revised_path+
s

r�cCs,ttjtjd�}|dk	r(|tjdd�<dS)z�Ensures current directory is on sys.path, and __main__ directory is not.

    Exception: __main__ dir is left alone if it's also pydoc's directory.
    rN)r�rr�argv)r�rrr�_adjust_cli_sys_pathG
sr�cCs�ddl}Gdd�dt�}t��yp|�tjdd�d�\}}d}d}d}d}d}x`|D]X\}	}
|	d	krnd
}d
}|	dkr�t|
�dS|	dkr�d
}|
}|	d
kr�d
}|	dkrVd
}|
}qVW|r�t|||d�dS|s�|�x�|D]�}t|�r�tj	�
|�s�td|�Py`t|��rtj	�|��rt
|�}|�rPt|��rFtj	�|��rFt|�nt|�n
t�|�Wq�tk
�r�}zt|�Wdd}~XYq�Xq�WWnN|j|fk
�r�tj	�tj	�tjd��d}
tdj|
tjd��YnXdS)z@Command-line interface (looks at sys.argv to decide what to do).rNc@seZdZdS)zcli.<locals>.BadUsageN)r%r&rTrrrr�BadUsageT
sr�rzbk:n:p:wFr~z-bTz-kz-pz-wz-n)rerzfile %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�)�getoptr=r�rr�r;r�r�r	r�existsr�rxr�rr�r�rr�rXr�r�r�r�)r�r�Zoptsr�ZwritingZstart_serverrrQreZopt�val�argrHr�rrr�cliQ
s`


"r�r>)NN)r)r)r�rN)r�rN)r)rN)rg)r)[rPr&r[rVrOrMZimportlib._bootstrapr�Zimportlib._bootstrap_external�importlib.machinery�importlib.utilrr�r	r,r�rrr�rdr�Zurllib.parser'rF�collectionsr�reprlibr�	tracebackrrrr$r)r-r/r3r�
IGNORECASEr4r5r:r?rCrMrcrdrvrzr�r�r=r�r�r�r�r�r�rcrdrtrvruryr{rxr�r�r~r�r�r.r�r�r�r�r"r�r�r�rr<r;rfr}r�r�r�r�r�r%rrrr�<module>&s�		


	'
0<*; p",






=
n%
U