AlkantarClanX12

Your IP : 18.191.200.223


Current Path : /opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/__pycache__/pydoc.cpython-39.pyc

a

R�f,��@s*dZdgZdZdZdZddlZddlZddlZddl	Zddl
ZddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlmZddlmZdd	lmZd
d�Zdd
�Z dd�Z!dd�Z"dd�Z#dd�Z$dd�Z%dd�Z&dd�Z'dd�Z(dd�Z)d d!�Z*e�+d"ej,�Z-d#d$�Z.d%d&�Z/d'd(�Z0d)d*�Z1d�d+d,�Z2d-d.�Z3d/d0�Z4d1d2�Z5d3d4�Z6ifd5d6�Z7Gd7d8�d8e8�Z9d9d:�Z:difd;d<�Z;Gd=d>�d>�Z<Gd?d@�d@e�Z=GdAdB�dBe<�Z>GdCdD�dDe�Z?GdEdF�dFe<�Z@GdGdH�dHe@�ZAdIdJ�aBdKdL�ZCdMdN�ZDdOdP�ZEdQdR�ZFdSdT�ZGdUdV�ZHdWdX�ZIdYdZ�ZJd�d[d\�ZKe@�ZLeA�ZMe>�ZNd�d]d^�ZOd�d`da�ZPd�dbdc�ZQd�ddde�ZRd�dgdh�ZSGdidj�dj�ZTeT�ZUGdkdl�dl�ZVdmdn�ZWdodp�ZXd�drds�ZYd�dtdudv�dwdx�ZZdydz�Z[d{d|�Z\d}d~�Z]dd��Z^e_d�k�r&e^�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}tjD]H}tj�|pd�}tj�|�}||vrtj�|�r|�|�|�|�q|S)zAConvert sys.path into a list of absolute, existing, unique paths.�.)�sys�path�os�abspath�normcase�isdir�append)�dirsZnormdirs�dirZnormdir�r�*/opt/alt/python39/lib64/python3.9/pydoc.py�pathdirsRs

rcCst�|�ot|tj�S�N)�inspectZisclass�
isinstance�types�GenericAlias��objectrrr�_isclass^srcCsNtj�|j�}|durdS|j�d�dd�D]}t||�}q.t|�sJdS|S)Nr���)r�modules�get�
__module__�__qualname__�split�getattrr)�func�cls�namerrr�
_findclassasr%c	Cs�t�|�rH|jj}|j}t|�r>tt||d�d�|jur>|}n|j}�n"t�|�r||j}t	|�}|dusvt||�|urzdSn�t�
|�r�|j}|j}t|�r�|jd||jkr�|}n|j}n�t|t
�r�|j}|j}t	|�}|dus�t||�|ur�dSntt�|��st�|��rf|j}|j}t||�|u�r.dSt�|��rjt|dd�}t|t��rj||v�rj||SndS|jD]F}ztt||��}Wnt�y�Y�qpYn0|du�rp|S�qpdS)N�__func__r�	__slots__)r�ismethodr&�__name__�__self__rr!�	__class__�
isfunctionr%�	isbuiltinrr�property�fgetZismethoddescriptor�isdatadescriptor�__objclass__�ismemberdescriptor�dict�__mro__�
_getowndoc�AttributeError)�objr$�selfr#r"�slots�base�docrrr�_finddocksZ
�


�



r<cCsdzJt�|d�}|durWdS|turFt|�j}t|t�rF||krFWdS|WSty^YdS0dS)zUGet the documentation string for an object if it is not
    inherited from its class.�__doc__N)r�__getattribute__�typer=r�strr6)r7r;Ztypedocrrrr5�s
r5c	CsNt|�}|dur6zt|�}Wnttfy4YdS0t|t�sDdSt�|�S)z�Get the documentation string for an object.

    All tabs are expanded to spaces.  To clean up docstrings that are
    indented to line up with blocks of code, any whitespace than can be
    uniformly removed from the second line onwards is removed.N)r5r<r6�	TypeErrorrr@rZcleandoc)rr;rrr�_getdoc�s
rBcCs,t|�pt�|�}|r(t�dd|���p*dS)z-Get the doc string or comments for an object.z^ *
�)rBrZgetcomments�re�sub�rstrip)r�resultrrr�getdoc�srHcCsf|���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.�
�rrC�N)�stripr �lenrF�join)r;�linesrrr�splitdoc�srPcCs"|j}|j|kr|jd|}|S)z@Get a class name and qualify it with a module name if necessary.r)r)r)r�modnamer$rrr�	classname�s
rRcCs<t�|�p8t|�p8t�|�p8t�|�p8t�|�p8t�|�S)z>Check if an object is of a type that probably means it's data.)r�ismoduler�	isroutineZisframeZistracebackZiscoderrrr�isdata�s����rUcGs.|r*|d�|�|d��}|dd�}q|S)z/Do a series of global replacements on a string.rJrrKN)rNr )�textZpairsrrr�replace�srWcCsXt|�|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�rKN�...)rM�max)rV�maxlenZpreZpostrrr�cram�s
$r\z at 0x[0-9a-f]{6,16}(>+)$cCst�d|�S)z>Remove the hexadecimal id from a Python object representation.z\1)�_re_stripidrE�rVrrr�stripid�sr_cCs<t�|�rdSt�|�r8t|dd�}t�|�p4|duSdS)zo
    Returns True if fn is a bound method, regardless of whether
    fn was implemented in Python or in C.
    Tr*NF)rr(r-r!rS)�fnr8rrr�_is_bound_method�s

racCs^i}t�|tj�D]\}}d||<q|jD]}|�t|��q*|��D]}t||�||<qF|S�NrJ)r�
getmembersrT�	__bases__�update�
allmethods�keysr!)�cl�methods�key�valuer:rrrrf�s

rfcCs8g}g}|D]"}||�r$|�|�q|�|�q||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_listsrpcCs\|dvrdS|�d�r$|�d�r$dS|�d�r<t|d�r<dS|durL||vS|�d�SdS)	z3Decide whether to show documentation on a variable.>r)r'�__date__rr�
__cached__�__builtins__�
__loader__�__credits__r=�__version__�__path__�__package__�
__author__�__spec__�__file__r�__rJ�_�_fieldsTN)�
startswith�endswith�hasattr)r$�allr7rrr�visiblenamesr�cCsXg}t�|�D]D\}}}}t�|�r@d}t|t�r@|jdur@d}|�||||f�q|S)zCWrap inspect.classify_class_attrs, with fixup for data descriptors.�data descriptorN�readonly property)r�classify_class_attrsr0rr.�fsetr
)r�resultsr$�kindr#rkrrrr�)s
r�csZt|dg��z�fdd�t��D��Wnty<i�Yn0�fdd�}|j|d�dS)zGSort the attrs list in-place by _fields and then alphabetically by namer~csi|]\}}||t���qSr)rM)�.0�ir$)�fieldsrr�
<dictcomp>:�z#sort_attributes.<locals>.<dictcomp>cs��|dd�|dfS�Nr)r)�attr)�field_orderrr�<lambda>=r�z!sort_attributes.<locals>.<lambda>�rjN)r!�	enumeraterA�sort)�attrsrZkeyfuncr)r�r�r�sort_attributes4s
r�cCs:tj�|�r6dD]$}tj�tj�|d|��rdSqdS)z3Guess whether a path refers to a package directory.)z.pyz.pyc�__init__TF)r	rr�isfilerN)r�extrrr�	ispackageBs
r�cCs�|��}|dd�dks |��s0|��}|sq0q|��}|dd�dkrT|dd�}|dd�dkr�|dd�}|dd�dkr�|dd�}|��s�|��}|s�q�q�|�d�d	��}nd}|S)
NrJ�#�zr"""rX�"""r�\r)�readlinerLr )�file�linerGrrr�source_synopsisJsr�c
Cs2t�|�j}|�|d�\}}|dus.||k�r.|�ttjj��rJtjj	}n |�ttjj
��rftjj}nd}|dur�zt�
|�}Wnty�YdS0|�t|�}Wd�n1s�0Yn^|d|�}tjjd||d�}ztj�|�}	WnYdS0tjd=|	j�r|	j��dnd}||f||<|S)z.Get the one-line summary out of a module file.)NNNZ__temp__��loaderr)r	�stat�st_mtimerr��tuple�	importlib�	machinery�BYTECODE_SUFFIXES�SourcelessFileLoader�EXTENSION_SUFFIXES�ExtensionFileLoader�tokenize�open�OSErrorr��util�spec_from_file_location�
_bootstrap�_loadrrr=�
splitlines)
�filename�cache�mtimeZ
lastupdaterGZ
loader_clsr�r��spec�modulerrr�synopsis[s6

(

�r�c@s eZdZdZdd�Zdd�ZdS)�ErrorDuringImportzEErrors that occurred while trying to import something to document it.cCs||_|\|_|_|_dSr)r��excrk�tb)r8r��exc_inforrrr��szErrorDuringImport.__init__cCs|jj}d|j||jfS)Nzproblem in %s - %s: %s)r�r)r�rk)r8r�rrr�__str__�szErrorDuringImport.__str__N)r)rrr=r�r�rrrrr��sr�c	Cs�tjj}t|d��"}||�t|��k}Wd�n1s:0Ytj�|�}tj�	|�\}}|rttj
�||�}ntj
�||�}tjj
|||d�}ztj�|�WSt|t����Yn0dS)z<Import a Python source file or compiled file given its path.�rbNr�)r�r��MAGIC_NUMBERr��readrMr	r�basename�splitext�_bootstrap_externalr��SourceFileLoaderr�r�r�r�rr�)	r�magicr�Zis_bytecoder�r$r�r�r�rrr�
importfile�s0r�c	sz^|rT�tjvrT�tjvrT�fdd�tjD�}�g|D]}tj|||<tj|=q8t��}Wnzt��\}}}}	�tjvr�ttj�j|	��n>|tur�t|j|	��n(t	|t
�r�|j�kr�YdSt�t����Yn0��d�dd�D],}
zt
||
�}Wq�t�yYdS0q�|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)r��m�rrr�
<listcomp>�r�zsafeimport.<locals>.<listcomp>NrrJ)rr�builtin_module_names�
__import__r�r�r{�SyntaxErrorr��
issubclass�ImportErrorr$r r!r6)r�	forceloadr�Zsubsrjr�r�rkr��info�partrr�r�
safeimport�s*


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/libraryNrKcGs�||f|}zDt�|�r$|j|�WSt|�r8|j|�WSt�|�rN|j|�WSWntybYn0t�|�rx|j	|�S|j
|�S)z%Generate documentation for an object.)rrS�	docmoduler�docclassrT�
docroutiner6r0�docdata�docother)r8rr$�argsrrr�document�s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)�reprr?r)rA)r8rr$r��messagerrr�fail�s�zDoc.failZstdlibcCs�zt�|�}Wnty$d}Yn0tj�d|j�}tj�|�}t	|t
t��r�|jdvsx|�|�r�|�tj�
|d��s�|jdvr�|�d�r�d|�d�|j��f}q�tj�
||j��d	�}nd
}|S)z*Return the location of module docs or None�
(built-in)r�)
�errno�
exceptionsZgcZimp�marshal�posix�signalr�_threadZ	zipimportz
site-packages)z	xml.etreeztest.pydoc_mod)zhttp://zhttps://z%s/%s�/�.htmlN)r�
getabsfilerAr	�environrr�rrrr?r)rrNrF�lower)r8rZbasedirr��doclocrrr�	getdocloc�s(
����
z
Doc.getdocloc)N)N)r)rrr	r�rr�version_infor�r�r�r�r�r�r��docpropertyr��	sysconfigZget_pathr�rrrrr��s��

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�rr��maxlist�maxtuple�maxdict�	maxstring�maxother�r8rrrr�
s
zHTMLRepr.__init__cCst|dddddd�S)N�&z&amp;�<z&lt;�>z&gt;)rW�r8rVrrr�escapeszHTMLRepr.escapecCst�||�Sr)rr��r8rrrrr�sz
HTMLRepr.reprcCsZtt|�d�r@dd�t|�j���}t||�r@t||�||�S|�ttt	|��|j
��S�Nr)�repr_r})r�r?rNr)r r!rr\r_r�r��r8ro�levelZ
methodnamerrr�repr1s

zHTMLRepr.repr1cCs^t||j�}t|�}d|vrJdt|dd�vrJd|d|�|�|dSt�dd|�|��S)Nr��\\rC�rrz-((\\[\\abfnrtv\'"]|\\[0-9]..|\\x..|\\u....)+)z<font color="#c040c0">\1</font>)r\r�r�rWrrDrE�r8ror
�testZtestreprrrr�repr_strings�zHTMLRepr.repr_stringcCs@z|�ttt|��|j��WS|�d|jj�YS0dS�Nz
<%s instance>)rr\r_r�r�r+r)�r8ror
rrr�
repr_instance*szHTMLRepr.repr_instanceN)r)rrr=r�rr�rr�repr_strrZrepr_unicoderrrrr�sr�c@seZdZdZe�ZejZejZdd�Zd1dd�Z	d2d
d�Z
dd
�Zdd�Zd3dd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdiiifdd �Zd4d!d"�Zd5d#d$�Zddiifd%d&�Zd'd(�Zddiiidfd)d*�Zd6d+d,�ZeZd7d-d.�Zd8d/d0�ZdS)9�HTMLDocz'Formatter class for HTML documentation.cCsd||fS)�Format 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)r8�title�contentsrrr�page;s�zHTMLDoc.pagerCcCsd|||||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>
    �&nbsp;r)r8r�fgcol�bgcolZextrasrrr�headingEs�zHTMLDoc.heading�Nrc	
Cs^|durdd|d}d|||f}	|r@|	d||||f}	n|	d|||f}	|	d|S)	z Format a section with a heading.Nz<tt>rz</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)
r8rrrr�widthZpreludeZ
marginaliaZgaprGrrr�sectionPs�
��zHTMLDoc.sectioncGsd|}|j|g|�R�S)z$Format a section with a big heading.z<big><strong>%s</strong></big>)r )r8rr�rrr�
bigsectionfszHTMLDoc.bigsectionc
Cs&|�|���}t|dddddddd�	S)z!Format literal preformatted text.�

z
 
r�rrI�<br>
)r�
expandtabsrWrrrr�	preformatks�zHTMLDoc.preformatr�cCs�d}t|�|d|}t|�D]X}|dd|}t|||||�D]$}|t|�krJ||||�d}qJ|d}q d|S)z0Format a list of items into a multi-column list.rCrJz<td width="%d%%" valign=top>r�r#z</td>z7<table width="100%%" summary="list"><tr>%s</tr></table>)rM�range)r8�list�formatZcolsrG�rows�colr�rrr�multicolumnqs
zHTMLDoc.multicolumncCsd|S)Nz<font color="#909090">%s</font>rrrrr�grey}r�zHTMLDoc.greycGs*|D] }||vrd|||fSq|S)z:Make a link for an identifier, given name-to-URL mappings.�<a href="%s">%s</a>r)r8r$Zdictsr3rrr�namelinkszHTMLDoc.namelinkcCsN|jtj�|j�}}t||�rDt||�|urDd|j|t||�fSt||�S)zMake a link for a class.z<a href="%s.html#%s">%s</a>)r)rrrrr�r!rR)r8rrQr$r�rrr�	classlink�s�zHTMLDoc.classlinkcCsd|j|jfS)zMake a link for a module.�<a href="%s.html">%s</a>)r)rrrr�
modulelink�szHTMLDoc.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)r-)r,)r8Z
modpkginfor$rr��shadowed�urlrVrrr�
modpkglink�s

zHTMLDoc.modpkglinkcCsd||fS)zMake a link to source file.z<a href="file:%s">%s</a>r)r8r3rrrr�filelink�szHTMLDoc.filelinkcCs�|p|j}g}d}t�d�}|�||�}	|	s0�qh|	��\}
}|�||||
���|	��\}}
}}}}|
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�rP|�|�	||||��n|�|�	||��|}q|�|||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.rzJ\b((http|https|ftp)://\S+[\w/]|RFC[- ]?(\d+)|PEP[- ]?(\d+)|(self\.)?(\w+))�"z&quot;r-z'http://www.rfc-editor.org/rfc/rfc%d.txtz)https://www.python.org/dev/peps/pep-%04d/rJ�(zself.zself.<strong>%s</strong>NrC)rrD�compile�search�spanr
�groupsrW�intr.rN)r8rVr�funcs�classesrir��here�pattern�match�start�endr�ZschemeZrfcZpepZselfdotr$r3rrr�markup�s8

zHTMLDoc.markupc
Cs�d}|D]�}t|�td�ur�|\}}|d}||�||�}|r�||fkr�g}|D]}	|�|�|	|��qR|dd�|�d}|d}qt|�tg�ur|d|�|||�}qd	|S)
zAProduce HTML for a class tree as given by inspect.getclasstree().rCrz"<dt><font face="helvetica, arial">r7�, �)z
</font></dt>z
<dd>
%s</dd>
z
<dl>
%s</dl>
)r?r/r
rN�
formattree)
r8�treerQ�parentrG�entry�c�bases�parentsr:rrrrG�s"
�
zHTMLDoc.formattreec#
s�|j}z
|j}Wnty&d}Yn0|�d�}g}tt|�d�D],}|�dd�|d|d��||f�qFd�||dd��}	d|	}
z&t�	|�}t
j�|�}��
||�}
Wnty�d}
Yn0g}t|d��r2t|j�}|dd	�d
k�r|dd�dk�r|d	d���}|�d��|��t|d
��rT|���t|j���|�rl|
dd�|�}
��|�}|du�r�dt�}nd}��|
ddd|
|�}t�|tj�}gi}}t�|t�D]Z\}}|du�s�t�|��p�||u�r�t|||��r�|�||f�d|||<||<�q�|D]�\}}|jD]n}|j|j}}tj �!|�}||k�r:|�r:t||��r:t"||�|u�r:||v�r:|d|||<||<�q:�q,gi}}t�|tj#�D]p\}}|du�s�t�$|��s�t�|�|u�r�t|||��r�|�||f�d|||<t�%|��r�||||<�q�g}t�|t&�D]&\}}t|||��rH|�||f��qH��'t(|��j)||�}|�o�d|}|d|}t|d��rg}t*�+|j,�D]\}}} |�||| df��q�|�-���.|�j/�}!|��0ddd|!�}n.|�r6��.|�fdd��}!|��0d dd|!�}|�r�d!d"�|D�}"��1t�2|"d�|�g}!|D]"\}}|!���3|||||���qd|��0d#dd$d%�|!��}|�r�g}!|D]"\}}|!���3|||||���q�|��0d&dd'd%�|!��}|�r4g}!|D]\}}|!���3||���q�|��0d(dd)d*�|!��}t|d+��rh��'t|j4��j)�}!|��0d,dd|!�}t|d-��r���'t|j5��j)�}!|��0d.dd|!�}|S)/z/Produce HTML documentation for a module object.NrrJz5<a href="%s.html"><font color="#ffffff">%s</font></a>r�)<big><big><strong>%s</strong></big></big>r�rv��$Revision: �$z
version %srqz (%s)rEz-<br><a href="%(docloc)s">Module Reference</a>rC�#ffffff�#7799eez<a href=".">index</a><br>r�z.html#z#-z<tt>%s</tt>z
<p>%s</p>
rwrzPackage Contentsz#aa55cccs��|d�Srb)r1��trrrr�9r�z#HTMLDoc.docmodule.<locals>.<lambda>ZModulescSsg|]\}}|�qSrr�r�rjrkrrrr�>r�z%HTMLDoc.docmodule.<locals>.<listcomp>ZClasses�#ee77aar�Z	Functionsz#eeaa77ZDataz#55aa55r#ryZAuthorruZCredits)6r)�__all__r6r r&rMr
rNrr��urllib�parseZquoter5rAr�r@rvrLrrqr��localsrrcrSr�	getmoduler�rdrrrrr!rTr-r,rUrDrHr%�pkgutil�iter_modulesrwr�r+r4r!rG�getclasstreer�ryru)#r8rr$�mod�ignoredr��partsZlinksr�Z
linkedname�headrr3r5r��versionr�rGrr>Zcdictrjrkr:rQr�r=Zfdict�datar;�modpkgs�importer�ispkgr�	classlistrrrr��s�


��


$


�

�

 

�����������zHTMLDoc.docmodulec	s��j}|p|}�j}g}	|	j�G�fdd�d�}
|
��tt����}t|�dkr�����d�|D]}�d��|�j	��qd�d���������fdd�}
����fd	d
�}��������fdd�}�fd
d�t
��D�}i�|D]j\}}}}d|d|�|<}zt�|�}Wnt�y2Yn0z|�|<Wq�t
�yTYq�0q�|�rt|�rn|���n|dd�t|�fdd��\}}�tju�r��tju�r�|}�qXn"��u�r�d}nd����j	�}|d7}t|��|
d||dd��}|
d||dd��}|
d||dd��}|d||dd��}|d||d d��}|d!||d"d��}|gk�slJ�|}�qXd#�|	�}	||k�r�d$||f}nd%|||f}|�r�g}|D]}|���|�j	���q�|d&d'�|�}d#}zt���}Wntt
f�yd(}Yn0|�r@t|�}|�r@|d)k�r@|��|�d*}t��}|�r\||�pXd#}��|�j����}|�o|d+|}��|d,d-|	d.|�S)/z.Produce HTML documentation for a class object.cs eZdZdd�Z�fdd�ZdS)z(HTMLDoc.docclass.<locals>.HorizontalRulecSs
d|_dSr��Zneedonerrrrr�hsz1HTMLDoc.docclass.<locals>.HorizontalRule.__init__cs|jr�d�d|_dS)Nz<hr>
rJrjr��pushrr�maybejsz.HTMLDoc.docclass.<locals>.HorizontalRule.maybeN�r)rrr�rmrrkrr�HorizontalRulegsrorKz&<dl><dt>Method resolution order:</dt>
z<dd>%s</dd>
�</dl>
cs�t||�\}}|r�����|�|D]b\}}}}zt�|�}Wn$tyd���||���Yn0���||��������d�q&|S)NrI�rprmr!�	Exceptionr�r���msgr�rn�okr$r��homeclsrk�r>r=�hr�mdictr`rrlr8rr�spillzs�
zHTMLDoc.docclass.<locals>.spillcsJt||�\}}|rF����|�|D]\}}}}���||���q&|Sr�rprmr�rs�rxr`rlr8rr�spilldescriptors�sz*HTMLDoc.docclass.<locals>.spilldescriptorsc
s�t||�\}}|r�����|�|D]r\}}}}��t�|�|��}t|�}	|	s`�d|�n0��t|��j����}	d|	}	�d||	f��d�q&|S)Nz<dl><dt>%s</dl>
z<dd><tt>%s</tt>z<dl><dt>%s%s</dl>
rI)rprmr�r!rHrDr%)
rtr�rnrur$r�rvrkr:r;rwrr�	spilldata�s �
z#HTMLDoc.docclass.<locals>.spilldatacs,g|]$\}}}}t|�d�r||||f�qS�)r7�r��r�r$r�r#rkrrrr��s
�z$HTMLDoc.docclass.<locals>.<listcomp>r��-rcs|d�uS�NrKrrT��	thisclassrrr��r�z"HTMLDoc.docclass.<locals>.<lambda>�defined here�inherited from %sz:<br>
z
Methods %scSs|ddkS�NrJ�methodrrTrrrr��r�zClass methods %scSs|ddkS�NrJzclass methodrrTrrrr��r�zStatic methods %scSs|ddkS�NrJz
static methodrrTrrrr��r�zReadonly properties %scSs|ddkS�NrJr�rrTrrrr��r�zData descriptors %scSs|ddkS�NrJr�rrTrrrr��r�zData and other attributes %scSs|ddkS�NrJrerrTrrrr��r�rCz*<a name="%s">class <strong>%s</strong></a>z/<strong>%s</strong> = <a name="%s">class %s</a>�(%s)rEN�()r"z<tt>%s<br>&nbsp;</tt>z#000000z#ffc8d8rX)r)rdr
rr�getmrorMrmr/rr�r!rrrA�popleftrp�builtinsrr�rN�	signature�
ValueErrorr@rrHrDr%r )r8rr$r`r=r>ra�realnamerLrro�mror:rzr}r~r�rjr�rvrk�anchor�	inherited�tagrrM�declr��argspecr;r)	r>r=rxryr`rrlr8r�rr�\s�
�
	
�

�

�
�
�
�
�
�

��
zHTMLDoc.docclasscCs|�d|�|��S�z)Format an argument default value as text.�=)r,r�rrrr�formatvalue�szHTMLDoc.formatvaluec	Cs�|j}|p|}|r|jpdd|}	d}
d}t|�r�|jj}|rZ||ur�d|�||�}
n0|jdurzd|�|jj|�}
nd|�||�}
t�|�s�t�|�r�d}
nd}
||kr�d	|	|f}nD|r�t�||g�|ur�d
|jd||f}d}n|}d|	||f}d}t�	|��rjzt�
|�}Wnttf�y<d}Yn0|�rjt
|�}|d
k�rjd|}|dd�}|�std}|
||�|�|
�o�|�d|
�}|�r�d|S|�t|�|j|||�}|�o�d|}d||fSdS)z;Produce HTML documentation for a function or method object.rCr�r� from N� method of %s instance� unbound %s method�async z$<a name="%s"><strong>%s</strong></a>z<a href="#%s">%s</a>rJz)<a name="%s"><strong>%s</strong></a> = %s�<lambda>z$<strong>%s</strong> <em>lambda</em> r�(...)z'<font face="helvetica, arial">%s</font>z<dl><dt>%s</dt></dl>
z<dd><tt>%s</tt></dd>z<dl><dt>%s</dt>%s</dl>
)r)rar*r+r/r�iscoroutinefunction�isasyncgenfunction�getattr_staticrTr�r�rAr@rr,rDrHr%)r8rr$r`r=r>rirhr�r��note�skipdocs�imclass�asyncqualifierrZreallinkr�r�r�r;rrrr�sl
�
���

��zHTMLDoc.docroutinecCsNg}|j}|r|d|�|�t|�|j�}|r<|d|�|d�d�|�S)z1Produce html documentation for a data descriptor.z!<dl><dt><strong>%s</strong></dt>
z<dd><tt>%s</tt></dd>
rprC)r
rDrHr%rN�r8rr$r`rhr�rlr;rrrr�CszHTMLDoc.docdatacGs|rd|pd}||�|�S)z-Produce HTML documentation for a data object.z<strong>%s</strong> = rC�r�)r8rr$r`raZlhsrrrr�SszHTMLDoc.docothercCs�g}|duri}t�|g�D]<\}}}tdd�|D��r:q|�|d|||vf�d||<q|��|�||j�}|�|dd|�S)z2Generate an HTML index for a directory of modules.Ncss*|]"}dt|�kodknVqdS)i�i��N)�ord�r�Zchrrr�	<genexpr>]r�z HTMLDoc.index.<locals>.<genexpr>rCrJrRrW)r]r^�anyr
r�r+r4r!)r8rr2rfrgr$rhrrrr�indexXs
z
HTMLDoc.index)rC)rrCNr)r�)N)NN)NNN)NN)N)r)rrr=r��_repr_instancer�rrrr r!r%r+r,r.r/r1r4r5rDrGr�r�r�r�r�r�r�r�rrrrr2s>

�

+

y#�
A

rc@s4eZdZdZdd�Zdd�Zdd�ZeZdd	�Zd
S)�TextReprzAClass for safely making a text representation of a Python object.cCs,t�|�d|_|_d|_d|_|_dSr�r�rrrrr�ks
zTextRepr.__init__cCsTtt|�d�r@dd�t|�j���}t||�r@t||�||�Sttt|��|j	�Sr)
r�r?rNr)r r!r\r_r�r�r	rrrrqs

zTextRepr.repr1cCsHt||j�}t|�}d|vrDdt|dd�vrDd|d||dS|S)Nr�rrCr
r)r\r�r�rWrrrrrxs
zTextRepr.repr_stringcCs4zttt|��|j�WSd|jjYS0dSr)r\r_r�r�r+r)rrrrr�szTextRepr.repr_instanceN)	r)rrr=r�rrrrrrrrr�is	r�c@s~eZdZdZe�ZejZdd�Zddd�Zdd�Z	ddd�Z
dd
d�Zddd�Zdd�Z
ddd�Zddd�ZeZddd�Zd	S) �TextDocz'Formatter class for text documentation.cCsd�dd�|D��S)z(Format a string in bold by overstriking.rCcss|]}|d|VqdS)�Nrr�rrrr��r�zTextDoc.bold.<locals>.<genexpr>)rNrrrr�bold�szTextDoc.bold�    cs>|sdS�fdd�|�d�D�}|r4|d��|d<d�|�S)z6Indent text by prepending a given prefix to each line.rCcsg|]}�|�qSrr�r�r���prefixrrr��r�z"TextDoc.indent.<locals>.<listcomp>rIr)r rFrN)r8rVr�rOrr�r�indent�szTextDoc.indentcCs$|�|���}|�|�d|dS)z&Format a section with a given heading.rIr")r�rFr�)r8rrZclean_contentsrrrr �szTextDoc.sectionNrCc
	s�d}|D]�}t|�td�urr|\}}||t|��}|rh||fkrh�fdd�|D�}	|dd�|	�}|d}qt|�tg�ur||�|�||d�}q|S)	zBRender in text a class tree as returned by inspect.getclasstree().rCrc3s|]}t|��VqdSr�rR)r�rK�rQrrr��r�z%TextDoc.formattree.<locals>.<genexpr>r�rErIr�)r?rRrNrG)
r8rHrQrIr�rGrJrKrLrMrr�rrG�s
�zTextDoc.formattreec	Cs|j}tt|��\}}|�d||o(d|�}t|dd�}|�|�}|dur`||�d|d�}|rt||�d|�}g}	t�|t�D]<\}
}|dus�t�	|�p�||ur�t
|
||�r�|	�|
|f�q�g}t�|tj�D]B\}
}|dus�t�
|�s�t�	|�|ur�t
|
||�r�|�|
|f�q�g}
t�|t�D]&\}
}t
|
||��r(|
�|
|f��q(g}t�}t|d��r�t�|j�D]6\}}}|�|�|�r�|�|d	�n
|�|��qr|��||�d
d�|��}g}t�|tj�D]0\}
}|j�|d��r�|
|v�r�|�|
��q�|�r0|��||�d
d�|��}|	�r�dd�|	D�}|�t�|d�|�g}|	D]\}
}|�|�||
|���q^||�dd�|��}|�r�g}|D]\}
}|�|�||
|���q�||�dd�|��}|
�r g}|
D]"\}
}|�|j||
|dd���q�||�dd�|��}t|d��rzt|j�}|dd�dk�rj|dd�dk�rj|dd���}||�d|�}t|d��r�||�dt|j ��}t|d��r�||�dt|j!��}t|d ��r�||�d!t|j"��}zt�#|�}Wnt$�yd"}Yn0||�d#|�}|S)$z5Produce text documentation for a given module object.�NAME� - rXNzMODULE 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.
ZDESCRIPTIONrw�
 (package)zPACKAGE CONTENTSrIrZ
SUBMODULEScSsg|]\}}|�qSrrrVrrrr��r�z%TextDoc.docmodule.<locals>.<listcomp>rJ�CLASSES�	FUNCTIONS�F)r[ZDATArvrOrPrrQZVERSIONrqZDATEryZAUTHORruZCREDITSr�ZFILE)%r)rPrHr r!r�rrcrr\r�r
rTr-rU�setr�r]r^rw�addr�rNrSrrGr_r�r�r@rvrLrqryrur�rA)r8rr$r`Zsynop�descrGr�r�r>rjrkr=rerfZ
modpkgs_namesrgrQrhZ
submodulesrirrdr�rrrr��s�
	���

�
��
$
zTextDoc.docmodulec	sX�j}|p|}�j}�jfdd�}||kr:d��|�}n��|�d|}|rlt||�}	|dd�|	�}g}
|
j�zt���}Wnt	t
fy�d}Yn0|r�t|�}|r�|dkrȈ||d	�t��}
|
r�|
d	�t
t����}t|�d
k�r(�d�|D]}�d||���q�d
�tdd�t���D�tjd�}t|�}d}|�r��d�|d|�D]}�d|��ql||k�r��dt||�d��d
�G�fdd�d�}|�������fdd�}����fdd�}�����fdd�}�fdd�t��D�}|�r$|�r(|���n|dd
�t|�fd d!��\}}�tju�rl�tju�rl|}�qn ��u�r|d"}nd#t��j�}t|��|d$||d%d!��}|d&||d'd!��}|d(||d)d!��}|d*||d+d!��}|d,||d-d!��}|d.||d/d!��}|gk�sJ�|}�qd	�|
�}
|
�s<|d	S|d	��|
��d0�d	S)1z4Produce text documentation for a given class object.cSs
t||�Srr�)rKr�rrr�makenamesz"TextDoc.docclass.<locals>.makename�class z	 = class r�rENr�rIrKzMethod resolution order:r�rCcss.|]&}|j�d�s|jdkrt|j�VqdS)r}r�N)r)rrr@)r�r#rrrr�Cs�z#TextDoc.docclass.<locals>.<genexpr>r�r�zBuilt-in subclasses:z    ... and z other subclassescs eZdZdd�Z�fdd�ZdS)z(TextDoc.docclass.<locals>.HorizontalRulecSs
d|_dSr�rjrrrrr�Usz1TextDoc.docclass.<locals>.HorizontalRule.__init__cs|jr�d�d|_dS)NzF----------------------------------------------------------------------rJrjrrkrrrmWsz.TextDoc.docclass.<locals>.HorizontalRule.maybeNrnrrkrrroTsroc
s�t||�\}}|r|����|�|D]T\}}}}zt�|�}Wn$tyd���||���Yq&0���||����q&|Srrqrs�rxr`rrlr8rrrz]s�zTextDoc.docclass.<locals>.spillcsJt||�\}}|rF����|�|D]\}}}}���||���q&|Srr{rsr|rrr}nsz*TextDoc.docclass.<locals>.spilldescriptorsc
	s�t||�\}}|r�����|�|D]\\}}}}t|�}zt�|�}	Wntyd|j|}	Yn0��j|	|�d|d�d�q&|S)Nr�)r[r;rI)rprmrHr!r6�__dict__r�)
rtr�rnrur$r�rvrkr;r7r�rrr~ws�z#TextDoc.docclass.<locals>.spilldatacs,g|]$\}}}}t|�d�r||||f�qSrr�r�rrrr��s
�z$TextDoc.docclass.<locals>.<listcomp>rcs|d�uSr�rrTr�rrr��r�z"TextDoc.docclass.<locals>.<lambda>r�r�zMethods %s:
cSs|ddkSr�rrTrrrr��r�zClass methods %s:
cSs|ddkSr�rrTrrrr��r�zStatic methods %s:
cSs|ddkSr�rrTrrrr��r�zReadonly properties %s:
cSs|ddkSr�rrTrrrr��r�zData descriptors %s:
cSs|ddkSr�rrTrrrr��r�zData and other attributes %s:
cSs|ddkSr�rrTrrrr��r�z |  )r)rdrr��maprNr
rr�r�rAr@rHrr�rM�sortedr?�__subclasses__r�r�r�rpr�rrRr�r�rF)r8rr$r`rar�rLr�rrMrr�r�r;r�r:Z
subclassesZno_of_subclassesZMAX_SUBCLASSES_TO_DISPLAYZsubclassnamerorzr}r~r�r�r�r)rxr`rrlr8r�rr�s�

�

��	
�

�

�
�
�
�
�
�
zTextDoc.docclasscCsd|�|�Sr�r�rrrrr��szTextDoc.formatvaluec	Cs�|j}|p|}d}d}t|�rn|jj}|rB||urndt||�}n,|jdur`dt|jj|�}ndt||�}t�|�s�t�|�r�d}	nd}	||kr�|�|�}
n,|r�t�	||g�|ur�d}|�|�d	|}
d}t�
|��r:zt�|�}Wntt
f�yd}Yn0|�r:t|�}|d
k�r:|�|�d}
|dd�}|�sDd
}|	|
||}
|�rb|
dSt|��pnd}|
d|�o�|�|���dSdS)z;Produce text documentation for a function or method object.rCrr�Nr�r�r�rJ� = r�z lambda rr�rI)r)rar*r+rRrr�r�r�r�rTr�r�rAr@rHr�rF)r8rr$r`rhr�r�r�r�r�rr�r�r�r;rrrr��sT
�
�

zTextDoc.docroutinecCsTg}|j}|r$||�|��|d�t|�p.d}|rJ||�|��|d�d�|�S)z1Produce text documentation for a data descriptor.rIrC)r
r�rHr�rNr�rrrr��szTextDoc.docdatac
Cs�|�|�}|rF|r|dpd|}|t|�}	|	dkrF|d|	�d}|rX|�|�dpZd|}|slt|�}|r�|d|�t|��d7}|S)z-Produce text documentation for a data object.r�rCrNrYrI)r�rMr�rHr�r@)
r8rr$r`rIr[r;r�r�Zchoprrrr��s
zTextDoc.docother)r�)NrC)NN)NN)NNN)NNN)NNNNN)r)rrr=r�r�r�r�r�r rGr�r�r�r�r�r�r�rrrrr��s


e

7
r�c@seZdZdZdd�ZdS)�
_PlainTextDocz2Subclass of TextDoc which overrides string stylingcCs|Srrrrrrr�
sz_PlainTextDoc.boldN)r)rrr=r�rrrrr�sr�cCst�at|�dS)zCThe first time this is called, determine what kind of pager to use.N)�getpager�pagerr^rrrr�sr�c	sZttjd�stSttjd�s tStj��r4tj��s8tStj�d�pNtj�d���r�tj	dkrj�fdd�Stj�d�dvr��fd	d�S�fd
d�Stj�d�dvr�tStj	dkr�dd�Sttd�r�t�
d
�dkr�dd�Sddl}|��\}}t�
|�zRttd��r,t�
d|�dk�r,dd�Wt�|�StWt�|�SWt�|�nt�|�0dS)z2Decide what method to use for paging through text.�isattyZMANPAGERZPAGER�win32cstt|���Sr��
tempfilepager�plainr^�Z	use_pagerrrr�#r�zgetpager.<locals>.<lambda>ZTERM)ZdumbZemacscstt|���Sr)�	pipepagerr�r^r�rrr�%r�cs
t|��Sr�r�r^r�rrr�'r�cSstt|�d�S)Nzmore <r�r^rrrr�+r��systemz(less) 2>/dev/nullrcSs
t|d�S)NZlessr�r^rrrr�-r�Nz	more "%s"cSs
t|d�S)NZmorer�r^rrrr�4r�)r�r�stdin�
plainpager�stdoutr�r	r�r�platformr��tempfileZmkstemp�close�unlink�ttypager)r��fdr�rr�rr�s>


 
�
�r�cCst�dd|�S)z%Remove boldface formatting from text.z.rC)rDrEr^rrrr�:sr�c	Cs�ddl}|j|d|jd�}zVtj|jdd��2}z|�|�WntyNYn0Wd�n1sd0YWnty�Yn0z|�	�Wq�Wq�ty�Yq�0q�dS)z3Page through text by feeding it to another program.rNT)�shellr��backslashreplace)�errors)
�
subprocess�Popen�PIPE�io�
TextIOWrapperr��write�KeyboardInterruptr��wait)rV�cmdr��proc�piperrrr�>s(r�c	Cs�ddl}|����}tj�|d�}t|ddtjdkr<t�d�ndd��}|�	|�Wd�n1sd0Yt�
|d|d	�Wd�n1s�0YdS)
z<Page through text by invoking a program on a temporary file.rNz	pydoc.out�wr�r�)r��encodingz "r6)r�ZTemporaryDirectoryr	rrNr�rr��device_encodingr�r�)rVr�r�Ztempdirr�r�rrrr�Us
��(r�cCs$ttjdd�pd}|�|d��|�S)Nr��utf-8r�)r!rr��encode�decode)rVr�rrr�_escape_stdoutasr�c
Cs�tt|���d�}z2ddl}tj��}|�|�}|�|�dd�}Wn&t	t
tjfyjd}dd�}Yn0�zDzt
tj�dd��}Wnty�d}Yn0|dkr�d	}|d}}tj�d�|d|��d�||d��r�tj�d
�tj��|�}	|	dv�rtj�d��q�n,|	d
v�rFtj�d||d�|d}q�|	dv�rj|||}|dk�rjd}tj�dd�||||��d�||}q�W|�r�|�||j|�n|�r�|�||j|�0dS)z%Page through text on a text terminal.rIrNcSstj�d�Srb)rr�r�rrrrr�nr�zttypager.<locals>.<lambda>cSstj��dd�dd�S)NrrJ)rr�r�rrrrr�qr�ZLINESrJ�z
-- more --)�q�Qz
          
)�
rI)�b�B�)r�r�r �ttyrr��filenoZ	tcgetattrZ	setcbreakr�r6r��UnsupportedOperationr<r	r�rr�r�r�rN�flushZ	tcsetattrZ	TCSAFLUSH)
rVrOrr��oldZgetchar�hr
ZincrKrrrr�fsN







&�r�cCstj�tt|���dS)z>Simply print unformatted text.  This is the ultimate fallback.N)rr�r�r�r�r^rrrr��sr�cCs�t�|�r>|jtjvr 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 rwzpackage zmodule zbuilt-in function zgetset descriptor %s.%s.%szmember descriptor %s.%s.%sr�z	function zmethod )rrSr)rr�r�r-Zisgetsetdescriptorr1rr2rr,r(r?)�thingrrr�describe�s2







�
�




r	c	Cs�dd�|�d�D�}d\}}|t|�kr\td�|d|d��|�}|r\||d}}qq\q|rf|}nt}||d�D]*}zt||�}Wqvty�YdS0qv|S)z@Locate an object by name or dotted path, importing as necessary.cSsg|]}|r|�qSrr)r�r�rrrr��r�zlocate.<locals>.<listcomp>rr�NrJ)r rMr�rNr�r!r6)rr�rbr��nZ
nextmodulerr�rrr�locate�srcCsVt|t�r0t||�}|dur(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))rr@rr�r!)rr�rr$rrr�resolve�s

�r� Python Library Documentation: %scCs�|durt}t||�\}}t|�}t�|�}|rTd|vrT|d|d|�d��7}n|rn||urn|d|j7}t�|�s�t|�s�t�	|�s�t�
|�s�t|�s�t|d�r�|j
}nt|�}|d7}||d|�||�S)zBRender text documentation, given an object or a path to an object.Nrz in z in module �
__origin__z objectr")rVrr	rr\�rfindr)rSrrTr0rBr�rr?r�)rrr�Zrendererrr$r�r�rrr�
render_doc�s.

����
rc
Cshz2|durtt|||��n|�t|||t��Wn0ttfyb}zt|�WYd}~n
d}~00dS)zCDisplay text documentation, given an object or a path to an object.N)r�rr��	plaintextr�r��print)rrr��outputrkrrrr;�sr;c
Cs�ztt||�\}}t�t|�t�||��}t|dddd��}|�|�Wd�n1sZ0Ytd|d�Wn0tt	fy�}zt|�WYd}~n
d}~00dS)z<Write HTML documentation to a file in the current directory.r�r�r�)r�NZwrote)
r�htmlrr	r�r�r�rr�r�)rr�rr$rr�rkrrr�writedoc�s(rrCcCs2|duri}t�|g|�D]\}}}t|�qdS)zAWrite out HTML documentation for all modules in a directory tree.N)r]�
walk_packagesr)r�pkgpathZdonergrQrhrrr�	writedocs	s
rcJ@s.eZdZdddddddddddd	d
ddd
ddddddddddddddddddddd�$Zd d!�d"D�Zd#d$d%d&ge�Rd'd(d)d*d+d,d-�Zd.d/d0d1d2d3d4d5d6d7d8d9d9d:d:d;�Ze��D]:\ZZ	e	D],Z
e�e
e�Zeevr�ed<eZeee
<q�q�d=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)��HelperrC�BOOLEAN�with)�assertrC)�asyncrC)�awaitrC)�break�	while for)�classzCLASSES SPECIALMETHODS)�continuer )ZfunctionrC)�del�BASICMETHODS�if)�elser �try)�forzbreak continue while�import)�globalznonlocal NAMESPACES)r%�
TRUTHVALUE)r)�MODULES)�in�SEQUENCEMETHODS�
COMPARISON)�lambdar�)�nonlocalzglobal NAMESPACES)�passrC)�raise�
EXCEPTIONS)�returnr�)r'r4)�whilezbreak continue if TRUTHVALUE)rz CONTEXTMANAGERS EXCEPTIONS yield)�yieldrC)$�False�None�True�__peg_parser__�and�asrrrrr!r"�defr#�elifr&�except�finallyr(�fromr*r%r)r-�isr0r1�not�orr2r3r5r'r6rr7cCsg|]}dD]}||�qqS)��'r6r)r��pr�rrrr�Er�zHelper.<listcomp>)r��fr
�urGz'''r6r�)�+r��*�**r�z//�%�<<�>>r�|�^�~rr�<=�>=�==�!=�<>)rrrTrUrVrWrX)r�rS)z+=z-=z*=z/=z%=z&=z|=z^=z<<=z>>=z**=z//=)rOrPrrQrRrS)�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)rNrM�,rrY�:�@r�r}r|�`r7rF�[�]r�)rzRSTRINGS UNICODE NUMBERS SEQUENCES MAPPINGS FUNCTIONS CLASSES MODULES FILES inspect)�stringsz4str UNICODE SEQUENCES STRINGMETHODS FORMATTING TYPES)zstring-methodszSTRINGS FORMATTING)Z
formatstringsr\)rjz: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-objectrC)zbltin-ellipsis-object�SLICINGS)ZspecialattrsrC)rz!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)Zobjectsrl)ZspecialnameszbBASICMETHODS ATTRIBUTEMETHODS CALLABLEMETHODS SEQUENCEMETHODS MAPPINGMETHODS NUMBERMETHODS CLASSES)Z
customizationzhash repr str SPECIALMETHODS)zattribute-accesszATTRIBUTES SPECIALMETHODS)zcallable-typeszCALLS SPECIALMETHODS)�sequence-typesz(SEQUENCES SEQUENCEMETHODS SPECIALMETHODS)rozMAPPINGS SPECIALMETHODS)z
numeric-typesz*NUMBERS AUGMENTEDASSIGNMENT SPECIALMETHODS)Z	execmodelz%NAMESPACES DYNAMICFEATURES EXCEPTIONS)Znamingz3global nonlocal ASSIGNMENT DELETION DYNAMICFEATURES)zdynamic-featuresrC�
NAMESPACES)r�ztry except finally raise)ZconversionsrC)Zidentifierszkeywords SPECIALIDENTIFIERS)z
id-classesrC)zatom-identifiersrC)z
atom-literalsz=STRINGS NUMBERS TUPLELITERALS LISTLITERALS DICTIONARYLITERALS�	SEQUENCES)Z	exprlistszTUPLES LITERALS)ztypesseq-mutable�LISTLITERALS)ZlistszLISTS LITERALS)Ztypesmapping�DICTIONARYLITERALS)r3zDICTIONARIES LITERALS)zattribute-referencesz(getattr hasattr setattr ATTRIBUTEMETHODS)Z
subscriptionsr.)Zslicingsr.)Zcallsrn)Zpowerrn)Zunaryrn)Zbinaryrn)Zshiftingrn)Zbitwisern)ZcomparisonszEXPRESSIONS BASICMETHODS)ZbooleanszEXPRESSIONS TRUTHVALUEr)Z
assignmentr^)Z	augassign�
NUMBERMETHODSr#r5)Zcompoundzfor while break continue)�truthz if while and or not BASICMETHODS)ZdebuggerZpdb)zcontext-managersr)Irlr[Z
STRINGMETHODSZ
FORMATTING�UNICODEZNUMBERSZINTEGERZFLOATr`rqZMAPPINGSr�ZMETHODSZCODEOBJECTSZTYPEOBJECTSZFRAMEOBJECTSZ
TRACEBACKSZNONErbZSPECIALATTRIBUTESr�r,ZPACKAGESrnr\Z
PRECEDENCEZOBJECTSZSPECIALMETHODSr$ZATTRIBUTEMETHODSZCALLABLEMETHODSr.ZMAPPINGMETHODSrtZ	EXECUTIONrpZDYNAMICFEATURESZSCOPINGZFRAMESr4ZCONVERSIONSZIDENTIFIERSZSPECIALIDENTIFIERSrcZLITERALSZTUPLESZ
TUPLELITERALSZLISTSrrrkrsZ
ATTRIBUTESZ
SUBSCRIPTSrmZCALLSrar]ZBINARYZSHIFTINGr_r/rZ	ASSERTIONZ
ASSIGNMENTr^ZDELETIONZ	RETURNINGZ	IMPORTINGZCONDITIONALZLOOPINGr+Z	DEBUGGINGZCONTEXTMANAGERSNcCs||_||_dSr)�_input�_output)r8�inputrrrrr��szHelper.__init__cCs|jp
tjSr)rwrr�rrrrry�szHelper.inputcCs|jp
tjSr)rxrr�rrrrr�sz
Helper.outputcCs2t��dddkr|�dSd|jj|jjfS)NrJrX�?rCz<%s.%s instance>)r�stackr+rrrrrr�__repr__�s�zHelper.__repr__cCs6||jur|�|�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�interactrr��r8Zrequestrrr�__call__�s

zHelper.__call__c	Cs�|j�d�z|�d�}|s Wq�Wnttfy<Yq�Yn0|��}t|�dkr�|d|dkrndvr�nn |d|dd�vr�|dd�}|��dvr�q�|d	kr�|��q|�	|�qdS)
NrIzhelp> rKrrrFrJ)r��quitr)
rr��getliner��EOFErrorrLrMr�r~rr�rrrr�s

,�
zHelper.interactcCs8|jtjurt|�S|j�|�|j��|j��SdS)z.Read one line, using input() when appropriate.N)ryrr�rr�rr�)r8�promptrrrr��s

zHelper.getlinecCs<t|�td�u�r|��}|dkr,|��n�|dkr>|��n�|dkrP|��n�|dkrb|��n�|dd�dkr�|�|��d�n�||jvr�|�|�nj|d	vr�t	t
|�d
�nR||jvr�|�|�n<||j
vr�|�|�n&|r�t	|d
|jd�nt	td
|jd�n$t|t��r|�nt	|d
|jd�|j�d�dS)
NrC�keywords�symbols�topicsr�zmodules rJ)r:r8r9zHelp on %s:)rrI)r?rL�listkeywords�listsymbols�
listtopics�listmodulesr r��
showsymbolr;�evalr��	showtopicr�rxr@rrrr�r�rrrr�s$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.%drK)rr�r(rr�rrrrr~s
�zHelper.intror��Pc	
Cs�tt|��}||}t|�|d|}t|�D]v}t|�D]\}|||}|t|�kr<|j�||�||dkr<|j�dd|dt||��q<|j�d�q0dS)NrJr�rI)r'r�rMr&rr�)	r8�items�columnsrZcolwr)�rowr*r�rrrr'%s&zHelper.listcCs |j�d�|�|j���dS)NzN
Here is a list of the Python keywords.  Enter any keyword to get more help.

)rr�r'r�rgrrrrr�2szHelper.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.

)rr�r'r�rgrrrrr�9szHelper.listsymbolscCs |j�d�|�|j���dS)NzN
Here is a list of available topics.  Enter any topic name to get more help.

)rr�r'r�rgrrrrr�AszHelper.listtopicscCs,zddl}Wn ty,|j�d�YdS0|j�||j�|��}|s`|j�dt|��dSt|�td�ur||�	||�S|\}}z|jj|}Wn(t
y�|j�dt|��YdS0|��d}|r�|p�dd|}|�r ddl}dd�
|���d}	|�|	d	�}
|d
d�
|
�7}t|�dS)Nr�t
Sorry, topic and keyword documentation is not available because the
module "pydoc_data.topics" could not be found.
zno documentation found for %s
rCrIr��Related help topics: rE�Hz
%s
)�pydoc_data.topicsr�rr�r�rr�r�r?r��KeyErrorrL�textwraprNr Zwrapr�)r8�topic�
more_xrefs�
pydoc_data�target�label�xrefsr;r�rVZwrapped_textrrrr�Hs4zHelper.showtopiccCs�zddl}Wnty YdS0|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)r�rCzcould not find topicrCr�)	r�r�r�rr�r�rr@�	_gettopic)r8r�r�r�r�r�r�r;rrrr�hs	
zHelper._gettopiccCs*|j|}|�d�\}}}|�||�dS)Nr�)r��	partitionr�)r8�symbolr�r�r}r�rrrr��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)N����	.__init__r�rrrJ)�find)rrQr�rrrr�callback�sz$Helper.listmodules.<locals>.callbackcs�d|d�dSrrr��r�rr�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".
)rr�r(�apropos�
ModuleScanner�runr'rg)r8rjrr�rr�rr��s
�
zHelper.listmodules)NN)r�r�)rC)rC)rC)!r)rrr�Z_strprefixesZ_symbols_inverser�r�r�Zsymbols_r�rr�r�r.ryrr|rr}r�rr�rr~r'r�r�r�r�r�r�r�rrrrrsD�(���W



	


 
rc@seZdZdZddd�ZdS)r�z7An interruptible scanner that searches module synopses.Nc	Cs|r|��}d|_i}tjD]p}|dkrd||<|durF|d|d�qt|�jpRd}|�d�d}|d|}|���|�dkr|d||�qtj	|d�D�]V\}	}}
|jr��q�|dur�|d|d�q�zt�
|	|�}Wnty�Yq�Yn0|j}t
|d	��rjz|�|�}
Wn&t�y6|�r.||�Yq�Yn0tt�|
���pJd}t
|d
��rd|�|�}nd}n^ztj�|�}Wn&t�y�|�r�||�Yq�Yn0|j�r�|j��dnd}t|dd�}|d|}|���|�dkr�||||�q�|�r|�dS)NF�__main__rJrCrIrr�r��
get_source�get_filenamer{)r�r�rr�r�r=r r�r]r�	_get_specr�r�r�r�rrr�r��StringIOr�r�r�r�r�r�r!)r8r�rjZ	completerr��seenrQr$r�rgrhr�r��sourcerr�rrrr��s^



zModuleScanner.run)NNN)r)rrr=r�rrrrr��sr�cCsXdd�}dd�}t���,t�d�t�j|||d�Wd�n1sJ0YdS)zAPrint all the one-line module summaries that contain a substring.cSs6|dd�dkr |dd�d}t||o.d|�dS�Nr�r�r�z- )r�rrQr�rrrr��szapropos.<locals>.callbackcSsdSrrr�rrrr��szapropos.<locals>.onerror�ignorer�N)�warnings�catch_warnings�filterwarningsr�r�)rjr�r�rrrr��s


r�cs�ddl�ddl�ddl�ddl�Gdd�d�jj��G�fdd�d�jj��G�����fdd�d�j�}||||�}|��|j	s�|j
s�t�d	�q~|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.css�text/css�	text/html��zContent-Typez%s; charset=UTF-8r�N)	rr�Z
send_responseZsend_headerZend_headersZwfiler��
urlhandlerr�)r8�content_typerrr�do_GET0	s

��z(_start_server.<locals>.DocHandler.do_GETcWsdSrr)r8r�rrr�log_message@	sz-_start_server.<locals>.DocHandler.log_messageN)r)rrr�r�rrrr�
DocHandler.	sr�cs(eZdZdd�Z�fdd�Zdd�ZdS)z _start_server.<locals>.DocServercSs6||_|j|f|_||_|j�||j|j�d|_dS�NF)�hostZaddressr�r:r��handlerr�)r8r��portr�rrrr�F	s
z)_start_server.<locals>.DocServer.__init__cs>|js2��|j��gggd�\}}}|r|��q|��dSrb)r��selectZsocketrZhandle_requestZserver_close)r8ZrdZwrZex�r�rr�serve_until_quitM	s

z1_start_server.<locals>.DocServer.serve_until_quitcSs |j�|�|jr|�|�dSr)r:�server_activater�rrrrr�T	sz0_start_server.<locals>.DocServer.server_activateN)r)rrr�r�r�rr�rr�	DocServerD	sr�cs:eZdZ�fdd�Z����fdd�Zdd�Zdd�Zd	S)
z#_start_server.<locals>.ServerThreadcs2||_||_t|�|_�j�|�d|_d|_dSr�)r�r�r<r��Threadr��serving�error)r8r�r�r�)�	threadingrrr�[	s
z,_start_server.<locals>.ServerThread.__init__c
szzJ�jj�_��_�jj�_t|j��_�|j	|j
|j�}||_|�
�Wn*tyt}z||_WYd}~n
d}~00dS)zStart the server.N)�server�
HTTPServerr:r�r�ZMessageZMessageClass�staticmethodr�r�r��ready�	docserverr�rrr�)r8Zdocsvr�e)r�r��email�httprrr�c	s

z'_start_server.<locals>.ServerThread.runcSs,d|_|j|_|j|_d|j|jf|_dS)NTz
http://%s:%d/)r�r�Zserver_portr�r3)r8r�rrrr�p	sz)_start_server.<locals>.ServerThread.readycSs&d|j_|��d|_d|_d|_dS)z&Stop the server and this thread nicelyTNF)r�r�rNr�r3rrrr�stopv	s
z(_start_server.<locals>.ServerThread.stopN)r)rrr�r�r�r�r)r�r�r�r�r�rr�ServerThreadY	s
r�g{�G�z�?)
Zhttp.serverZ
email.messager�r�r�ZBaseHTTPRequestHandlerr�r�rBr�r��time�sleep)r��hostnamer�r��threadr)r�r�r�r�r�r�r�
_start_server�s8'r�r�cs6G�fdd�dt�}|���fdd���fdd���fdd���fd	d
���fdd���fd
d���fdd���fdd����������fdd�}|�d�r�|dd�}|dk�rtj�tj�t��}tj�||�}t|��}d�|�	��Wd�S1�s0Yn|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)rzpydoc_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)r8rr�css_pathZcss_link��html_navbarrrr�	s���z#_url_handler.<locals>._HTMLDoc.pageN)r)rrrrr�rr�_HTMLDoc�	sr�cs>��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)rr�Zpython_versionZpython_buildZpython_compiler)rd�rrrr��	s
��z!_url_handler.<locals>.html_navbarcs�dd�}��ddd�}dd�tjD�}��||�}|d��d	dd
|�g}i}tjD]}|���||��qT|�d�dd
�|�fS)zModule Index page.cSsd||fS�Nr0r�r$rrr�	bltinlink�	sz3_url_handler.<locals>.html_index.<locals>.bltinlinkz7<big><big><strong>Index of Modules</strong></big></big>rRrScSsg|]}|dkr|�qS)r�r)r�r$rrrr��	s�z4_url_handler.<locals>.html_index.<locals>.<listcomp>z<p>zBuilt-in ModulesrWz|<p align=right><font color="#909090" face="helvetica,arial"><strong>pydoc</strong> by Ka-Ping Yee&lt;ping@lfw.org&gt;</font>zIndex of ModulesrC)	rrr�r+r!rr
r�rN)r�r�namesrr�rr�rr�
html_index�	s"��
�z _url_handler.<locals>.html_indexc		s�g��fdd�}t���4t�d�dd�}t�j|||d�Wd�n1sR0Ydd	�}g}��d
dd�}�D]\}}|�||�|�qz|��d
|ddd�|��}d|fS)zSearch results page.cs:|dd�dkr |dd�d}��||o0d|f�dSr�rlr��Z
search_resultrrr��	sz3_url_handler.<locals>.html_search.<locals>.callbackr�cSsdSrrr�rrrr��	sz2_url_handler.<locals>.html_search.<locals>.onerrorr�NcSsd||fSr�rr�rrrr��	sz4_url_handler.<locals>.html_search.<locals>.bltinlinkz5<big><big><strong>Search Results</strong></big></big>rRrSzkey = %srW�<br>zSearch Results)	r�r�r�r�r�rr
r!rN)	rjr�r�r�r�rr$r�rr�r�r�html_search�	s$

0��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>rr�rrrr��	sz4_url_handler.<locals>.html_topics.<locals>.bltinlink�,<big><big><strong>INDEX</strong></big></big>rRrSZTopicsrW)rr�rr�rgr+r!)r�rr�rr�rr�html_topics�	s��z!_url_handler.<locals>.html_topicscsL��ddd�}ttj���}dd�}��||�}|��ddd|�}d|fS)zIndex of keywords.r�rRrScSsd||fSr�rr�rrrr�
sz6_url_handler.<locals>.html_keywords.<locals>.bltinlinkZKeywordsrW)rr�rr�rgr+r!)rr�r�rr�rr�
html_keywords
s��z#_url_handler.<locals>.html_keywordscs�t��}t||�}|�|�\}}||jvr0d}nd}��d|dd�}d��|�}��|dd|�}|r�t|�	��}dd	�}��
||�}��d
dd|�}d||fd�|||f�fS)
zTopic or keyword help page.ZKEYWORDZTOPICrNrRrSz
<pre>%s</pre>rWcSsd||fSr�rr�rrrr�&
sz7_url_handler.<locals>.html_topicpage.<locals>.bltinlinkr�z%s %srC)
r�r�rr�r�rrDr!r�r r+r rN)r�ZbufZhtmlhelprr�rrr�r�rr�html_topicpage
s,

��
�z$_url_handler.<locals>.html_topicpagecs@t|dd�}|dur$|dkr$td��t|�}��||�}||fS)NrJ)r�r9zcould not find object)rr�r	r�)r3r7r�contentr�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>rRrSr�c3s|]}��|�VqdSr)rr�r�rrr�;
r�z3_url_handler.<locals>.html_error.<locals>.<genexpr>z#bb0000z
Error - %s)rrNrr?r!)r3r�rrr�rr�
html_error7
s���z _url_handler.<locals>.html_errorc
sp|}|�d�r|dd�}�z|dvr2��\}}n�|dkrF��\}}n�|dkrZ��\}}n�d|v�r |�d�\}}}|dkr��|�\}}n�|d	kr�z�|�\}}Wnty��|�\}}Yn0nZ|d
k�r|dvr��\}}n2z�|�\}}Wn t�y�|�\}}Yn0ntd��n�|�\}}Wn4t�yb}z�||�\}}WYd}~n
d}~00��||�S)zGenerate an HTML page for url.r�N���)rCr�r�r�r�z
search?keyz	topic?keyzget?keyz
bad pydoc url)r�r�r�rrr)r3Zcomplete_urlrr��opr}r�)rr�r�r�r�r�r�r�rr�
get_html_pageA
s>



$z#_url_handler.<locals>.get_html_pager�rJNr�rCr�z"unknown content type %r for url %s)rrr	r�dirname�realpathr{rNr��	readlinesrA)r3r�r�r�Z	path_herer��fpr)	rr�r�r�r�r�r�r�r�r�_url_handler�	s*	
(


0
r�T�	localhost)�open_browserr�c	Cs�ddl}tt||�}|jr(t|j�dS|jr�d}|rB|�|j�z�zZtd|j�t|�|jr�td�}|�	�}|dkr|q�qZ|dkr�|�|j�qZt|�qZWnt
tfy�t�Yn0W|jr�|��td�n|jr�|��td�0dS)	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)
�
webbrowserr�r�r�rr�r�r3ryr�r�r�r�)r�r�r�r�ZserverthreadZserver_help_msgr�rrr�browsev
s8

�r�cCst|t�o|�tj�dkSr�)rr@r�r	�sep)rorrr�ispath�
srcCsvd|vstj|vst��|vr"dStj�t�}tj�|�}|��}||vrbtj�||�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.
    rCNr)
r	�curdir�getcwdrr�r{�copy�samefile�remove�insert)Z
given_pathZargv0Z
stdlib_dirZ
script_dir�revised_pathrrr�_get_revised_path�
s

r	cCs,ttjtjd�}|dur(|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)rrrr�_adjust_cli_sys_path�
srcCs�ddl}Gdd�dt�}t��zx|�tjdd�d�\}}d}d}d}d}d}|D]\\}	}
|	d	krld
}d
}|	dkr�t|
�WdS|	dkr�d
}|
}|	d
kr�d
}|	dkrTd
}|
}qT|r�t|||d�WdS|s�|�|D]�}t|��rtj	�
|��std|��q�z`t|��r&tj	�|��r&t
|�}|�rXt|��rNtj	�|��rNt|�nt|�n
t�|�Wq�t�y�}zt|�WYd}~q�d}~00q�WnL|j|f�y�tj	�tj	�tjd��d}
tdj|
tjd��Yn0dS)z@Command-line interface (looks at sys.argv to decide what to do).rNc@seZdZdS)zcli.<locals>.BadUsageN)r)rrrrrr�BadUsage�
r�rrJzbk:n:p:wFr�z-bTz-kz-pz-wz-n)r�r�zfile %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)�getoptrrrrr
r�r�rr	r�existsrr�r�rrrrr�r�r�r�r(r)r
rZoptsr�ZwritingZstart_serverr�r�r��opt�val�argrkr�rrr�cli�
s`

$�rr�)NN)r)r)r
rN)r
rN)r)rCN)r�)r)`r=rXryrqrur�Zimportlib._bootstrapr�Zimportlib._bootstrap_external�importlib.machinery�importlib.utilrr�r	r]r�rDrr�r�r�rZurllib.parserYr��collectionsr�reprlibr�	tracebackrrrr%r<r5rBrHrPrRrUrWr\r8�
IGNORECASEr]r_rarfrpr�r�r�r�r�r�rrr�r�r�r�r�rr�r�r�r�r�r�r�r�r�r�r�r	rrVrrrrr;rrrrr�r�r�r�r�rr	rrr)rrrr�<module>s�&

3	


'
0:*; ",

�
�


=
n%
U