ok

Mini Shell

Direktori : /opt/alt/python36/lib64/python3.6/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/__pycache__/pydoc.cpython-36.pyc

3

)j�aM��@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�dirZnormdir�r�*/opt/alt/python36/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�getdocZgetcomments�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�	isroutineZisframeZistracebackZiscode)rrrr�isdatamsr-cGs2x,|r,|dj|j|d��}|dd�}qW|S)z/Do a series of global replacements on a string.rrrN)r!r)�textZpairsrrr�replacessr/cCsXt|�|krTtd|dd�}td|d|�}|d|�d|t|�|d�S|S)zCOmit part of a string if needed to make it fit in a maximum length.r�rNz...)r �max)r.�maxlenZpreZpostrrr�cramzs
$r3z at 0x[0-9a-f]{6,16}(>+)$cCstjd|�S)z>Remove the hexadecimal id from a Python object representation.z\1)�_re_stripidr)r.rrr�stripid�sr5cCs(tj|�p&tj|�p&tj|�p&tj|�S)N)r�
isfunction�ismethod�	isbuiltinZismethoddescriptor)�objrrr�_is_some_method�s


r:cCs<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)rr7r8�getattrr*)�fn�selfrrr�_is_bound_method�s

r?cCshi}x tj|t�D]\}}d||<qWx|jD]}|jt|��q.Wx|j�D]}t||�||<qNW|S)Nr)r�
getmembersr:�	__bases__�update�
allmethods�keysr<)�cl�methods�key�value�baserrrrC�srCcCs<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
rOcCs\|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>rXrZr%rWrVrSrPrYrTr]rUr&rQr\rRr[)�
startswith�endswith�hasattr)r(�allr9rrr�visiblename�srecCsDg}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�clsrHrrrrf�s
rfcs\t|dg��y�fdd�t��D��Wntk
r>i�YnX�fdd�}|j|d�dS)zGSort the attrs list in-place by _fields and then alphabetically by namer`csi|]\}}|t��|�qSr)r )�.0�ir()�fieldsrr�
<dictcomp>�sz#sort_attributes.<locals>.<dictcomp>cs�j|dd�|dfS)Nr)�get)�attr)�field_orderrr�<lambda>�sz!sort_attributes.<locals>.<lambda>)rGN)r<�	enumerate�	TypeError�sort)�attrsrZkeyfuncr)rqrmr�sort_attributes�s
rwcCs<tjj|�r8x*dD]"}tjjtjj|d|��rdSqWdS)z3Guess whether a path refers to a package directory.�.py�.pyc�__init__TF)rxry)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"""r0z"""�\r���r�)�readlinerr)�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_mtimerorb�tuple�	importlib�	machinery�BYTECODE_SUFFIXES�SourcelessFileLoader�EXTENSION_SUFFIXES�ExtensionFileLoader�tokenize�open�OSErrorr��util�spec_from_file_location�
_bootstrap�_loadr�modulesrU�
splitlines)
�filename�cache�mtimeZ
lastupdaterZ
loader_clsr�r��spec�modulerrr�synopsis�s4



r�c@s eZdZdZdd�Zdd�ZdS)�ErrorDuringImportzEErrors that occurred while trying to import something to document it.cCs||_|\|_|_|_dS)N)r��excrH�tb)r>r��exc_inforrrrz#szErrorDuringImport.__init__cCs|jj}d|j||jfS)Nzproblem in %s - %s: %s)r�r%r�rH)r>r�rrr�__str__'szErrorDuringImport.__str__N)r%r&r[rUrzr�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)ra)rk�m)rrr�
<listcomp>Qszsafeimport.<locals>.<listcomp>Nrr)rr��builtin_module_names�
__import__r�r�rV�SyntaxErrorr��
issubclass�ImportErrorr(rr<�AttributeError)r�	forceloadr�ZsubsrGr�r�rHr��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)r>rr(�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%rt)r>rr(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�
getabsfilertr	�environror�rrr�r�r%rar!r�lower)r>rZbasedirr��doclocrrr�	getdocloc�s$



z
Doc.getdocloc)N)N)r%r&r[r	r�ror�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)rrz�maxlist�maxtuple�maxdict�	maxstring�maxother)r>rrrrz�s
zHTMLRepr.__init__cCst|dddddd�S)N�&z&amp;�<z&lt;�>z&gt;)r/)r>r.rrr�escape�szHTMLRepr.escapecCstj||�S)N)rr�)r>rrrrr��sz
HTMLRepr.reprcCsZtt|�d�r@ddjt|�jj��}t||�r@t||�||�S|jttt	|��|j
��S)Nr%�repr_r_)rcr�r!r%rr<r�r3r5r�r�)r>rN�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>)r3r�r�r/r�rr)r>rNr��test�testreprrrr�repr_string�szHTMLRepr.repr_stringcCs8y|jttt|��|j��S|jd|jj�SdS)Nz
<%s instance>)r�r3r5r�r��	__class__r%)r>rNr�rrr�
repr_instance�szHTMLRepr.repr_instanceN)r%r&r[rUrzr�r�r�r��repr_strr�Zrepr_unicoderrrrr��sr�c@seZdZdZe�ZejZejZdd�Zd5dd�Z	d6d
d�Z
dd
�Zdd�Zd7dd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdiiifdd �Zd8d!d"�Zd9d#d$�Zddiifd%d&�Zd'd(�Zddiiidfd)d*�Zd+d,�Zd:d-d.�Zd;d/d0�Zd<d1d2�Zd=d3d4�ZdS)>�HTMLDocz'Formatter class for HTML documentation.cCsd||fS)zFormat an HTML page.z�<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: %s</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body bgcolor="#f0f0f8">
%s
</body></html>r)r>�title�contentsrrr�page�szHTMLDoc.pagercCsd|||||pdfS)zFormat a page heading.a'
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="%s">
<td valign=bottom>&nbsp;<br>
<font color="%s" face="helvetica, arial">&nbsp;<br>%s</font></td
><td align=right valign=bottom
><font color="%s" face="helvetica, arial">%s</font></td></tr></table>
    z&nbsp;r)r>r��fgcol�bgcolZextrasrrr�heading�s	zHTMLDoc.heading�N�&nbsp;c	
Cs^|dkrdd|d}d|||f}	|r@|	d||||f}	n|	d|||f}	|	d|S)	z Format a section with a heading.Nz<tt>z&nbsp;z</tt>z�<p>
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="%s">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="%s" face="helvetica, arial">%s</font></td></tr>
    zR
<tr bgcolor="%s"><td rowspan=2>%s</td>
<td colspan=2>%s</td></tr>
<tr><td>%s</td>z(
<tr><td bgcolor="%s">%s</td><td>%s</td>z'
<td width="100%%">%s</td></tr></table>r)
r>r�r�r�r��widthZpreludeZ
marginaliaZgaprrrr�section�szHTMLDoc.sectioncGsd|}|j|f|��S)z$Format a section with a big heading.z<big><strong>%s</strong></big>)r)r>r�r�rrr�
bigsection	szHTMLDoc.bigsectionc
Cs&|j|j��}t|dddddddd�	S)z!Format literal preformatted text.z

z
 
r�z&nbsp;rz<br>
)r��
expandtabsr/)r>r.rrr�	preformatszHTMLDoc.preformatrcCs�d}t|�|d|}xht|�D]\}|dd|}x>t|||||�D]$}|t|�krN||||�d}qNW|d}q"Wd|S)z0Format a list of items into a multi-column list.rrz<td width="%d%%" valign=top>r�z<br>
z</td>z7<table width="100%%" summary="list"><tr>%s</tr></table>)r �range)r>�list�formatZcolsr�rows�colrlrrr�multicolumnszHTMLDoc.multicolumncCsd|S)Nz<font color="#909090">%s</font>r)r>r.rrr�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)r>r(Zdicts�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�ror&rcr<r))r>rr'r(r�rrr�	classlink)s
zHTMLDoc.classlinkcCsd|j|jfS)zMake a link for a module.z<a href="%s.html">%s</a>)r%)r>rrrr�
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)r>Z
modpkginfor(rr}�shadowed�urlr.rrr�
modpkglink5s

zHTMLDoc.modpkglinkcCsd||fS)zMake a link to source file.z<a href="file:%s">%s</a>r)r>rrrrr�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
�groupsr/�intrr!)r>r.r��funcs�classesrFrh�here�pattern�match�start�endrd�schemeZrfcZpepZselfdotr(rrrr�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">rz, �)z
</font></dt>z
<dd>
%s</dd>
z
<dl>
%s</dl>
)r�rr
r!�
formattree)
r>�treer'�parentr�entry�c�bases�parentsrIrrrr(ss 


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)r]��$z
Revision: z
version %srTz (%s)z, z-<br><a href="%(docloc)s">Module Reference</a>rz#ffffffz#7799eez<a href=".">index</a><br>r~z.html#z#-z<tt>%s</tt>z
<p>%s</p>
rZrzPackage Contentsz#aa55cccs�j|d�S)Nr)r)�t)r>rrrr�sz#HTMLDoc.docmodule.<locals>.<lambda>�ModulescSsg|]\}}|�qSrr)rkrGrHrrrr��sz%HTMLDoc.docmodule.<locals>.<listcomp>ZClassesz#ee77aar�Z	Functionsz#eeaa77ZDataz#55aa55z<br>
rPZAuthorrSZCreditsr�z$Revision: r�r�)6r%�__all__r�rrr r
r!rr��urllib�parseZquoterrtrc�strr]rr�rTr��localsrr@r*r+�	getmodulererAr&rr�ror<r,r8r6r-r&rr�pkgutil�iter_modulesrZrur
rrr(�getclasstreer�rPrS)#r>rr(�mod�ignoredrd�partsZlinksrlZ
linkedname�headrrrr��versionr�rr�rZcdictrGrHrIr'r�rZfdict�datar"�modpkgs�importer�ispkgr��	classlistr)r>rr��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)r>rrrrzsz1HTMLDoc.docclass.<locals>.HorizontalRule.__init__cs|jr�d�d|_dS)Nz<hr>
r)rF)r>)�pushrr�maybe
sz.HTMLDoc.docclass.<locals>.HorizontalRule.maybeN)r%r&r[rzrHr)rGrr�HorizontalRule
srIrz&<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)rOrHr<�	Exception�_docdescriptorr�)�msgrvrK�okr(ri�homeclsrH)rr�hr�mdictr<rrGr>rr�spillszHTMLDoc.docclass.<locals>.spillcsNt||�\}}|rJ�j��|�x&|D]\}}}}��j||���q(W|S)N)rOrHrK)rLrvrKrMr(rirNrH)rOr<rGr>rr�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)NrUz<dl><dt>%s</dl>
z<dd><tt>%s</tt>z<dl><dt>%s%s</dl>
r)
rOrHr�r<�callablerrgr&rr)
rLrvrKrMr(rirNrHrIr")rrrOrPr<rrGr>rr�	spilldata8s"
z#HTMLDoc.docclass.<locals>.spilldatacs,g|]$\}}}}t|�d�r||||f�qS))r9)re)rkr(rirjrH)rrrr�Ms
z$HTMLDoc.docclass.<locals>.<listcomp>r~�-rcs|d�kS)Nrr)r1)�	thisclassrrrrfsz"HTMLDoc.docclass.<locals>.<lambda>zdefined herezinherited from %sz:<br>
z
Methods %scSs|ddkS)Nr�methodr)r1rrrrrvszClass methods %scSs|ddkS)Nrzclass methodr)r1rrrrrxszStatic methods %scSs|ddkS)Nrz
static methodr)r1rrrrrzszData descriptors %scSs|ddkS)Nrzdata descriptorr)r1rrrrr|szData and other attributes %scSs|ddkS)NrrAr)r1rrrrr~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#ffc8d8r0)r%rAr
rr�getmror rHrr&rfr<rJrt�popleftrO�builtinsrrw�AssertionErrorr!r&rrr)r>rr(r<rrr=�realnamer-r�rI�mrorIrQrRrTrvrGrirNrH�anchor�	inherited�tagr�r.r"r)	rrrOrPr<rrGr>rVrr��s�

	



















zHTMLDoc.docclasscCs|jd|j|��S)z)Format an argument default value as text.�=)rr�)r>rrrr�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.rrUrz 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%r?r;r�rr�getattr_staticr,�	signature�
ValueErrorrtr6r�rr&rr)r>rr(r<rrrFrEr\r^�note�skipdocs�imclassr�Zreallink�argspecrd�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
rUr&rrr!)r>r(rHr<rhrGr"rrrrK�s
zHTMLDoc._docdescriptorcCs|j|||�S)z*Produce html documentation for a property.)rK)r>rr(r<rErrrr��szHTMLDoc.docpropertycGs|rd|pd}||j|�S)z-Produce HTML documentation for a data object.z<strong>%s</strong> = r)r�)r>rr(r<r=Zlhsrrrr��szHTMLDoc.docothercCs|j|||�S)z1Produce html documentation for a data descriptor.)rK)r>rr(r<rErrrr��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)rk�chrrr�	<genexpr>�sz HTMLDoc.index.<locals>.<genexpr>rrz#ffffffz#ee77aa)r9r:�anyr
rur
rr)r>rrrBrCr(rDr�rrr�index�sz
HTMLDoc.index)r)rrNr)r)N)NN)NNN)NN)NNN)N)r%r&r[rUr��_repr_instancer�r�r�rrrrr
rrrrrrr&r(r�r�rbr�rKr�r�r�rorrrrr��s<



+

y:


r�c@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�)rrzr�r�r�r�r�)r>rrrrzs
zTextRepr.__init__cCsTtt|�d�r@ddjt|�jj��}t||�r@t||�||�Sttt|��|j	�S)Nr%r�r_)
rcr�r!r%rr<r3r5r�r�)r>rNr�r�rrrr�s

zTextRepr.repr1cCsHt||j�}t|�}d|krDdt|dd�krDd|d||dS|S)Nr�z\\rr�r)r3r�r�r/)r>rNr�r�r�rrrr�
s
zTextRepr.repr_stringc
Cs,yttt|��|j�Sd|jjSdS)Nz
<%s instance>)r3r5r�r�r�r%)r>rNr�rrrr�szTextRepr.repr_instanceN)	r%r&r[rUrzr�r�r�r�rrrrrq�s	rqc@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)rkrlrrrrm(szTextDoc.bold.<locals>.<genexpr>)r!)r>r.rrr�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)rkr�)�prefixrrr�-sz"TextDoc.indent.<locals>.<listcomp>rrr�r�)rrr!)r>r.rvr#r)rvr�indent*szTextDoc.indentcCs$|j|�j�}|j|�d|dS)z&Format a section with a given heading.rz

)rwrrt)r>r�r�Zclean_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))rkr,)r'rrrm@sz%TextDoc.formattree.<locals>.<genexpr>z(%s)z, rz    )r�r)r!r()
r>r)r'r*rvrr+r,r-r.r)r'rr(8s

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 - r3NzMODULE REFERENCEa.

The following documentation is automatically generated from the Python
source files.  It may be incomplete, incorrect or include features that
are considered implementation detail and may vary between Python
implementations.  When in doubt, consult the module reference at the
location listed above.
ZDESCRIPTIONrZz
 (package)zPACKAGE CONTENTSrrZ
SUBMODULEScSsg|]\}}|�qSrr)rkrGrHrrrr��sz%TextDoc.docmodule.<locals>.<listcomp>r�CLASSES�	FUNCTIONS�F)r2ZDATAr]r/r0z
Revision: �VERSIONrTZDATErPZAUTHORrSZCREDITSz
(built-in)ZFILEz$Revision: r�r�)%r%r$rrr<r�rr@r+r8rer
r,r8r-�setrcr9r:rZ�addrur!r*rar(r;r�r�r6r]rrTrPrSr�rt)r>rr(r<Zsynop�descrrdr�rrGrHrrArBZ
modpkgs_namesrCr'rDZ
submodulesrEr�r@r�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))r,r�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)rF)r>rrrrz�sz1TextDoc.docclass.<locals>.HorizontalRule.__init__cs|jr�dd�d|_dS)NrUr{r)rF)r>)rGrrrH�sz.TextDoc.docclass.<locals>.HorizontalRule.maybeN)r%r&r[rzrHr)rGrrrI�srIcs�t||�\}}|r��j��|�x^|D]V\}}}}yt�|�}Wn&tk
rh��j||���Yq(X��j||����q(W|S)N)rOrHr<rJrKr�)rLrvrKrMr(rirNrH)rOr<rrGr>rrrQ�szTextDoc.docclass.<locals>.spillcsNt||�\}}|rJ�j��|�x&|D]\}}}}��j||���q(W|S)N)rOrHrK)rLrvrKrMr(rirNrH)rOr<rGr>rrrR�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{)r2r"r)
rOrHrSrrgrr<r��__dict__r�)
rLrvrKrMr(rirNrHr"r9)rOr<rrGr>rrrT�s
z#TextDoc.docclass.<locals>.spilldatacs,g|]$\}}}}t|�d�r||||f�qS))r9)re)rkr(rirjrH)rrrr�s
z$TextDoc.docclass.<locals>.<listcomp>rcs|d�kS)Nrr)r1)rVrrrr	sz"TextDoc.docclass.<locals>.<lambda>zdefined herezinherited from %szMethods %s:
cSs|ddkS)NrrWr)r1rrrrrszClass methods %s:
cSs|ddkS)Nrzclass methodr)r1rrrrrszStatic methods %s:
cSs|ddkS)Nrz
static methodr)r1rrrrrszData descriptors %s:
cSs|ddkS)Nrzdata descriptorr)r1rrrrrszData and other attributes %s:
cSs|ddkS)NrrAr)r1rrrrr sz |  )r%rAr&rt�mapr!rr
rrrXr rfrYrOrZrr)rwr[rwr)r>rr(r<r=r\r-r�r�r.r"r�r]rIrIrQrRrTrvr_r`r)rOr<rrGr>rVrr��sn

	
















zTextDoc.docclasscCsd|j|�S)z)Format an argument default value as text.ra)r�)r>rrrrrb*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%r?r;r�r)rtrrcr,rdrertr6rrwr)r>rr(r<rEr\rfrgrhr�rirdrjr"rrrr�.sH


zTextDoc.docroutinecCsTg}|j}|r$||j|��|d�t|�p.d}|rJ||j|��|d�dj|�S)Nrr)r
rtrrwr!)r>r(rHr<rhrGr"rrrrK_szTextDoc._docdescriptorcCs|j|||�S)z*Produce text documentation for a property.)rK)r>rr(r<rErrrr�lszTextDoc.docpropertycCs|j|||�S)z1Produce text documentation for a data descriptor.)rK)r>rr(r<rErrrr�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 rtrwr6)
r>rr(r<r*r2r"r�r�Zchoprrrr�ts
zTextDoc.docother)ru)Nr)NN)NN)NNN)NNN)NNN)NNNNN)r%r&r[rUrqrpr�rtrwrr(r�r�rbr�rKr�r�r�rrrrrrs


e
}
1

rrc@seZdZdZdd�ZdS)�
_PlainTextDocz2Subclass of TextDoc which overrides string stylingcCs|S)Nr)r>r.rrrrt�sz_PlainTextDoc.boldN)r%r&r[rUrtrrrrr��sr�cCst�at|�dS)zCThe first time this is called, determine what kind of pager to use.N)�getpager�pager)r.rrrr��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.�isattyZMANPAGERZPAGERZwin32cstt|���S)N)�
tempfilepager�plain)r.)�	use_pagerrrrr�szgetpager.<locals>.<lambda>ZTERM�dumb�emacscstt|���S)N)�	pipepagerr�)r.)r�rrrr�scs
t|��S)N)r�)r.)r�rrrr�scSstt|�d�S)Nzmore <)r�r�)r.rrrrr�s�systemz(less) 2>/dev/nullrcSs
t|d�S)NZless)r�)r.rrrrr�sNz	more "%s"cSs
t|d�S)NZmore)r�)r.rrrrr�s)r�r�)r�r�)rcr�stdin�
plainpager�stdoutr�r	r�ro�platformr��tempfileZmkstemp�close�ttypager�unlink)r��fdr�r)r�rr��s6


 r�cCstjdd|�S)z%Remove boldface formatting from text.z.r)rr)r.rrrr��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)r.�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�Zmktempr�r�r	r�r�)r.r�r�r�r�rrrr��sr�cCs$ttjdd�pd}|j|d�j|�S)N�encodingzutf-8r�)r<rr��encode�decode)r.r�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�rrrrrr�szttypager.<locals>.<lambda>cSstjj�dd�dd�S)Nrr�)rr�r�rrrrrr�sZLINESr�z
-- more --�q�Qz
          
�
�b�B�)r�r�)r�r)r�r�r�)r�r�r�ttyrr��filenoZ	tcgetattrZ	setcbreakr�r�r��UnsupportedOperationrr	r�rorer�r�r!�flushZ	tcsetattrZ	TCSAFLUSH)
r.r#r�r��oldZgetchar�hr�Zincr,rrrr��sL








&r�cCstjjtt|���dS)z>Simply print unformatted text.  This is the ultimate fallback.N)rr�r�r�r�)r.rrrr�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 rZzpackage zmodule zbuilt-in function zgetset descriptor %s.%s.%szmember descriptor %s.%s.%szclass z	function zmethod )rr*r%rr�rcr8r��__objclass__r&r�r+r6r7r�)�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)rkr�rrrr�'szlocate.<locals>.<listcomp>rNrr)Nr)rr r�r!rZr<r�)rr�r>r��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�r6r�r�r<)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

)r.r�r�rr8�rfindr%r*r+r,r�r�r�r�r�r�)r�r�r�Zrendererrr(rr�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�r�r��outputrHrrrr"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��htmlr�r�r�r�r�r�r�r�)r�r�rr(r�r�rHrrr�writedocpsr�rcCs6|dkri}x$tj|g|�D]\}}}t|�qWdS)zAWrite out HTML documentation for all modules in a directory tree.N)r9�
walk_packagesr�)r�pkgpath�donerCr'rDrrr�	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�lambdarz�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�r�cCsg|]}dD]}||�qqS)�'r)r�rr)rk�pr�rrrr��szHelper.<listcomp>r��fr��ur��'''r�"""�+rU�*�**r��//�%�<<�>>r��|�^�~r�r��<=�>=�==�!=�<>�+=�-=�*=�/=�%=�&=�|=�^=�<<=�>>=�**=�//=�j�J)�STRINGS�	OPERATORSr��UNARY�AUGMENTEDASSIGNMENT�BITWISE�COMPLEXzOPERATORS FORMATTING�POWERzTUPLES LISTS FUNCTIONSz ATTRIBUTES FLOAT MODULES OBJECTS�ELLIPSISzSLICINGS DICTIONARYLITERALSz	def classr�PRIVATENAMESzPRIVATENAMES SPECIALMETHODSZ
BACKQUOTESzTUPLES FUNCTIONS CALLSzLISTS SUBSCRIPTS SLICINGS)rz**�,rz...�:�@r�r_r^�`rr'�[�]r��types�RSTRINGS UNICODE NUMBERS SEQUENCES MAPPINGS FUNCTIONS CLASSES MODULES FILES inspect�strings�4str UNICODE SEQUENCES STRINGMETHODS FORMATTING TYPES�string-methods�STRINGS FORMATTING�
formatstringsr�: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�
assignmentr �	augassign�
NUMBERMETHODS�compound�for while break continue�truth� if while and or not BASICMETHODS�debugger�pdb�context-managers)IrGrZ
STRINGMETHODSZ
FORMATTING�UNICODEZNUMBERSZINTEGERZFLOATr"rmZMAPPINGSrzZMETHODSZCODEOBJECTSZTYPEOBJECTSZFRAMEOBJECTSZ
TRACEBACKSZNONEr$ZSPECIALATTRIBUTESryr�ZPACKAGESrPrZ
PRECEDENCEZOBJECTSZSPECIALMETHODSr�ZATTRIBUTEMETHODSZCALLABLEMETHODSr�ZMAPPINGMETHODSr�Z	EXECUTIONrdZDYNAMICFEATURESZSCOPINGZFRAMESr�ZCONVERSIONSZIDENTIFIERSZSPECIALIDENTIFIERSr%ZLITERALSZTUPLESZ
TUPLELITERALSZLISTSrqr>ruZ
ATTRIBUTESZ
SUBSCRIPTSrJZCALLSr#rZBINARYZSHIFTINGr!r�r�Z	ASSERTIONZ
ASSIGNMENTr ZDELETIONZ	RETURNINGZ	IMPORTINGZCONDITIONALZLOOPINGr�Z	DEBUGGINGZCONTEXTMANAGERSNcCs||_||_dS)N)�_input�_output)r>�inputr�rrrrz/szHelper.__init__cCs|jp
tjS)N)r�rr�)r>rrrrr3szHelper.<lambda>cCs|jp
tjS)N)r�rr�)r>rrrrr4scCs2tj�dddkr|�dSd|jj|jjfS)Nrr0�?rz<%s.%s instance>)r�stackr�r&r[)r>rrr�__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�)r>�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> rrrr�rr��quitrr�)r�rr�r�)r�r�)
r�r��getliner��EOFErrorrr r�r�r)r>r�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�)r>�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 rr�r�r�zHelp on %s:)r�r)r�r�r�)r�r�listkeywords�listsymbols�
listtopics�listmodulesrr��
showsymbolr"�evalr��	showtopicr�r�r6r�r�r�r�)r>r�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�r
rr�)r>rrrr�~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�)	r>�items�columnsrZcolwr�rowrrlrrrr	�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�r	r�rD)r>rrrr��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�r	r�rD)r>rrrr��szHelper.listsymbolscCs |jjd�|j|jj��dS)NzN
Here is a list of available topics.  Enter any topic name to get more help.

)r�r�r	r�rD)r>rrrr��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�ror�r�r�r��KeyErrorr�textwrapr!rZwrapr�)r>�topic�
more_xrefs�
pydoc_data�target�label�xrefsr"r�r.Z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�ror�rer�r6�	_gettopic)r>r�r�r�r�r�r�r"rrrr��s	
zHelper._gettopiccCs*|j|}|jd�\}}}|j||�dS)Nr�)r��	partitionr�)r>�symbolr�r�r_r�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'rr�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�runr	rD)r>rGr�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�rz)r�r�)r�r)r�r�)r�rz)r�r�)r�r�)r�r�)r�r)r�r�r�r�)r�r�rr�)rrUrrr�rrrrr�rrr	r�r�r
rrr
r)r�r�r
rrr
r)rUr	)rrrrrrrrrrrr)rrr�rrr	)rr)r,r-)r.r/)r0r1)r2r)r.r3)r4r5)r6r7)r8r9)r:r;)r<r=)r?r@)rArB)rCrD)rErF)rHr)rIrJ)rKr)r,rL)rMr�)rNrO)rQrG)rRrS)rTrU)rVrW)rXrY)rZr[)rZr\)r]r^)r_r`)rarb)rcr)r�re)rfr)rgrh)rir)rjr)rkrl)rnro)rprq)rrrs)rtru)rrv)rwrx)ryr�)rzr�)r{rP)r|rP)r}rP)r~rP)rrP)r�rP)r�r�)r�r�)r�r )r�r�)r�r�)r�r�)r�r�)r�r�)NN)rr�)r)r)r)!r%r&r[r�Z_strprefixesZ_symbols_inverser�r�r�Zsymbols_r�ror�rzr�r�r�r�rr�r�r�r�rr�r	r�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_filenamerV)r�r�rr�r�rUrr�r9r��	_get_specr�r�rcr�rJr�r��StringIOr�r�r�r�r�r�r<)r>r�rGZ	completerr��seenr'r(rrCrDr�r��sourcerr�rrrr�s`zModuleScanner.run)NNN)r%r&r[rUr�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'rrrrr�Oszapropos.<locals>.callbackcSsdS)Nr)r'rrrr�Sszapropos.<locals>.onerror�ignore)r�N)�warnings�catch_warnings�filterwarningsr�r�)rGr�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)	rrbZ
send_responseZsend_headerZend_headersZwfiler��
urlhandlerr�)r>�content_typerrr�do_GET�s

z(_start_server.<locals>.DocHandler.do_GETcWsdS)Nr)r>r�rrr�log_message�sz-_start_server.<locals>.DocHandler.log_messageN)r%r&r[r�r�rrrr�
DocHandler�sr�cs(eZdZdd�Z�fdd�Zdd�ZdS)z _start_server.<locals>.DocServercSs6d|_|j|f|_||_|jj||j|j�d|_dS)NZ	localhostF)�hostZaddressr�rIrz�handlerr�)r>�portr�rrrrz�s
z)_start_server.<locals>.DocServer.__init__csBx4|js4�j|jj�gggd�\}}}|r|j�qW|j�dS)Nr)r��selectZsocketr�Zhandle_requestZserver_close)r>Zrd�wrZex)r�rr�serve_until_quit�s
z1_start_server.<locals>.DocServer.serve_until_quitcSs |jj|�|jr|j|�dS)N)rI�server_activater�)r>rrrr��sz0_start_server.<locals>.DocServer.server_activateN)r%r&r[rzr�r�r)r�rr�	DocServer�sr�cs:eZdZ�fdd�Z����fdd�Zdd�Zdd�Zd	S)
z#_start_server.<locals>.ServerThreadcs,||_t|�|_�jj|�d|_d|_dS)NF)r�rr��Threadrz�serving�error)r>r�r�)�	threadingrrrz�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�
HTTPServerrIr�r�ZMessageZMessageClass�staticmethodr�r��ready�	docserverr�rJr�)r>Zdocsvr�e)r�r��email�httprrr��s

z'_start_server.<locals>.ServerThread.runcSs,d|_|j|_|j|_d|j|jf|_dS)NTz
http://%s:%d/)r�r�Zserver_portr�r)r>r�rrrr��sz)_start_server.<locals>.ServerThread.readycSs&d|j_|j�d|_d|_d|_dS)z&Stop the server and this thread nicelyTNF)r�r�r!r�r)r>rrr�stop�s
z(_start_server.<locals>.ServerThread.stopN)r%r&r[rzr�r�r�r)r�r�r�r�r�rr�ServerThread�s
r�g{�G�z�?)
Zhttp.serverZ
email.messager�r�r�ZBaseHTTPRequestHandlerr�r�r#r�r��timeZsleep)r�r�r�Zthreadr)r�r�r�r�r�r�r�
_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)r>r�r��css_pathZcss_link)�html_navbarrrr��sz#_url_handler.<locals>._HTMLDoc.pageN)r%r&r[r�r)r�rr�_HTMLDoc�sr�cs>�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)Zterse)r�r�Zpython_versionZpython_buildZpython_compiler)r@)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)rkr(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)	rrr�r
rrr
ror!)r�r�namesr�r�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�rr
rr!)	rGr�r�r�rhrr(rr�)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)rr�r�r�rDr
r)r�rr�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)rr�r�r�rDr
r)rr�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�rr&rr�rr
rr!)r�ZbufZhtmlhelpr�r�r�rr�)r�rr�html_topicpage~	s&



z$_url_handler.<locals>.html_topicpagecs@t|dd�}|dkr$|dkr$td��t|�}�j||�}||fS)Nr)r�r�zcould not find object)r�rer�r�)rr9r��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�)rkr�)r�rrrm�	sz3_url_handler.<locals>.html_error.<locals>.<genexpr>z#bb0000z
Error - %s)rr!rr�r)rr�rr�)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�rror�r�raz
search?keyz	topic?keyzget?keyz
bad pydoc url���)rro)rro)rbr�rerJr�)rZcomplete_urlr�r��opr_r�)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)r�rar	r�dirname�realpathrVr!r��	readlinesrt)rr�r�r�Z	path_herer��fpr)	r�r�r�r�r�r�r�r�r�r�_url_handler�s*	
(


rT)�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)
�
webbrowserr�rr�r�r�r�rr�r�r�r�r�)r�rrZserverthreadZserver_help_msgr�rrr�browse�	s2

rcCst|t�o|jtj�dkS)Nr)r�r6r�r	�sep)rNrrr�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&r[rrrr�BadUsage

sr
rrrzbk:p:wFz-bTz-kz-pz-w)rzfile %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�r)�getoptrJrrr	r�argv�remove�insertr�rr	�existsr�r{r�rr�r�rr�r�r�r�r
r)rr
Z	scriptdirZoptsr�ZwritingZstart_serverrr�Zopt�val�argrHr�rrr�cli
sd




$rr�)NN)r)r)r�rN)r�rN)r)rN)r�)r)XrUr3rPrTrSrZZimportlib._bootstrapr�Zimportlib._bootstrap_external�importlib.machinery�importlib.utilrr�r	r9r�rrr�r�Zurllib.parser4r��collectionsr�reprlibr�	tracebackrrrr$r)r-r/r3r�
IGNORECASEr4r5r:r?rCrOrerfrwr}r�r�rJr�r�r�r�r�r�rqrrr�r�r�r�r�r�r�r�r�r�r�r.r�r�r�r�r"r�r�r�rr�r�r�rrr	rr%rrrr�<module>#s�		


	'
0>*- d",






=
n%V


Zerion Mini Shell 1.0