HEX
Server: LiteSpeed
System: Linux pl-rocket-da1.hostsila.org 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: etorby24eu (1588)
PHP: 8.3.23
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //lib64/python3.6/__pycache__/pydoc.cpython-36.pyc
3

�]dhM��@s�dZdgZdZdZdZddlZddlZddlZddl	Zddl
ZddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlmZddlmZdd	lmZd
d�Zdd
�Zdd�Zdd�Z dd�Z!dd�Z"dd�Z#ej$dej%�Z&dd�Z'dd�Z(dd�Z)dd �Z*d!d"�Z+dud#d$�Z,d%d&�Z-d'd(�Z.d)d*�Z/d+d,�Z0ifd-d.�Z1Gd/d0�d0e2�Z3d1d2�Z4difd3d4�Z5Gd5d6�d6�Z6Gd7d8�d8e�Z7Gd9d:�d:e6�Z8Gd;d<�d<e�Z9Gd=d>�d>e6�Z:Gd?d@�d@e:�Z;dAdB�a<dCdD�Z=dEdF�Z>dGdH�Z?dIdJ�Z@dKdL�ZAdMdN�ZBdOdP�ZCdQdR�ZDdvdSdT�ZEe:�ZFe;�ZGe8�ZHdwdUdV�ZIdxdXdY�ZJdydZd[�ZKdzd\d]�ZLd{d_d`�ZMGdadb�db�ZNeN�ZOGdcdd�dd�ZPdedf�ZQdgdh�ZRd|djdk�ZSd}dldm�dndo�ZTdpdq�ZUdrds�ZVeWdtk�r�eV�dS)~a�Generate Python documentation in HTML or text for interactive use.

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

Or, at the shell command line outside of Python:

Run "pydoc <name>" to show documentation on something.  <name> may be
the name of a function, module, package, or a dotted reference to a
class or function within a module or module in a package.  If the
argument contains a path segment delimiter (e.g. slash on Unix,
backslash on Windows) it is treated as the path to a Python source file.

Run "pydoc -k <keyword>" to search for a keyword in the synopsis lines
of all available modules.

Run "pydoc -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.  The -p option
can be used with the -b option to explicitly specify the server port.

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}tjj|p d�}tjj|�}||krtjj|�r|j|�|j|�qW|S)zAConvert sys.path into a list of absolute, existing, unique paths.�.)�sys�path�os�abspath�normcase�isdir�append)�dirsZnormdirs�dir�normdir�r�/usr/lib64/python3.6/pydoc.py�pathdirsLs
rcCs.tj|�ptj|�}|r*tjdd|j��p,dS)z-Get the doc string or comments for an object.z^ *
�)�inspect�getdoc�getcomments�re�sub�rstrip)�object�resultrrrrXsrcCsh|j�jd�}t|�dkr&|ddfSt|�dkrZ|dj�rZ|ddj|dd��fSddj|�fS)z>Split a doc string into a synopsis line (if any) and the rest.�
�rr�N)�strip�split�lenr�join)�doc�linesrrr�splitdoc]s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�	classnamefs
r+cCs>tj|�p:tj|�p:tj|�p:tj|�p:tj|�p:tj|�S)z>Check if an object is of a type that probably means it's data.)r�ismodule�isclass�	isroutine�isframe�istraceback�iscode)rrrr�isdatamsr2cGs2x,|r,|dj|j|d��}|dd�}qW|S)z/Do a series of global replacements on a string.rrrN)r#r!)�text�pairsrrr�replacessr5cCsXt|�|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)r3�maxlen�pre�postrrr�cramzs
$r;z at 0x[0-9a-f]{6,16}(>+)$cCstjd|�S)z>Remove the hexadecimal id from a Python object representation.z\1)�_re_stripidr)r3rrr�stripid�sr=cCs(tj|�p&tj|�p&tj|�p&tj|�S)N)r�
isfunction�ismethod�	isbuiltin�ismethoddescriptor)�objrrr�_is_some_method�s


rCcCs<tj|�rdStj|�r8t|dd�}tj|�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)rr?r@�getattrr,)�fn�selfrrr�_is_bound_method�s

rHcCshi}x tj|t�D]\}}d||<qWx|jD]}|jt|��q.Wx|j�D]}t||�||<qNW|S)Nr)r�
getmembersrC�	__bases__�update�
allmethods�keysrE)�cl�methods�key�value�baserrrrL�srLcCs<g}g}x*|D]"}||�r&|j|�q|j|�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�	predicate�yes�no�xrrr�_split_list�s
rXcCs\|dkrdS|jd�r$|jd�r$dS|jd�r<t|d�r<dS|dk	rL||kS|jd�SdS)z3Decide whether to show documentation on a variable.�
__author__�__builtins__�
__cached__�__credits__�__date__�__doc__�__file__�__spec__�
__loader__r(r'�__package__�__path__�__qualname__�	__slots__�__version__r�__r�_�_fieldsTN>r\r(r'r^rbrdrYrcrfrar]rer_r[rZr`)�
startswith�endswith�hasattr)r*�allrBrrr�visiblename�srncCsDg}x:tj|�D],\}}}}tj|�r*d}|j||||f�qW|S)zCWrap inspect.classify_class_attrs, with fixup for data descriptors.zdata descriptor)r�classify_class_attrs�isdatadescriptorr
)r�resultsr*�kind�clsrQrrrro�s
rocs\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 namericsi|]\}}|t��|�qSr)r")�.0�ir*)�fieldsrr�
<dictcomp>�sz#sort_attributes.<locals>.<dictcomp>cs�j|dd�|dfS)Nr)�get)�attr)�field_orderrr�<lambda>�sz!sort_attributes.<locals>.<lambda>)rPN)rE�	enumerate�	TypeError�sort)�attrsrZkeyfuncr)rzrvr�sort_attributes�s
r�cCs<tjj|�r8x*dD]"}tjjtjj|d|��rdSqWdS)z3Guess whether a path refers to a package directory.�.py�.pyc�__init__TF)r�r�)r	rr�isfiler#)r�extrrr�	ispackage�s

r�cCs�|j�}x,|dd�dks$|j�r4|j�}|s
Pq
W|j�}|dd�dkrZ|dd�}|dd�dkr�|dd�}|d	d�dkr�|dd
�}x|j�s�|j�}|s�Pq�W|jd�dj�}nd}|S)Nr�#�zr"""r6z"""�\r���r�)�readliner r!)�file�linerrrr�source_synopsis�s&
r�c
Cstj|�j}|j|d�\}}|dks.||k�r|jttjj��rJtjj	}n |jttjj
��rftjj}nd}|dkr�ytj
|�}Wntk
r�dSX|�t|�}WdQRXnZ|d|�}tjjd||d�}ytjj|�}	Wn
dStjd=|	j�r|	jj�dnd}||f||<|S)z.Get the one-line summary out of a module file.NZ__temp__)�loaderr)NN)r	�stat�st_mtimerxrk�tuple�	importlib�	machinery�BYTECODE_SUFFIXES�SourcelessFileLoader�EXTENSION_SUFFIXES�ExtensionFileLoader�tokenize�open�OSErrorr��util�spec_from_file_location�
_bootstrap�_loadr�modulesr^�
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��excrQ�tb)rGr��exc_inforrrr�#szErrorDuringImport.__init__cCs|jj}d|j||jfS)Nzproblem in %s - %s: %s)r�r'r�rQ)rGr�rrr�__str__'szErrorDuringImport.__str__N)r'r(rdr^r�r�rrrrr�!sr�c	Cs�tjj}t|d��}||jt|��k}WdQRXtjj|�}tjj	|�\}}|r`tj
j||�}ntj
j||�}tjj
|||d�}ytjj|�St|tj���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*r�r�r�rrr�
importfile+sr�cs"yb|rX�tjkrX�tjkrX�fdd�tjD�}x(�g|D]}tj|||<tj|=q:Wt��}Wnxtj�\}}}}	�tjkr�ttj�j|	��n<|tkr�t|j|	��n&t	|t
�r�|j�kr�dSt�tj���YnXx@�j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|]}|j�d�r|�qS)r)rj)rt�m)rrr�
<listcomp>Qszsafeimport.<locals>.<listcomp>Nrr)rr��builtin_module_names�
__import__r�r�r_�SyntaxErrorr��
issubclass�ImportErrorr*r!rE�AttributeError)r�	forceloadr�ZsubsrPr�r�rQr��info�partr)rr�
safeimport=s.


r�c@s|eZdZejjddejdd��Zd
dd�Z	ddd�Z
e
ZZZ
ZZZejjejd	d
ejdd��fdd�ZdS)�Doc�
PYTHONDOCSz%https://docs.python.org/%d.%d/libraryNrcGs�||f|}tj|�r |j|�Stj|�r4|j|�Sy@tj|�rJ|j|�Stj|�r^|j|�Stj|�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)rGrr*�argsrrr�documentss"










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'r})rGrr*r��messagerrr�fail�szDoc.fail�libzpython%d.%dcCs�ytj|�}Wntk
r&d}YnXtjjd|j�}tjj|�}t	|t
t��r�|jdks||j|�r�|jtjj
|d
��r�|jdkr�|jd�r�d|jd�|jj�f}q�tjj
||jj�d�}nd}|S)z*Return the location of module docs or Nonez
(built-in)r��errno�
exceptions�gc�imp�marshal�posix�signalr�_thread�	zipimportz
site-packages�	xml.etree�test.pydoc_mod�http://�https://z%s/%s�/z.htmlN)
r�r�r�r�r�r�r�rr�r�)r�r�)r�r�)r�
getabsfiler}r	�environrxr�rrr�r�r'rjr#r�lower)rGrZbasedirr��doclocrrr�	getdocloc�s$



z
Doc.getdocloc)N)N)r'r(rdr	r�rxr�version_infor�r�r�r�r�r�r�r�r�rr#�base_exec_prefixr�rrrrr�ms

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,tj|�d|_|_d|_d|_|_dS)N��
�d)rr��maxlist�maxtuple�maxdict�	maxstring�maxother)rGrrrr��s
zHTMLRepr.__init__cCst|dddddd�S)N�&z&amp;�<z&lt;�>z&gt;)r5)rGr3rrr�escape�szHTMLRepr.escapecCstj||�S)N)rr�)rGrrrrr��sz
HTMLRepr.reprcCsZtt|�d�r@ddjt|�jj��}t||�r@t||�||�S|jttt	|��|j
��S)Nr'�repr_rh)rlr�r#r'r!rEr�r;r=r�r�)rGrW�level�
methodnamerrr�repr1�s

zHTMLRepr.repr1cCs^t||j�}t|�}d|krJdt|dd�krJd|d|j|�|dStjdd|j|��S)Nr�z\\r�rrz-((\\[\\abfnrtv\'"]|\\[0-9]..|\\x..|\\u....)+)z<font color="#c040c0">\1</font>)r;r�r�r5r�rr)rGrWr��test�testreprrrr�repr_string�szHTMLRepr.repr_stringcCs8y|jttt|��|j��S|jd|jj�SdS)Nz
<%s instance>)r�r;r=r�r��	__class__r')rGrWr�rrr�
repr_instance�szHTMLRepr.repr_instanceN)r'r(rdr^r�r�r�r�r��repr_strrZ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)rG�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)rGr�fgcol�bgcol�extrasrrr�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)
rGrrrr�widthZpreludeZ
marginaliaZgaprrrr�section�szHTMLDoc.sectioncGsd|}|j|f|��S)z$Format a section with a big heading.z<big><strong>%s</strong></big>)r)rGrr�rrr�
bigsection	szHTMLDoc.bigsectionc
Cs&|j|j��}t|dddddddd�	S)z!Format literal preformatted text.z

z
 
r�z&nbsp;rz<br>
)r��
expandtabsr5)rGr3rrr�	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)rG�list�format�colsr�rows�colrurrr�multicolumnszHTMLDoc.multicolumncCsd|S)Nz<font color="#909090">%s</font>r)rGr3rrr�grey sz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)rGr*�dicts�dictrrr�namelink"s
zHTMLDoc.namelinkcCsN|jtjj|j�}}t||�rDt||�|krDd|j|t||�fSt||�S)zMake a link for a class.z<a href="%s.html#%s">%s</a>)r'rr�rxr(rlrEr+)rGrr)r*r�rrr�	classlink)s
zHTMLDoc.classlinkcCsd|j|jfS)zMake a link for a module.z<a href="%s.html">%s</a>)r')rGrrrr�
modulelink1szHTMLDoc.modulelinkcCsR|\}}}}|r|j|�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)rGZ
modpkginfor*rr��shadowed�urlr3rrr�
modpkglink5s

zHTMLDoc.modpkglinkcCsd||fS)zMake a link to source file.z<a href="file:%s">%s</a>r)rGr rrrr�filelinkDszHTMLDoc.filelinkcCs�|p|j}g}d}tjd�}�xL|j||�}	|	s2P|	j�\}
}|j||||
���|	j�\}}
}}}}|
r�||�jdd�}|jd||f�n�|r�dt|�}|jd|||�f�n�|r�dt|�}|jd|||�f�n�|�r$|||d�d	k�r|jd
|j	||��n|jd|�n@|||d�d	k�rR|j|j	||||��n|j|j	||��|}q W|j|||d���d
j
|�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
�groupsr5�intrr#)rGr3r��funcs�classesrOrq�here�pattern�match�start�endrm�schemeZrfcZpepZselfdotr*r rrr�markupHs<

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


zHTMLDoc.formattreec#s�|j}y
|j}Wntk
r(d}YnX|jd�}g}x@tt|�d�D],}|jddj|d|d��||f�qJWdj||d.d��}	d|	}
y&tj	|�}t
jj|�}�j
||�}
Wntk
r�d}
YnXg}t|d��r:t|j�}|dd�d/k�r&|d0d�d	k�r&|dd1�j�}|jd�j|��t|d��r\|j�jt|j���|�rt|
d
dj|�}
�j|�}|dk	�r�dt�}nd}�j|
ddd|
|�}tj|tj�}gi}}xltj|tj�D]Z\}}|dk	�stj|��p�||k�r�t|||��r�|j||f�d|||<||<�q�Wx�|D]�\}}xx|jD]n}|j|j}}tj j!|�}||k�rL|�rLt||��rLt"||�|k�rL||k�rL|d|||<||<�qLW�q<Wgi}}x�tj|tj#�D]p\}}|dk	�stj$|��stj|�|k�r�t|||��r�|j||f�d|||<tj%|��r�||||<�q�Wg}x6tj|t&�D]&\}}t|||��rd|j||f��qdW�j't(|��j)||�}|�o�d|}|d|}t|d��r*g}x.t*j+|j,�D]\}}} |j||| df��q�W|j-��j.|�j/�}!|�j0ddd|!�}n.|�rX�j.|�fdd��}!|�j0ddd|!�}|�r�d d!�|D�}"�j1tj2|"d�|�g}!x*|D]"\}}|!j�j3|||||���q�W|�j0d"dd#d$j|!��}|�rg}!x*|D]"\}}|!j�j3|||||���q�W|�j0d%dd&d$j|!��}|�rbg}!x$|D]\}}|!j�j3||���q(W|�j0d'dd(d)j|!��}t|d*��r��j't|j4��j)�}!|�j0d+dd|!�}t|d,��rʈj't|j5��j)�}!|�j0d-dd|!�}|S)2z/Produce HTML documentation for a module object.Nrrz5<a href="%s.html"><font color="#ffffff">%s</font></a>z)<big><big><strong>%s</strong></big></big>z
(built-in)rf��$z
Revision: z
version %sr]z (%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>
rcrzPackage Contentsz#aa55cccs�j|d�S)Nr)r)�t)rGrrr{�sz#HTMLDoc.docmodule.<locals>.<lambda>�ModulescSsg|]\}}|�qSrr)rtrPrQrrrr��sz%HTMLDoc.docmodule.<locals>.<listcomp>ZClassesz#ee77aar�Z	Functionsz#eeaa77�Dataz#55aa55z<br>
rYZAuthorr\ZCreditsr�z$Revision: r�r�)6r'�__all__r�r!rr"r
r#rr��urllib�parse�quoter"r}rl�strrfr r�r]r��localsr
rIr,r-�	getmodulernrJr(rr�rxrEr.r@r>r2r2rr�pkgutil�iter_modulesrcr~rr!rr4�getclasstreer�rYr\)#rGrr*�mod�ignoredrm�parts�linksruZ
linkedname�headrr r"r��versionr�rr�r+ZcdictrPrQrRr)r�r*Zfdict�datar$�modpkgs�importer�ispkgr�	classlistr)rGrr��s�


&


$




$

zHTMLDoc.docmodulecs�j}|p|}�j}g}	|	j�G�fdd�d�}
|
��ttj���}t|�dkr��j��d�x"|D]}�d�j|�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�|�rb|�r||j��n|dd�t|�fdd��\}}�tjk�r�|}�qfn"��k�r�d}nd�j��j	�}|d7}t|��|
d||dd��}|
d||dd��}|
d||dd��}|d||dd��}|d||d d��}|gk�sZt�|}�qfWd!j|	�}	||k�r�d"||f}nd#|||f}|�r�g}x"|D]}|j�j|�j	���q�W|d$d%j|�}�jt���j����}|�o�d&|}�j|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)rGrrrr�sz1HTMLDoc.docclass.<locals>.HorizontalRule.__init__cs|jr�d�d|_dS)Nz<hr>
r)rU)rG)�pushrr�maybe
sz.HTMLDoc.docclass.<locals>.HorizontalRule.maybeN)r'r(rdr�rWr)rVrr�HorizontalRule
srXrz&<dl><dt>Method resolution order:</dt>
z<dd>%s</dd>
z</dl>
cs�t||�\}}|r��j��|�xl|D]d\}}}}yt�|�}Wn&tk
rh��j||���YnX��j||��������d�q(W|S)Nr)rXrWrE�	Exception�_docdescriptorr�)�msgrrT�okr*rr�homeclsrQ)r+r*�hr�mdictrJrrVrGrr�spillszHTMLDoc.docclass.<locals>.spillcsNt||�\}}|rJ�j��|�x&|D]\}}}}��j||���q(W|S)N)rXrWrZ)r[rrTr\r*rrr]rQ)r^rJrVrGrr�spilldescriptors/sz*HTMLDoc.docclass.<locals>.spilldescriptorsc
s�t||�\}}|r��j��|�x�|D]�\}}}}�jt�|�|��}t|�sZtj|�rht|dd�}	nd}	|	dkr��d|�n0�jt|��j	����}	d|	}	�d||	f��d�q(W|S)Nr^z<dl><dt>%s</dl>
z<dd><tt>%s</tt>z<dl><dt>%s%s</dl>
r)
rXrWr�rE�callablerrpr2rr)
r[rrTr\r*rrr]rQrRr$)r+r*r^r_rJrrVrGrr�	spilldata8s"
z#HTMLDoc.docclass.<locals>.spilldatacs,g|]$\}}}}t|�d�r||||f�qS))rB)rn)rtr*rrrsrQ)rrrr�Ms
z$HTMLDoc.docclass.<locals>.<listcomp>r��-rcs|d�kS)Nrr)r=)�	thisclassrrr{fsz"HTMLDoc.docclass.<locals>.<lambda>zdefined herezinherited from %sz:<br>
z
Methods %scSs|ddkS)Nr�methodr)r=rrrr{vszClass methods %scSs|ddkS)Nrzclass methodr)r=rrrr{xszStatic methods %scSs|ddkS)Nrz
static methodr)r=rrrr{zszData descriptors %scSs|ddkS)Nrzdata descriptorr)r=rrrr{|szData and other attributes %scSs|ddkS)NrrPr)r=rrrr{~srz*<a name="%s">class <strong>%s</strong></a>z/<strong>%s</strong> = <a name="%s">class %s</a>z(%s)z, z<tt>%s<br>&nbsp;</tt>z#000000z#ffc8d8r6)r'rJr
rr�getmror"rWrr(rorErYr}�popleftrX�builtinsrr��AssertionErrorr#r2rrr)rGrr*rJr*r+rK�realnamer9rrX�mrorRr`rarcrrPrrr]rQ�anchor�	inherited�tagrr:r$r)	r+r*r^r_rJrrVrGrerr��s�

	



















zHTMLDoc.docclasscCs|jd|j|��S)z)Format an argument default value as text.�=)rr�)rGrrrr�formatvalue�szHTMLDoc.formatvaluecCs�|j}|p|}|r|jpdd|}	d}
d}t|�r�|jj}|rZ||k	r�d|j||�}
n0|jdk	rzd|j|jj|�}
nd|j||�}
||kr�d|	|f}
nD|r�tj||g�|kr�d	|jd||f}d
}n|}d|	||f}
d}tj|��rNytj|�}Wnt	t
fk
�r d}YnX|�rNt|�}|dk�rNd
|}
|d
d�}|�sXd}|
|j|�|
�ov|j
d|
�}|�r�d|S|jt|�|j|||�}|�o�d|}d||fSdS)z;Produce HTML documentation for a function or method object.rrdrz 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> 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'rHrDrrr�getattr_staticr.�	signature�
ValueErrorr}rDr�rr2rr)rGrr*rJr*r+rOrNrkrm�note�skipdocs�imclassrZreallink�argspecrs�declr$rrrr��sX


zHTMLDoc.docroutinecCsTg}|j}|r|d|�|jdk	rB|jt|�|j�}|d|�|d�dj|�S)Nz!<dl><dt><strong>%s</strong></dt>
z<dd><tt>%s</tt></dd>
z</dl>
r)r
r^r2rrr#)rGr*rQrJrqrVr$rrrrZ�s
zHTMLDoc._docdescriptorcCs|j|||�S)z*Produce html documentation for a property.)rZ)rGrr*rJrNrrrr��szHTMLDoc.docpropertycGs|rd|pd}||j|�S)z-Produce HTML documentation for a data object.z<strong>%s</strong> = r)r�)rGrr*rJrKZlhsrrrr��szHTMLDoc.docothercCs|j|||�S)z1Produce html documentation for a data descriptor.)rZ)rGrr*rJrNrrrr��szHTMLDoc.docdatacCs�g}|dkri}xLtj|g�D]<\}}}tdd�|D��r<q|j|d|||kf�d||<qW|j�|j||j�}|j|dd|�S)z2Generate an HTML index for a directory of modules.Ncss*|]"}dt|�kodknVqdS)i�i��N)�ord)rt�chrrr�	<genexpr>�sz HTMLDoc.index.<locals>.<genexpr>rrz#ffffffz#ee77aa)rGrH�anyr
r~rr!r)rGrrrQrRr*rSrrrr�index�sz
HTMLDoc.index)r)rrNr)r�)N)NN)NNN)NN)NNN)N)r'r(rdr^r��_repr_instancer�r�rr
rrrrrrrrr!r"r2r4r�r�rqr�rZr�r�r�r~rrrrr�s<



+

y:


rc@s4eZdZdZdd�Zdd�Zdd�ZeZdd	�Zd
S)�TextReprzAClass for safely making a text representation of a Python object.cCs,tj|�d|_|_d|_d|_|_dS)Nr�r�r�)rr�r�r�r�r�r�)rGrrrr�s
zTextRepr.__init__cCsTtt|�d�r@ddjt|�jj��}t||�r@t||�||�Sttt|��|j	�S)Nr'r�rh)
rlr�r#r'r!rEr;r=r�r�)rGrWr�r�rrrr�s

zTextRepr.repr1cCsHt||j�}t|�}d|krDdt|dd�krDd|d||dS|S)Nr�z\\rr�r)r;r�r�r5)rGrWr�r�r�rrrr�
s
zTextRepr.repr_stringc
Cs,yttt|��|j�Sd|jjSdS)Nz
<%s instance>)r;r=r�r�rr')rGrWr�rrrrszTextRepr.repr_instanceN)	r'r(rdr^r�r�r�rrrrrrr��s	r�c@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.cCsdjdd�|D��S)z(Format a string in bold by overstriking.rcss|]}|d|VqdS)�Nr)rtr{rrrr|(szTextDoc.bold.<locals>.<genexpr>)r#)rGr3rrr�bold&szTextDoc.bold�    cs>|sdS�fdd�|jd�D�}|r4|dj�|d<dj|�S)z6Indent text by prepending a given prefix to each line.rcsg|]}�|�qSrr)rtr�)�prefixrrr�-sz"TextDoc.indent.<locals>.<listcomp>rrr�r�)r!rr#)rGr3r�r%r)r�r�indent*szTextDoc.indentcCs$|j|�j�}|j|�d|dS)z&Format a section with a given heading.rz

)r�rr�)rGrrZclean_contentsrrrr1szTextDoc.sectionNrc
s�d}x�|D]�}t|�tf�krt|\}}||t|��}|rj||fkrj�fdd�|D�}	|ddj|	�}|d}q
t|�tg�kr
||j|�||d�}q
W|S)zBRender in text a class tree as returned by inspect.getclasstree().rc3s|]}t|��VqdS)N)r+)rtr8)r)rrr|@sz%TextDoc.formattree.<locals>.<genexpr>z(%s)z, rz    )r�r+r#r4)
rGr5r)r6r�rr7r8r9r:r)r)rr48s

zTextDoc.formattreecCsD|j}tt|��\}}|jd||o(d|�}t|dd�}|j|�}|dk	r`||jd|d�}|rt||jd|�}g}	xNtj|tj�D]<\}
}|dk	s�tj	|�p�||kr�t
|
||�r�|	j|
|f�q�Wg}xXtj|tj�D]F\}
}|dk	�stj
|��stj	|�|kr�t
|
||�r�|j|
|f�q�Wg}
x6tj|t�D]&\}
}t
|
||��r8|
j|
|f��q8Wg}t�}t|d��r�xFtj|j�D]6\}}}|j|�|�r�|j|d	�n
|j|��q�W|j�||jd
dj|��}g}xBtj|tj�D]0\}
}|jj|d��r�|
|k�r�|j|
��q�W|�rJ|j�||jd
dj|��}|	�r�dd�|	D�}|jtj|d�|�g}x&|	D]\}
}|j|j||
|���qzW||jddj|��}|�r�g}x&|D]\}
}|j|j||
|���q�W||jddj|��}|
�rFg}x*|
D]"\}
}|j|j||
|dd���q
W||jddj|��}t|d��r�t|j�}|dd�d#k�r�|d$d�dk�r�|dd%�j�}||jd|�}t|d��r�||jdt|j ��}t|d��r�||jdt|j!��}t|d��r||jd t|j"��}ytj#|�}Wnt$k
�r.d!}YnX||jd"|�}|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.
ZDESCRIPTIONrcz
 (package)zPACKAGE CONTENTSrrZ
SUBMODULEScSsg|]\}}|�qSrr)rtrPrQrrrr��sz%TextDoc.docmodule.<locals>.<listcomp>r�CLASSES�	FUNCTIONS�F)r8�DATArfr;r<z
Revision: �VERSIONr]ZDATErYZAUTHORr\ZCREDITSz
(built-in)ZFILEz$Revision: r�r�)%r'r&rrrEr�rrIr-rFrnr
r.r@r2�setrlrGrHrc�addr~r#r,rjr4rIr�r�rDrfr r]rYr\r�r})rGrr*rJZsynop�descrrmr�r+rPrQr*rPrQZ
modpkgs_namesrRr)rSZ
submodulesrTrrOr�rrrr�Hs�





$
zTextDoc.docmodulecsf�j}|p|}�j}�jfdd�}||kr:d�j|�}n�j|�d|}|rlt||�}	|ddj|	�}t��}
|
r�|
dgp�g}|j�tt	j
���}t|�dkrԈd	�x|D]}
�d
||
��q�W�d�G�fdd
�d
�}|�������fdd�}����fdd�}�����fdd�}�fdd�t��D�}x�|�r0|�rT|j
��n|dd�t|�fdd��\}}�tjk�r�|}�q>n ��k�r�d}ndt��j�}t|��|d||dd��}|d||dd��}|d||d d��}|d!||d"d��}|d#||d$d��}|gk�s(t�|}�q>Wdj|�}|�sJ|dS|d�j|j�d%�dS)&z4Produce text documentation for a given class object.cSs
t||�S)N)r+)r8r�rrr�makename�sz"TextDoc.docclass.<locals>.makenamezclass z	 = class z(%s)z, rrzMethod resolution order:z    rcs eZdZdd�Z�fdd�ZdS)z(TextDoc.docclass.<locals>.HorizontalRulecSs
d|_dS)Nr)rU)rGrrrr��sz1TextDoc.docclass.<locals>.HorizontalRule.__init__cs|jr�dd�d|_dS)Nrdr�r)rU)rG)rVrrrW�sz.TextDoc.docclass.<locals>.HorizontalRule.maybeN)r'r(rdr�rWr)rVrrrX�srXcs�t||�\}}|r��j��|�x^|D]V\}}}}yt�|�}Wn&tk
rh��j||���Yq(X��j||����q(W|S)N)rXrWrErYrZr�)r[rrTr\r*rrr]rQ)r^rJrrVrGrrr`�szTextDoc.docclass.<locals>.spillcsNt||�\}}|rJ�j��|�x&|D]\}}}}��j||���q(W|S)N)rXrWrZ)r[rrTr\r*rrr]rQ)r^rJrVrGrrra�sz*TextDoc.docclass.<locals>.spilldescriptorsc
s�t||�\}}|r��j��|�x~|D]v\}}}}t|�sFtj|�rPt|�}nd}yt�|�}	Wntk
r�|j|}	YnX��j	|	|�d|d�d�q(W|S)Nr�)r8r$r)
rXrWrbrrprrEr��__dict__r�)
r[rrTr\r*rrr]rQr$rB)r^rJrrVrGrrrc�s
z#TextDoc.docclass.<locals>.spilldatacs,g|]$\}}}}t|�d�r||||f�qS))rB)rn)rtr*rrrsrQ)rrrr�s
z$TextDoc.docclass.<locals>.<listcomp>rcs|d�kS)Nrr)r=)rerrr{	sz"TextDoc.docclass.<locals>.<lambda>zdefined herezinherited from %szMethods %s:
cSs|ddkS)Nrrfr)r=rrrr{szClass methods %s:
cSs|ddkS)Nrzclass methodr)r=rrrr{szStatic methods %s:
cSs|ddkS)Nrz
static methodr)r=rrrr{szData descriptors %s:
cSs|ddkS)Nrzdata descriptorr)r=rrrr{szData and other attributes %s:
cSs|ddkS)NrrPr)r=rrrr{ sz |  )r'rJr(r��mapr#rr
rrrgr"rorhrXrirr+r�rjr�r)rGrr*rJrKrkr9r�rr:r$rrlrRrXr`rarcrrnror)r^rJrrVrGrerr��sn

	
















zTextDoc.docclasscCsd|j|�S)z)Format an argument default value as text.rp)r�)rGrrrrrq*szTextDoc.formatvaluecCsr|j}|p|}d}d}t|�rn|jj}|rB||k	rndt||�}n,|jdk	r`dt|jj|�}ndt||�}||kr�|j|�}	n,|r�tj||g�|kr�d}|j|�d|}	d}
tj|��rytj	|�}Wnt
tfk
r�d}YnX|�rt|�}
|d	k�r|j|�d
}	|
dd
�}
|
�s&d}
|	|
|}|�r@|dSt
|��pLd}
|d|
�oj|j|
�j�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 z(...)rr�)r'rHrDrr+r�rrrr.rsrtr}rDrr�r)rGrr*rJrNrkrurvrwrrxrsryr$rrrr�.sH


zTextDoc.docroutinecCsTg}|j}|r$||j|��|d�t|�p.d}|rJ||j|��|d�dj|�S)Nrr)r
r�rr�r#)rGr*rQrJrqrVr$rrrrZ_szTextDoc._docdescriptorcCs|j|||�S)z*Produce text documentation for a property.)rZ)rGrr*rJrNrrrr�lszTextDoc.docpropertycCs|j|||�S)z1Produce text documentation for a data descriptor.)rZ)rGrr*rJrNrrrr�pszTextDoc.docdatac
Cs�|j|�}|rF|r|dpd|}|t|�}	|	dkrF|d|	�d}|rX|j|�dpZd|}|dk	r~|d|jt|��7}|S)z-Produce text documentation for a data object.z = rrNz...r)r�r"r�r�rD)
rGrr*rJr6r8r$r�r�Zchoprrrr�ts
zTextDoc.docother)r�)Nr)NN)NN)NNN)NNN)NNN)NNNNN)r'r(rdr^r�rr�r�r�rr4r�r�rqr�rZr�r�r�rrrrr�s


e
}
1

r�c@seZdZdZdd�ZdS)�
_PlainTextDocz2Subclass of TextDoc which overrides string stylingcCs|S)Nr)rGr3rrrr��sz_PlainTextDoc.boldN)r'r(rdr^r�rrrrr��sr�cCst�at|�dS)zCThe first time this is called, determine what kind of pager to use.N)�getpager�pager)r3rrrr��sr�cs<ttjd�stSttjd�s tStjj�s8tjj�r<tStjjd�pRtjjd���r�tj	dkrn�fdd�Stjjd�dkr��fd
d�S�fdd�Stjjd�dkr�tStj	dkr�dd�Sttd
�r�tj
d�dkr�dd�Sddl}|j�\}}tj
|�z0ttd
��r$tj
d|�dk�r$dd�StSWdtj|�XdS)z2Decide what method to use for paging through text.�isattyZMANPAGERZPAGER�win32cstt|���S)N)�
tempfilepager�plain)r3)�	use_pagerrrr{�szgetpager.<locals>.<lambda>ZTERM�dumb�emacscstt|���S)N)�	pipepagerr�)r3)r�rrr{�scs
t|��S)N)r�)r3)r�rrr{�scSstt|�d�S)Nzmore <)r�r�)r3rrrr{�s�systemz(less) 2>/dev/nullrcSs
t|d�S)NZless)r�)r3rrrr{�sNz	more "%s"cSs
t|d�S)NZmore)r�)r3rrrr{�s)r�r�)r�r�)rlr�stdin�
plainpager�stdoutr�r	r�rx�platformr��tempfile�mkstemp�close�ttypager�unlink)r��fdr�r)r�rr��s6


 r�cCstjdd|�S)z%Remove boldface formatting from text.z.r)rr)r3rrrr��sr�c Cs�ddl}|j|d|jd�}yDtj|jdd��*}y|j|�Wntk
rPYnXWdQRXWntk
rrYnXx(y|j	�PWqvtk
r�YqvXqvWdS)z3Page through text by feeding it to another program.rNT)�shellr��backslashreplace)�errors)
�
subprocess�Popen�PIPE�io�
TextIOWrapperr��write�KeyboardInterruptr��wait)r3�cmdr��proc�piperrrr��s r�cCs`ddl}|j�}t|ddd��}|j|�WdQRXztj|d|d�Wdtj|�XdS)z<Page through text by invoking a program on a temporary file.rN�wr�)r�z "r#)r��mktempr�r�r	r�r�)r3r�r�r�r�rrrr��sr�cCs$ttjdd�pd}|j|d�j|�S)N�encodingzutf-8r�)rErr��encode�decode)r3r�rrr�_escape_stdout�sr�c
Cs�tt|��jd�}y2ddl}tjj�}|j|�}|j|�dd�}Wn(t	t
tjfk
rld}dd�}YnX�z2yt
tjjdd��}Wntk
r�d}YnX|dkr�d	}|d}}tjjdj|d|��d�x�||d��r�tjjd
�tjj�|�}	|	dk�rtjjd
�Pn,|	dk�rJtjjd
||d�|d}q�|	dk�rn|||}|dk�rnd}tjjddj||||��d�||}q�WWd|�r�|j||j|�XdS)z%Page through text on a text terminal.rrNcSstjjd�S)Nr)rr�r�rrrrr{�szttypager.<locals>.<lambda>cSstjj�dd�dd�S)Nrr�)rr�r�rrrrr{�s�LINESr�z
-- more --�q�Qz
          
�
�b�B�)r�r�)r�r)r�r�r�)r�r�r!�ttyrr��filenoZ	tcgetattrZ	setcbreakr�r�r��UnsupportedOperationr)r	r�rxrtr�r�r#�flushZ	tcsetattrZ	TCSAFLUSH)
r3r%r�r��old�getchar�hr�Zincr8rrrr��sL








&r�cCstjjtt|���dS)z>Simply print unformatted text.  This is the ultimate fallback.N)rr�r�r�r�)r3rrrr�sr�cCs�tj|�r>|jtjkr d|jSt|d�r4d|jSd|jStj|�rRd|jStj|�rtd|jj	|jj|jfStj
|�r�d|jj	|jj|jfStj|�r�d|jStj|�r�d	|jStj
|�r�d
|jSt|�jS)z/Produce a short description of the given thing.zbuilt-in module rczpackage zmodule zbuilt-in function zgetset descriptor %s.%s.%szmember descriptor %s.%s.%szclass z	function zmethod )rr,r'rr�rlr@r��__objclass__r(r�r-r>r?r�)�thingrrr�describe
s.
















r�cCs�dd�|jd�D�}d\}}xB|t|�kr^tdj|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)rtr�rrrr�'szlocate.<locals>.<listcomp>rNrr)Nr)r!r"r�r#rirEr�)rr�rLr��nZ
nextmodulerr�rrr�locate%s 
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�rDr�r�rE)r�r�rr*rrr�resolve>s


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

)r3r�r�rrF�rfindr'r,r-r.r�r�r�r�r�r�)r�rr��rendererrr*r�r�rrr�
render_docLs$






r�cCsfy2|dkrtt|||��n|jt|||t��Wn.ttfk
r`}zt|�WYdd}~XnXdS)zCDisplay text documentation, given an object or a path to an object.N)r�r�r��	plaintextr�r��print)r�rr��outputrQrrrr$esr$cCs�y`t||�\}}tjt|�tj||��}t|dddd��}|j|�WdQRXtd|d�Wn.tt	fk
r�}zt|�WYdd}~XnXdS)z<Write HTML documentation to a file in the current directory.z.htmlr�zutf-8)r�NZwrote)
r��htmlrr�r�r�r�r�r�r�)r�r�rr*rr�rQrrr�writedocpsr�rcCs6|dkri}x$tj|g|�D]\}}}t|�qWdS)zAWrite out HTML documentation for all modules in a directory tree.N)rG�
walk_packagesr�)r�pkgpath�donerRr)rSrrr�	writedocs{s
r�cJ@s�eZdZdddddd�d�d�d�d�d�d
d�ddd�dd�d�d�d�dd�d�ddd�d�d��d�d�d�dd&�!Zd'd(��dD�Z�de��d�d�d�d	�d
�ddS�ZdTdUdVdWdXdYdZd[d\d]d^d_d_d`d`da�ZxPej�D]D\ZZ	x8e	D]0Z
eje
e�Zeek�r�edbeZeee
<�q�W�q�W�d�d
�d�d�d�d�d�d�d�ddv�d�d�d�ddd�d�d�d�d�dd�dd�d��d �d!�d"�d#�d$�d%�d&�d'�d(�d)�d*d�d��d+�d,�d-�d.�d/�d0d��d1�d2�d3�d4�d5�d6�d7�d8�d9�d:�d;�d<�d=�d>�d?�d@d�dA�dBdd!dd
�dC�dD�dE�dFdʜIZ�dGd�d̈́Z
ed�dτ�Zed�dτ�Zd�d҄Ze�Zefd�dԄZd�dքZd�d؄Zd�dڄZd�d܄Z�dHd�d�Zd�d�Zd�d�Zd�d�Z�dId�d�Z�dJd�d�Zd�d�Z�dKd�d�Z d�S(L�Helperr�BOOLEAN�with�assert�break�	while for�class�CLASSES SPECIALMETHODS�continue�function�del�BASICMETHODS�if�else�try�for�break continue while�import�global�nonlocal NAMESPACES�
TRUTHVALUE�MODULES�in�SEQUENCEMETHODS�
COMPARISON�lambdar��nonlocal�global NAMESPACES�pass�raise�
EXCEPTIONS�return�while�break continue if TRUTHVALUE� CONTEXTMANAGERS EXCEPTIONS yield�yield)!�False�None�True�and�asr�r�r�r��defr��elifr��except�finallyr��fromr�r�r�r��isr�r��not�orr�r�r�r�r�r�rcCsg|]}dD]}||�qqS)�'r#)rr#r)rt�pr�rrrr��szHelper.<listcomp>r��fr��ur�'''r#�"""�+rd�*�**r��//�%�<<�>>r��|�^�~r�r��<=�>=�==�!=�<>�+=�-=�*=�/=�%=�&=�|=�^=�<<=�>>=�**=�//=�j�J)�STRINGS�	OPERATORSr��UNARY�AUGMENTEDASSIGNMENT�BITWISE�COMPLEXzOPERATORS FORMATTING�POWERzTUPLES LISTS FUNCTIONSz ATTRIBUTES FLOAT MODULES OBJECTS�ELLIPSISzSLICINGS DICTIONARYLITERALSz	def classr3�PRIVATENAMESzPRIVATENAMES SPECIALMETHODSZ
BACKQUOTESzTUPLES FUNCTIONS CALLSzLISTS SUBSCRIPTS SLICINGS)rz**�,rz...�:�@r�rhrg�`r$r3�[�]r��types�RSTRINGS UNICODE NUMBERS SEQUENCES MAPPINGS FUNCTIONS CLASSES MODULES FILES inspect�strings�4str UNICODE SEQUENCES STRINGMETHODS FORMATTING TYPES�string-methods�STRINGS FORMATTING�
formatstringsr4�:encodings unicode SEQUENCES STRINGMETHODS FORMATTING TYPES�numbers�INTEGER FLOAT COMPLEX TYPES�integers�	int range�floating�
float math�	imaginary�
complex cmath�typesseq�$STRINGMETHODS FORMATTING range LISTS�DICTIONARIES�typesfunctions�	def TYPES�typesmethods�class def CLASSES TYPES�bltin-code-objects�compile FUNCTIONS TYPES�bltin-type-objects�types TYPES�TYPES�bltin-null-object�bltin-ellipsis-object�SLICINGS�specialattrs�!class SPECIALMETHODS PRIVATENAMES�typesmodules�operator-summary��lambda or and not in is BOOLEAN COMPARISON BITWISE SHIFTING BINARY FORMATTING POWER UNARY ATTRIBUTES SUBSCRIPTS SLICINGS CALLS TUPLES LISTS DICTIONARIES�EXPRESSIONS�objects�specialnames�bBASICMETHODS ATTRIBUTEMETHODS CALLABLEMETHODS SEQUENCEMETHODS MAPPINGMETHODS NUMBERMETHODS CLASSES�
customization�hash repr str SPECIALMETHODS�attribute-access�ATTRIBUTES SPECIALMETHODS�callable-types�CALLS SPECIALMETHODS�sequence-types�(SEQUENCES SEQUENCEMETHODS SPECIALMETHODS�MAPPINGS SPECIALMETHODS�
numeric-types�*NUMBERS AUGMENTEDASSIGNMENT SPECIALMETHODS�	execmodel�%NAMESPACES DYNAMICFEATURES EXCEPTIONS�naming�3global nonlocal ASSIGNMENT DELETION DYNAMICFEATURES�dynamic-features�
NAMESPACESr��try except finally raise�conversions�identifiers�keywords SPECIALIDENTIFIERS�
id-classes�atom-identifiers�
atom-literals�=STRINGS NUMBERS TUPLELITERALS LISTLITERALS DICTIONARYLITERALS�	SEQUENCES�	exprlists�TUPLES LITERALS�typesseq-mutable�LISTLITERALS�lists�LISTS LITERALS�typesmapping�DICTIONARYLITERALSr�DICTIONARIES LITERALS�attribute-references�(getattr hasattr setattr ATTRIBUTEMETHODS�
subscriptions�slicings�calls�power�unary�binary�shifting�bitwise�comparisons�EXPRESSIONS BASICMETHODS�booleans�EXPRESSIONS TRUTHVALUE�
assignmentr6�	augassign�
NUMBERMETHODS�compound�for while break continue�truth� if while and or not BASICMETHODS�debugger�pdb�context-managers)Ir]r3Z
STRINGMETHODSZ
FORMATTING�UNICODEZNUMBERSZINTEGER�FLOATr8r�ZMAPPINGSr�ZMETHODSZCODEOBJECTSZTYPEOBJECTSZFRAMEOBJECTSZ
TRACEBACKS�NONEr:ZSPECIALATTRIBUTESr�r�ZPACKAGESrfr4Z
PRECEDENCEZOBJECTSZSPECIALMETHODSr�ZATTRIBUTEMETHODSZCALLABLEMETHODSr�ZMAPPINGMETHODSr�Z	EXECUTIONrzZDYNAMICFEATURESZSCOPINGZFRAMESr�ZCONVERSIONSZIDENTIFIERSZSPECIALIDENTIFIERSr;ZLITERALSZTUPLESZ
TUPLELITERALSZLISTSr�rTr�Z
ATTRIBUTESZ
SUBSCRIPTSr`ZCALLSr9r5ZBINARYZSHIFTINGr7r�r�Z	ASSERTIONZ
ASSIGNMENTr6ZDELETIONZ	RETURNINGZ	IMPORTINGZCONDITIONALZLOOPINGr�Z	DEBUGGINGZCONTEXTMANAGERSNcCs||_||_dS)N)�_input�_output)rG�inputr�rrrr�/szHelper.__init__cCs|jp
tjS)N)r�rr�)rGrrrr{3szHelper.<lambda>cCs|jp
tjS)N)r�rr�)rGrrrr{4scCs2tj�dddkr|�dSd|jj|jjfS)Nrr6�?rz<%s.%s instance>)r�stackrr(rd)rGrrr�__repr__6s
zHelper.__repr__cCs6||jk	r|j|�n|j�|j�|jjd�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�)rG�requestrrr�__call__>s
zHelper.__call__cCs�|jjd�x�y|jd�}|s PWnttfk
r<PYnX|j�}t|�dkr�|d|dkoldknr�|d|dd
�kr�|dd�}|j�dkr�P|d
kr�|j�q|j	|�qWdS)Nrzhelp> rrrrr#r��quitrr�)rr#r�r�)r�r�)
r�r��getliner��EOFErrorr r"r�r�r)rGr�rrrr�Ks"
,
zHelper.interactcCs8|jtjkrt|�S|jj|�|jj�|jj�SdS)z.Read one line, using input() when appropriate.N)r�rr�r�r�r�r�)rG�promptrrrr�`s

zHelper.getlinecCs<t|�td�k�r|j�}|dkr,|j�n�|dkr>|j�n�|dkrP|j�n�|dkrb|j�n�|dd�dkr�|j|j�d�n�||jkr�|j|�nj|dkr�t	t
|�d�nR||jkr�|j|�n<||j
kr�|j|�n&|r�t	|d|jd
�nt	td|jd
�n$t|t��r|�nt	|d|jd
�|jjd�dS)Nr�keywords�symbols�topicsr��zmodules rrrrzHelp on %s:)r�r)rrr)r�r �listkeywords�listsymbols�
listtopics�listmodulesr!r��
showsymbolr$�evalr��	showtopicr�r�rDr�r�r�r�)rGr�rrrris6




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

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

)r�r�rr�rM)rGrrrr��szHelper.listtopicscCs,yddl}Wn tk
r,|jjd�dSX|jj||jj|��}|s`|jjdt|��dSt|�td�kr||j	||�S|\}}y|jj|}Wn(t
k
r�|jjdt|��dSX|j�d}|r�|p�dd|}|�r ddl}ddj
|j��d}	|j|	d	�}
|d
dj
|
�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�r�rxr�r�r�r��KeyErrorr �textwrapr#r!�wrapr�)rG�topic�
more_xrefs�
pydoc_data�target�label�xrefsr$r�r3�wrapped_textrrrr��s6zHelper.showtopiccCs�yddl}Wntk
r dSX|jj||jj|��}|sDtd��t|t�rZ|j||�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�t
Sorry, topic and keyword documentation is not available because the
module "pydoc_data.topics" could not be found.
rzcould not find topicr�)r�r)	r�r�r�rxr�rtr�rD�	_gettopic)rGr�r�r�r�r�r�r$rrrr��s	
zHelper._gettopiccCs*|j|}|jd�\}}}|j||�dS)Nr�)r��	partitionr�)rG�symbolr�r�rhr�rrrr��s
zHelper.showsymbolcsv|r |jjdj|��t|�nR|jjd�i}|fdd���fdd�}t�j�|d�|j|j��|jjd�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}|jd�dkr:d||<dS)	N�	z	.__init__z
 (package)rrri����i����)�find)rr)r�r�rrr�callbacksz$Helper.listmodules.<locals>.callbackcs�d|d�dS)Nr)r))r�rr�onerrorsz#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�runrrM)rGrPr�r�r)r�rr��s
zHelper.listmodules)r�r)r�r�)r�r�)r�r�)r�r)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r)r�r�)r�r�)r�r�)r�r)r�r)rr)r�rr�r)rrr#r)rrdrrr�rrrrr�rrrr�r�r r!r"r#r$)r�r�r r!r"r#r$)rdr)r%r&r'r(r)r*r+r,r-r.r/r0)rrr�rrr)r1r2)rBrC)rDrE)rFrG)rHr4)rDrI)rJrK)rLrM)rNrO)rPrQ)rRrS)rUrV)rWrX)rYrZ)r[r\)r^r)r_r`)rar)rBrb)rcr�)rdre)rgr])rhri)rjrk)rlrm)rnro)rprq)rprr)rsrt)rurv)rwrx)ryr)r�r{)r|r)r}r~)rr)r�r)r�r�)r�r�)r�r�)r�r�)r�r�)rr�)r�r�)r�r�)r�r�)r�rf)r�rf)r�rf)r�rf)r�rf)r�rf)r�r�)r�r�)r�r6)r�r�)r�r�)r�r�)r�r�)r�r�)NN)r�r�)r)r)r)!r'r(rdr�Z_strprefixesZ_symbols_inverser�r�r�Zsymbols_r�rxr�r�r�r�r�r�rr�r�r�r�rr�rr�r�r�r�r�r�r�rrrrr��s6





	
 r�c@seZdZdZddd�ZdS)r�z7An interruptible scanner that searches module synopses.NcCs
|r|j�}d|_i}xztjD]p}|dkrd||<|dkrH|d|d�qt|�jpTd}|jd�d}|d|}|j�j|�dkr|d||�qW�xdtj	|d�D�]R\}	}}
|jr�P|dkr�|d|d�q�ytj
|	|�}Wntk
r�w�YnX|j}t
|d	��rny|j|�}
Wn&tk
�r:|�r4||�w�YnXttj|
���pNd}t
|d
��rh|j|�}nd}n^ytjj|�}Wn&tk
�r�|�r�||�w�YnX|j�r�|jj�dnd}t|dd�}|d|}|j�j|�dkr�||||�q�W|�r|�dS)NF�__main__rrrrz - )r��
get_source�get_filenamer_)r�r�rr�r�r^r!r�rGr��	_get_specr�r�rlr�rYr�r��StringIOr�r�r�r�r�r�rE)rGr�rPZ	completerr��seenr)r*r�rRrSr�r��sourcerr�rrrr�s`zModuleScanner.run)NNN)r'r(rdr^r�rrrrr�sr�cCsDdd�}dd�}tj��"tjd�t�j|||d�WdQRXdS)zAPrint all the one-line module summaries that contain a substring.cSs6|dd�dkr |dd�d}t||o.d|�dS)Nr�z	.__init__z
 (package)z- i����i����)r�)rr)r�rrrr�Oszapropos.<locals>.callbackcSsdS)Nr)r)rrrr�Sszapropos.<locals>.onerror�ignore)r�N)�warnings�catch_warnings�filterwarningsr�r�)rPr�r�rrrr�Ms


r�cs�ddl�ddl�ddl�ddl�Gdd�d�jj��G�fdd�d�jj��G�����fdd�d�j�}|||�}|j�x|j	r�|j
r�tjd	�q~W|S)
a7Start 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.time()
        >>> timeout = 1                    #seconds

        This is a short timeout for testing purposes.

        >>> while serverthread.serving:
        ...     time.sleep(.01)
        ...     if serverthread.serving and time.time() - 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|jjd�rd}nd}|jd�|jdd|�|j�|jj|j|j|�jd��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)	rrk�
send_response�send_header�end_headers�wfiler��
urlhandlerr�)rG�content_typerrr�do_GET�s

z(_start_server.<locals>.DocHandler.do_GETcWsdS)Nr)rGr�rrr�log_message�sz-_start_server.<locals>.DocHandler.log_messageN)r'r(rdr�r�rrrr�
DocHandler�sr�cs(eZdZdd�Z�fdd�Zdd�ZdS)z _start_server.<locals>.DocServercSs6d|_|j|f|_||_|jj||j|j�d|_dS)N�	localhostF)�host�addressr�rRr��handlerr�)rG�portr�rrrr��s
z)_start_server.<locals>.DocServer.__init__csBx4|js4�j|jj�gggd�\}}}|r|j�qW|j�dS)Nr)r��select�socketr��handle_request�server_close)rGZrd�wr�ex)r�rr�serve_until_quit�s
z1_start_server.<locals>.DocServer.serve_until_quitcSs |jj|�|jr|j|�dS)N)rR�server_activater�)rGrrrr��sz0_start_server.<locals>.DocServer.server_activateN)r'r(rdr�r�r�r)r�rr�	DocServer�srcs:eZdZ�fdd�Z����fdd�Zdd�Zdd�Zd	S)
z#_start_server.<locals>.ServerThreadcs,||_t|�|_�jj|�d|_d|_dS)NF)r�r)r��Threadr��serving�error)rGr�r�)�	threadingrrr��s

z,_start_server.<locals>.ServerThread.__init__cstyF�jj�_��_�jj�_t|j��_�|j	|j
�}||_|j�Wn(t
k
rn}z||_WYdd}~XnXdS)zStart the server.N)�server�
HTTPServerrRr�r��Message�MessageClass�staticmethodr�r��ready�	docserverr�rYr)rGZdocsvr�e)r�r�email�httprrr��s

z'_start_server.<locals>.ServerThread.runcSs,d|_|j|_|j|_d|j|jf|_dS)NTz
http://%s:%d/)rr��server_portr�r )rGrrrrr
�sz)_start_server.<locals>.ServerThread.readycSs&d|j_|j�d|_d|_d|_dS)z&Stop the server and this thread nicelyTNF)rr�r#rr )rGrrr�stop�s
z(_start_server.<locals>.ServerThread.stopN)r'r(rdr�r�r
rr)r�rr
rrrr�ServerThread�s
rg{�G�z�?)
�http.server�
email.messager�rr�BaseHTTPRequestHandlerrrr/rr�time�sleep)r�r�r�threadr)r�rr
rr�rr�
_start_server[s8&
r�	text/htmlcsG�fdd�dt�}|���fdd���fdd���fdd���fd	d
���fdd���fd
d���fdd���fdd����������fdd�}|jd�r�|dd�}|dkr�tjjtjjt��}tjj||�}t|��}dj|j	��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)rGrr�css_pathZcss_link)�html_navbarrrr�sz#_url_handler.<locals>._HTMLDoc.pageN)r'r(rdrr)rrr�_HTMLDoc�srcs>�jdtj�tj�dtj�f�}d|�jtjdd��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)�terse)r�r��python_version�python_build�python_compiler)rO)r�rrr
	s
z!_url_handler.<locals>.html_navbarcs�dd�}�jddd�}dd�tjD�}�j||�}|d�jd	dd
|�g}i}x tjD]}|j�j||��qVW|jd�dd
j|�fS)zModule Index page.cSsd||fS)Nz<a href="%s.html">%s</a>r)r*rrr�	bltinlink+	sz3_url_handler.<locals>.html_index.<locals>.bltinlinkz7<big><big><strong>Index of Modules</strong></big></big>z#ffffffz#7799eecSsg|]}|dkr|�qS)r�r)rtr*rrrr�1	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�rrrr
r~r#)r!r
�namesrr�r)r�rr�
html_index(	sz _url_handler.<locals>.html_indexc	s�g��fdd�}tj��*tjd�dd�}t�j|||d�WdQRXdd	�}g}�jd
dd�}x"�D]\}}|j||�|�qhW|�jd
|dddj|��}d|fS)zSearch results page.cs:|dd�dkr |dd�d}�j||o0d|f�dS)Nr�z	.__init__z
 (package)z- i����i����)r
)rr)r�)�
search_resultrrr�F	sz3_url_handler.<locals>.html_search.<locals>.callbackr�cSsdS)Nr)r)rrrr�M	sz2_url_handler.<locals>.html_search.<locals>.onerror)r�NcSsd||fS)Nz<a href="%s.html">%s</a>r)r*rrrr!R	sz4_url_handler.<locals>.html_search.<locals>.bltinlinkz5<big><big><strong>Search Results</strong></big></big>z#ffffffz#7799eezkey = %sz#ee77aaz<br>zSearch Results)	r�r�r�r�r�r
r
rr#)	rPr�r�r!rqr
r*r�r)r�)r$r�html_searchA	s 

z!_url_handler.<locals>.html_searchcsLdd�}�jddd�}ttjj��}�j||�}|�jddd|�}d|fS)zIndex of topic texts available.cSsd||fS)Nz<a href="topic?key=%s">%s</a>r)r*rrrr!b	sz4_url_handler.<locals>.html_topics.<locals>.bltinlinkz,<big><big><strong>INDEX</strong></big></big>z#ffffffz#7799eeZTopicsz#ee77aa)r
r�r�r�rMrr)r!r
r"r)r�rr�html_topics_	sz!_url_handler.<locals>.html_topicscsL�jddd�}ttjj��}dd�}�j||�}|�jddd|�}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*rrrr!v	sz6_url_handler.<locals>.html_keywords.<locals>.bltinlinkZKeywordsz#ee77aa)r
r�r�r�rMrr)r
r"r!r)r�rr�
html_keywordso	sz#_url_handler.<locals>.html_keywordscs�tj�}t||�}|j|�\}}||jkr0d}nd}�jd|dd�}d�j|�}�j|dd|�}|r�t|j	��}dd	�}�j
||�}�jd
dd|�}d||fdj|||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*rrrr!�	sz7_url_handler.<locals>.html_topicpage.<locals>.bltinlinkzRelated help topics: z%s %sr)
r�r�r�r�r�r
r2rr�r!rrr#)r��bufZhtmlhelprr�rr
r!)r�rr�html_topicpage~	s&



z$_url_handler.<locals>.html_topicpagecs@t|dd�}|dkr$|dkr$td��t|�}�j||�}||fS)Nr)r�rzcould not find object)r�rtr�r�)r rBr�content)r�rr�html_getobj�	sz!_url_handler.<locals>.html_getobjcsP�jddd�}dj�fdd�tt|�|�D��}|�j|dd|�}d||fS)	Nz,<big><big><strong>Error</strong></big></big>z#ffffffz#7799eez<br>c3s|]}�j|�VqdS)N)r�)rtr�)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_errorcst|}|jd�r|dd
�}�y|dkr4��\}}�n�|dkrH��\}}n�|dkr\��\}}n�d|k�r&|jd�\}}}|d	kr��|�\}}n�|d
kr�y�|�\}}Wn tk
r��|�\}}YnXn\|dk�r|dkr��\}}n4y�|�\}}Wn"tk
�r�|�\}}YnXntd��n�|�\}}Wn2tk
�rf}z�||�\}}WYdd}~XnX�j||�S)zGenerate an HTML page for url.z.htmlN�rr~r�r�rpz
search?keyz	topic?keyzget?keyz
bad pydoc url���)rr~)rr~)rkr�rtrYr)r Zcomplete_urlrr*�oprhr�)r�r,r+r#r'r%r)r&rr�
get_html_page�	s>



 z#_url_handler.<locals>.get_html_pager�rNztext/cssrz	text/htmlz"unknown content type %r for url %s)rrjr	r�dirname�realpathr_r#r��	readlinesr})r r�rr0Z	path_herer�fpr)	r�r,r+r#r'rr%r)r&r�_url_handler�s*	
(


r5T)�open_browsercCs�ddl}tt|�}|jr&t|j�dS|jr�d}|r@|j|j�z�y^td|j�t|�xD|jr�td�}|j	�}|dkr|PqZ|dkr�|j|j�qZt|�qZWWnt
tfk
r�t�YnXWd|jr�|j�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)
�
webbrowserrr5rr�rr�r r�r�r�r�r)r�r6r7ZserverthreadZserver_help_msgr�rrr�browse�	s2

r8cCst|t�o|jtj�dkS)Nr)r�rDr�r	�sep)rWrrr�ispath
sr:cCsddl}Gdd�dt�}dtjkrXtjjtjd�}|tjkrJtjj|�tjjdd��yp|jtjdd�d�\}}d	}d	}d	}d}xP|D]H\}	}
|	d
kr�d}d}|	dkr�t	|
�dS|	d
kr�d}|
}|	dkr�d}q�W|r�|dkr�d}t
||d�dS|�s|�x�|D]�}t|��r4tjj|��r4t
d|�Py`t|��rVtjj|��rVt|�}|�r�t|��r~tjj|��r~t|�nt|�n
tj|�Wn,tk
�r�}zt
|�WYdd}~XnX�qWWnN|j|fk
�rtjjtjjtjd��d}
t
dj|
tjd��YnXdS)z@Command-line interface (looks at sys.argv to decide what to do).rNc@seZdZdS)zcli.<locals>.BadUsageN)r'r(rdrrrr�BadUsage

sr;rrrzbk:p:wFz-bTz-kz-pz-w)r6zfile %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} -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.  The -p option can be used with
    the -b option to explicitly specify the server port.

{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�r9)�getoptrYrrr	r1�argv�remove�insertr�r8r:�existsr�r�r�rr�r�rr�rr�r�rr9)r<r;�	scriptdir�optsr��writingZstart_serverr6r��opt�val�argrQr�rrr�cli
sd




$rGr�)NN)r)r)r�rN)r�rN)r)rN)r)r)Xr^r@rYr]r\riZimportlib._bootstrapr�Zimportlib._bootstrap_external�importlib.machinery�importlib.utilrr�r	rGr�rrrr��urllib.parserAr��collectionsr�reprlibr�	tracebackrrrr&r+r2r5r;r%�
IGNORECASEr<r=rCrHrLrXrnror�r�r�r�rYr�r�r�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�r3r�r�r�r�r$r�r�r�rr�r�rr5r8r:rGr'rrrr�<module>#s�		


	'
0>*- d",






=
n%V