AlkantarClanX12

Your IP : 3.14.132.43


Current Path : /proc/self/root/opt/alt/python35/lib64/python3.5/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python35/lib64/python3.5/__pycache__/pydoc.cpython-35.opt-1.pyc



��Yf��@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+ddd#d$�Z,d%d&�Z-d'd(�Z.d)d*�Z/id+d,�Z0Gd-d.�d.e1�Z2d/d0�Z3did1d2�Z4Gd3d4�d4�Z5Gd5d6�d6e�Z6Gd7d8�d8e5�Z7Gd9d:�d:e�Z8Gd;d<�d<e5�Z9Gd=d>�d>e9�Z:d?d@�a;dAdB�Z<dCdD�Z=dEdF�Z>dGdH�Z?dIdJ�Z@dKdL�ZAdMdN�ZBdOdP�ZCddQdR�ZDe9�ZEe:�ZFe7�ZGddSdT�ZHdUdddVdW�ZIdUdddXdY�ZJddZd[�ZKd\dd]d^�ZLGd_d`�d`�ZMeM�ZNGdadb�db�ZOdcdd�ZPdedf�ZQdgdhdi�ZRddjdkdldm�ZSdndo�ZTdpdq�ZUeVdrkr6eU�dS)sa�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}xstjD]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/python35/lib64/python3.5/pydoc.py�pathdirsMs
rcCsCtj|�ptj|�}|r?tjdd|j��pBdS)z-Get the doc string or comments for an object.z^ *
�)�inspect�getdocZgetcomments�re�sub�rstrip)�object�resultrrrrYsrcCs�|j�jd�}t|�dkr5|ddfSt|�dkry|dj�ry|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�	classnamegs	r)cCsYtj|�pWtj|�pWtj|�pWtj|�pWtj|�pWtj|�S)z>Check if an object is of a type that probably means it's data.)r�ismodule�isclass�	isroutineZisframeZistracebackZiscode)rrrr�isdatansr-cGsAx:|r<|dj|j|d��}|dd�}qW|S)z/Do a series of global replacements on a string.rrrN)r!r)�textZpairsrrr�replacets	 r/cCsnt|�|krjtd|dd�}td|d|�}|d|�d|t|�|d�S|S)zCOmit part of a string if needed to make it fit in a maximum length.r�rNz...)r �max)r.�maxlenZpreZpostrrr�cram{s
*r3z at 0x[0-9a-f]{6,16}(>+)$cCstjd|�S)z>Remove the hexadecimal id from a Python object representation.z\1)�_re_stripidr)r.rrr�stripid�sr5cCs:tj|�p9tj|�p9tj|�p9tj|�S)N)r�
isfunction�ismethod�	isbuiltinZismethoddescriptor)�objrrr�_is_some_method�sr:cCsRtj|�rdStj|�rNt|dd�}tj|�pL|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?cCs�i}x*tj|t�D]\}}d||<qWx$|jD]}|jt|��q=Wx'|j�D]}t||�||<qgW|S)Nr)r�
getmembersr:�	__bases__�update�
allmethods�keysr<)�cl�methods�key�value�baserrrrC�srCcCsPg}g}x7|D]/}||�r5|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||dkrdS|jd�r2|jd�r2dS|jd�rTt|d�rTdS|dk	rj||kS|jd�SdS)z3Decide whether to show documentation on a variable.�
__author__�__builtins__�
__cached__�__credits__�__date__�__doc__�__file__�__spec__�
__loader__r&r%�__package__�__path__�__qualname__�	__slots__�__version__r�__r�_�_fieldsTN>r\rYrXrTrVrPrRrQr[r]rSr&rZrWrUr%)�
startswith�endswith�hasattr)r(�allr9rrr�visiblename�s	
recCs^g}xQtj|�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"rfcCsPtjj|�rLx7dD]/}tjjtjj|d|��rdSqWdS)z3Guess whether a path refers to a package directory.�.py�.pyc�__init__TF)rkrl)r	rr�isfiler!)r�extrrr�	ispackage�s

%rpcCs|j�}x:|dd�dks2|j�rH|j�}|sPqW|j�}|dd�dkr{|dd�}|dd�dkr	|dd�}|d	d�dkr�|dd
�}x#|j�s�|j�}|s�Pq�W|jd�dj�}nd}|S)Nr�#�zr"""r0z"""�\r���rt)�readlinerr)�file�linerrrr�source_synopsis�s&&rxc
Cs�tj|�j}|j|d�\}}|dksB||kr||jttjj��rltjj	}n0|jttjj
��r�tjj}nd}|dkr�ytj
|�}Wntk
r�dSYnX|�t|�}WdQRXn{|d|�}tjjd|d|�}ytjj|�}	WndSYnXtjd=|	jrf|	jj�dnd}||f||<|S)z.Get the one-line summary out of a module file.NZ__temp__�loaderr)NN)r	�stat�st_mtime�getrb�tuple�	importlib�	machinery�BYTECODE_SUFFIXES�SourcelessFileLoader�EXTENSION_SUFFIXES�ExtensionFileLoader�tokenize�open�OSErrorrx�util�spec_from_file_location�
_bootstrap�_loadr�modulesrU�
splitlines)
�filename�cache�mtimeZ
lastupdaterZ
loader_clsrvry�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_inforrrrms	zErrorDuringImport.__init__cCs#|jj}d|j||jfS)Nzproblem in %s - %s: %s)r�r%r�rH)r>r�rrr�__str__szErrorDuringImport.__str__N)r%r&r[rUrmr�rrrrr�sr�c
Cstjj}t|d��4}|jt|��}||tjjfk}WdQRXtjj	|�}tjj
|�\}}|r�tjj||�}ntjj
||�}tjj||d|�}	ytjj|	�SWnt|tj���YnXdS)z<Import a Python source file or compiled file given its path.�rbNry)r~r��MAGIC_NUMBERr��readr �_BACKCOMPAT_MAGIC_NUMBERr	r�basename�splitext�_bootstrap_externalr��SourceFileLoaderr�r�r�r�rr�)
r�magicrvZfirst_bytesZis_bytecoder�r(roryr�rrr�
importfile sr�cs{y�|rv�tjkrv�tjkrv�fdd�tjD�}x0�g|D]!}tj|||<tj|=qQWt��}Wn�tj�\}}}}	�tjkr�ttj�j|	��nU|tkr�t|j|	��n4|t	kr
|j
�kr
dSt�tj���YnXxM�jd�dd�D]2}
yt||
�}WqAt
k
rrdSYqAXqAW|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).cs)g|]}|j�d�r|�qS)r)ra)�.0�m)rrr�
<listcomp>Ks	zsafeimport.<locals>.<listcomp>Nrr)rr��builtin_module_names�
__import__r�r�rV�SyntaxErrorr��ImportErrorr(rr<�AttributeError)r�	forceloadr�ZsubsrGr�r�rHr��info�partr)rr�
safeimport7s. 

r�c@s�eZdZejjddejdd��Zddd�Z	ddd�Z
e
ZZZ
ZZZejjejd	d
ejdd��dd�ZdS)
�Doc�
PYTHONDOCSz%https://docs.python.org/%d.%d/libraryNrcGs�||f|}tj|�r,|j|�Stj|�rH|j|�SyXtj|�rg|j|�Stj|�r�|j|�Stj|�r�|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�documentms"





zDoc.documentcGs9d|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%�	TypeError)r>rr(r��messagerrr�fails&zDoc.fail�libzpython%d.%dcCsytj|�}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}qtjj
||jj�d�}nd}|S)z*Return the location of module docs or Nonez
(built-in)r��errno�
exceptions�gc�imp�marshal�posix�signalr�_thread�	zipimportz
site-packages�	xml.etree�test.pydoc_mod�http://�https://z%s/%s�/z.htmlN)
r�r�r�r�r�r�r�rr�r�)r�r�)r�r�)r�
getabsfiler�r	�environr|r�rrr�r�r%rar!r�lower)r>rZbasedirrv�doclocrrr�	getdocloc�s$
	%%z
Doc.getdocloc)r%r&r[r	r�r|r�version_infor�r�r�r�r�r�r�r�r�rr!�base_exec_prefixr�rrrrr�gsr�c@sjeZdZdZdd�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)rrm�maxlist�maxtuple�maxdict�	maxstring�maxother)r>rrrrm�s
	zHTMLRepr.__init__cCst|dddddd�S)N�&z&amp;�<z&lt;�>z&gt;)r/)r>r.rrr�escape�szHTMLRepr.escapecCstj||�S)N)rr�)r>rrrrr��sz
HTMLRepr.reprcCs�tt|�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.repr1cCst||j�}t|�}d|krcdt|dd�krcd|d|j|�|dStjdd|j|��S)Nrsz\\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_stringcCsOy)|jttt|��|j��SWn|jd|jj�SYnXdS)Nz
<%s instance>)r�r3r5r�r��	__class__r%)r>rNr�rrr�
repr_instance�s)zHTMLRepr.repr_instanceN)r%r&r[rUrmr�r�r�r��repr_strr�Zrepr_unicoderrrrr��sr�c@s�eZdZdZe�ZejZejZdd�Zddd�Z	dddd	d
d�Z
dd
�Zdd�Zddd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdiiidd �Zdd!d"�Zddd#d$�Zddiid%d&�Zd'd(�Zddiiidd)d*�Zd+d,�Zdddd-d.�Zddd/d0�Zdddd1d2�Zdd3d4�ZdS)5�HTMLDocz'Formatter class for HTML documentation.cCsd||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�Nz&nbsp;c	
Csw|dkrdd|d}d|||f}	|rT|	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�szHTMLDoc.sectioncGsd|}|j||�S)z$Format a section with a big heading.z<big><strong>%s</strong></big>)r�)r>r�r�rrr�
bigsections
zHTMLDoc.bigsectionc
Cs7|j|j��}t|dddddddd�	S)z!Format literal preformatted text.z

z
 
r�z&nbsp;rz<br>
)r��
expandtabsr/)r>r.rrr�	preformatszHTMLDoc.preformatrrcCs�d}t|�|d|}x�t|�D]r}|dd|}xMt|||||�D]0}|t|�kr_||||�d}q_W|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�col�irrr�multicolumns"zHTMLDoc.multicolumncCsd|S)Nz<font color="#909090">%s</font>r)r>r.rrr�greyszHTMLDoc.greycGs3x,|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�namelinks
zHTMLDoc.namelinkcCsm|jtjj|j�}}t||�r`t||�|kr`d|j|t||�fSt||�S)zMake a link for a class.z<a href="%s.html#%s">%s</a>)r%rr�r|r&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�
modulelink+szHTMLDoc.modulelinkcCso|\}}}}|r%|j|�S|r>d||f}n
d|}|r[d|}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(rrp�shadowed�urlr.rrr�
modpkglink/s


zHTMLDoc.modpkglinkcCsd||fS)zMake a link to source file.z<a href="file:%s">%s</a>r)r>r
rrrr�filelink>szHTMLDoc.filelinkcCs|p|j}g}d}tjd�}x�|j||�}	|	sFP|	j�\}
}|j||||
���|	j�\}}
}}}}|
r�||�jdd�}|jd||f�n|rdt|�}|jd|||�f�n�|r7dt|�}|jd|||�f�n�|r�|||d�d	krw|jd
|j	||��q�|jd|�nU|||d�d	kr�|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(r
rrr�markupBs<   "
zHTMLDoc.markupc
Csd}x�|D]�}t|�tf�kr�|\}}|d}||j||�}|r�||fkr�g}x'|D]}	|j|j|	|��qyW|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�parentsrIrrrrms 



zHTMLDoc.formattreec#s�|j}y
|j}Wntk
r0d}YnX|jd�}g}xPtt|�d�D]8}|jddj|d|d��||f�q]Wdj||d.d��}	d|	}
y7tj	|�}t
jj|�}�j
||�}
Wntk
rd}
YnXg}t|d�r�t|j�}|dd�d/krx|d0d�d	krx|dd1�j�}|jd�j|��t|d�r�|j�jt|j���|r�|
d
dj|�}
�j|�}|dk	rdt�}nd}�j|
ddd|
|�}tj|tj�}gi}}x�tj|tj�D]n\}}|dk	s�tj|�p�||krft|||�rf|j||f�d|||<||<qfWx�|D]�\}}x�|jD]�}|j|j}}tj j!|�}||kr�|r�t||�r�t"||�|kr�||kr�|d|||<||<q�Wq�Wgi}}x�tj|tj#�D]�\}}|dk	s�tj$|�s�tj|�|kr�t|||�r�|j||f�d|||<tj%|�r�||||<q�Wg}xEtj|t&�D]1\}}t|||�rP|j||f�qPW�j't(|��j)||�}|o�d|}|d|}t|d�rVg}x<t*j+|j,�D](\}}} |j||| df�q�W|j-��j.|�j/�}!|�j0ddd|!�}n@|r��j.|�fdd��}!|�j0ddd|!�}|r.d d!�|D�}"�j1tj2|"d�|�g}!x6|D].\}}|!j�j3|||||��q�W|�j0d"dd#d$j|!��}|r�g}!x6|D].\}}|!j�j3|||||��qAW|�j0d%dd&d$j|!��}|r�g}!x-|D]%\}}|!j�j3||��q�W|�j0d'dd(d)j|!��}t|d*�rB�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>rqz.html#z#-z<tt>%s</tt>z
<p>%s</p>
rZrzPackage Contentsz#aa55cccs�j|d�S)Nr)r)�t)r>rr�<lambda>�sz#HTMLDoc.docmodule.<locals>.<lambda>�ModulescSsg|]\}}|�qSrr)r�rGrHrrrr��s	z%HTMLDoc.docmodule.<locals>.<listcomp>ZClassesz#ee77aar�Z	Functionsz#eeaa77ZDataz#55aa55z<br>
rPZAuthorrSZCreditsrtz$Revision: rtrt)6r%�__all__r�rr�r r
r!rr��urllib�parseZquoterr�rc�strr]rr�rTr��localsr�r@r*r+�	getmodulererAr&rr�r|r<r,r8r6r-rrr��pkgutil�iter_modulesrZ�sortrrr�r�getclasstreer�rPrS)#r>rr(�mod�ignoredrd�partsZlinksrZ
linkedname�headrr
rr��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	��q�W�d���������fdd�}
����fd	d
�}��������fdd�}�fd
d�t
��D�}i�x|D]w\}}}}d|d|�|<}yt�|�}Wntk
r�YnXy|�|<WqWt
k
r�YqWXqWWxI|r|r�|j��n|dd�t|�fdd��\}}�tjkr:|}q�n.��krOd}nd�j��j	�}|d7}|jddd��|
d||dd��}|
d||dd��}|
d||dd��}|d||d d��}|d!||d"d��}|}q�Wd#j|	�}	||krLd$||f}nd%|||f}|r�g}x*|D]"}|j�j|�j	��qrW|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>rrrrmsz1HTMLDoc.docclass.<locals>.HorizontalRule.__init__cs |jr�d�d|_dS)Nz<hr>
r)r>)r>)�pushrr�maybes	
z.HTMLDoc.docclass.<locals>.HorizontalRule.maybeN)r%r&r[rmr@r)r?rr�HorizontalRulesrArz&<dl><dt>Method resolution order:</dt>
z<dd>%s</dd>
z</dl>
cs�t||�\}}|r��j��|�x�|D]�\}}}}yt�|�}Wn+tk
r���j||���Yn&X��j||��������d�q6W|S)Nr)rOr@r<�	Exception�_docdescriptorr�)�msg�attrsrK�okr(ri�homeclsrH)rr�hr�mdictr4rr?r>rr�spills


zHTMLDoc.docclass.<locals>.spillcsit||�\}}|re�j��|�x3|D]+\}}}}��j||���q6W|S)N)rOr@rC)rDrErKrFr(rirGrH)rHr4r?r>rr�spilldescriptors)s

z*HTMLDoc.docclass.<locals>.spilldescriptorsc
s
t||�\}}|r	�j��|�x�|D]�\}}}}�jt�|�|��}t|�s�tj|�r�t|dd�}	nd}	|	dkr��d|�nB�jt|��j	����}	d|	}	�d||	f��d�q6W|S)NrUz<dl><dt>%s</dl>
z<dd><tt>%s</tt>z<dl><dt>%s%s</dl>
r)
rOr@r�r<�callablerrgrrr�)
rDrErKrFr(rirGrHrIr")rrrHrIr4rr?r>rr�	spilldata2s"


z#HTMLDoc.docclass.<locals>.spilldatacs@g|]6\}}}}t|d��r||||f�qS)r9)re)r�r(rirjrH)rrrr�Gs	z$HTMLDoc.docclass.<locals>.<listcomp>rq�-rcs|d�kS)Nrr)r')�	thisclassrrr(`sz"HTMLDoc.docclass.<locals>.<lambda>zdefined herezinherited from %sz:<br>
rGcSs|dS)Nrr)r'rrrr(msz
Methods %scSs|ddkS)Nr�methodr)r'rrrr(qszClass methods %scSs|ddkS)Nrzclass methodr)r'rrrr(sszStatic methods %scSs|ddkS)Nrz
static methodr)r'rrrr(uszData descriptors %scSs|ddkS)Nrzdata descriptorr)r'rrrr(wszData and other attributes %scSs|ddkS)Nrr9r)r'rrrr(ysrz*<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 r@rr&rfr<rBr��popleftrO�builtinsrr2r!rrr�r�)r>rr(r4rrr5�realnamer#r�rA�mrorIrJrKrMrErGrirGrH�anchor�	inherited�tagr�r$r"r)	rrrHrIr4rr?r>rOrr��s�				



'	'

		!	








 $zHTMLDoc.docclasscCs|jd|j|��S)z)Format an argument default value as text.�=)rr�)r>rrrr�formatvalue�szHTMLDoc.formatvaluecCsT|j}|p|}|r$|jp'dd|}	d}
d}t|�r�|jj}|r�||k	r�d|j||�}
nD|jdk	r�d|j|jj|�}
nd|j||�}
||kr�d|	|f}
ne|r0||jkr0|j||kr0d	|jd||f}d
}n|}d|	||f}
d}tj|�r�ytj|�}Wnt	t
fk
r�d}YnX|r�t|�}|dkr�d
|}
|d
d�}|s�d}|
|j|�|
o�|j
d|
�}|rd|S|jt|�|j|||�}|o?d|}d||fSdS)z;Produce HTML documentation for a function or method object.rrNrz 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>
rt)r%r?r;r�r�__dict__rr,�	signature�
ValueErrorr�r-r�rrrr�)r>rr(r4rrrFrErTrV�note�skipdocs�imclassr�Zreallink�argspecr\�declr"rrrr��sZ			
zHTMLDoc.docroutinecCsrg}|j}|r#|d|�|jdk	r[|jt|�|j�}|d|�|d�dj|�S)Nz!<dl><dt><strong>%s</strong></dt>
z<dd><tt>%s</tt></dd>
z</dl>
r)r
rUrrr�r!)r>r(rHr4rhr?r"rrrrC�s	
zHTMLDoc._docdescriptorcCs|j|||�S)z*Produce html documentation for a property.)rC)r>rr(r4rErrrr��szHTMLDoc.docpropertycGs'|rd|pd}||j|�S)z-Produce HTML documentation for a data object.z<strong>%s</strong> = r)r�)r>rr(r4r5Zlhsrrrr��szHTMLDoc.docothercCs|j|||�S)z1Produce html documentation for a data descriptor.)rC)r>rr(r4rErrrr��szHTMLDoc.docdatacCs�g}|dkri}xhtj|g�D]T\}}}tdd�|D��rVq+|j|d|||kf�d||<q+W|j�|j||j�}|j|dd|�S)z2Generate an HTML index for a directory of modules.Ncss1|]'}dt|�ko&dknVqdS)i�i��N)�ord)r��chrrr�	<genexpr>�sz HTMLDoc.index.<locals>.<genexpr>rrz#ffffffz#ee77aa)r0r1�anyr
r2rrr�)r>rr	r:r;r(r<r�rrr�index�s"
z
HTMLDoc.index)r%r&r[rUr��_repr_instancer�r�r�r�r�r�r�rrrrrrrrrr�r�rZr�rCr�r�r�rgrrrrr��s:			
+y�;
r�c@sLeZdZdZdd�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�)rrmr�r�r�r�r�)r>rrrrm�s
	zTextRepr.__init__cCsxtt|�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.repr1cCs^t||j�}t|�}d|krZdt|dd�krZd|d||dS|S)Nrsz\\rr�r)r3r�r�r/)r>rNr�r�r�rrrr�	s
$zTextRepr.repr_stringc
Cs=y ttt|��|j�SWnd|jjSYnXdS)Nz
<%s instance>)r3r5r�r�r�r%)r>rNr�rrrr�s zTextRepr.repr_instanceN)	r%r&r[rUrmr�r�r�r�rrrrri�s	ric@s�eZdZdZe�ZejZdd�Zddd�Zdd�Z	d	d
dd�Z
d	d	d
d�Zd	d	dd�Zdd�Z
d	d	d	dd�Zdd�Zd	d	d	dd�Zd	d	d	dd�Zd	d	d	d	d	dd�Zd	S)�TextDocz'Formatter class for text documentation.cCsdjdd�|D��S)z(Format a string in bold by overstriking.rcss|]}|d|VqdS)�Nr)r�rdrrrre$szTextDoc.bold.<locals>.<genexpr>)r!)r>r.rrr�bold"szTextDoc.boldz    csS|s
dS�fdd�|jd�D�}|rF|dj�|d<dj|�S)z6Indent text by prepending a given prefix to each line.rcsg|]}�|�qSrr)r�rw)�prefixrrr�)s	z"TextDoc.indent.<locals>.<listcomp>rrrtrt)rrr!)r>r.rmr#r)rmr�indent&s"zTextDoc.indentcCs.|j|�j�}|j|�d|dS)z&Format a section with a given heading.rz

)rnrrl)r>r�r�Zclean_contentsrrrr�-szTextDoc.sectionNrc
s�d}x�|D]�}t|�tf�kr�|\}}||t|��}|r�||fkr��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))r�r")r'rrre<sz%TextDoc.formattree.<locals>.<genexpr>z(%s)z, rz    )r�r)r!r)
r>rr'r rmrr!r"r#r$r)r'rr4s

	zTextDoc.formattreecCs�|j}tt|��\}}|jd||o:d|�}t|dd�}|j|�}|dk	r�||jd|d�}|r�||jd|�}g}	xotj|tj�D]X\}
}|dk	s�tj	|�p�||kr�t
|
||�r�|	j|
|f�q�Wg}xxtj|tj�D]a\}
}|dk	sttj
|�sttj	|�|kr8t
|
||�r8|j|
|f�q8Wg}
xEtj|t�D]1\}
}t
|
||�r�|
j|
|f�q�Wg}t�}t|d�r�xWtj|j�D]C\}}}|j|�|rR|j|d	�q|j|�qW|j�||jd
dj|��}g}xRtj|tj�D];\}
}|jj|d�r�|
|kr�|j|
�q�W|r|j�||jd
dj|��}|	r�dd�|	D�}|jtj|d�|�g}x0|	D](\}
}|j|j||
|��qWW||jddj|��}|rg}x0|D](\}
}|j|j||
|��q�W||jddj|��}|
rdg}x6|
D].\}
}|j|j||
|dd��qW||jddj|��}t|d�r�t|j�}|dd�d#kr�|d$d�dkr�|dd%�j�}||jd|�}t|d�r||jdt|j ��}t|d�r6||jdt|j!��}t|d�rd||jd t|j"��}ytj#|�}Wnt$k
r�d!}YnX||jd"|�}|S)&z5Produce text documentation for a given module object.�NAMEz - r*NzMODULE REFERENCEa.

The following documentation is automatically generated from the Python
source files.  It may be incomplete, incorrect or include features that
are considered implementation detail and may vary between Python
implementations.  When in doubt, consult the module reference at the
location listed above.
ZDESCRIPTIONrZz
 (package)zPACKAGE CONTENTSrrZ
SUBMODULEScSsg|]\}}|�qSrr)r�rGrHrrrr��s	z%TextDoc.docmodule.<locals>.<listcomp>r�CLASSES�	FUNCTIONSr2�FZDATAr]r%r&z
Revision: �VERSIONrTZDATErPZAUTHORrSZCREDITSz
(built-in)ZFILEz$Revision: rtrt)%r%r$rr�r<r�rr@r+r/rer
r,r8r-�setrcr0r1rZ�addr2r!r*rarr3r�r�r-r]rrTrPrSr�r�)r>rr(r4Zsynop�descrrdr�rrGrHrr9r:Z
modpkgs_namesr;r'r<Z
submodulesr=r�r8rvrrrr�Ds�	 ""$	"

	""
	  &,
zTextDoc.docmodulecs-�j}|p|}�j}�jdd�}||krRd�j|�}n�j|�d|}|r�t||�}	|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�}x0|r�|r�|j
��n|dd�t|�fdd��\}}�tjkr#|}q�n+��kr8d}ndt��j�}|j�|d||dd��}|d||dd��}|d||d d��}|d!||d"d��}|d#||d$d��}|}q�Wdj|�}|s|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)r>)r>rrrrm�sz1TextDoc.docclass.<locals>.HorizontalRule.__init__cs$|jr�dd�d|_dS)NrNrrr)r>)r>)r?rrr@�s	z.TextDoc.docclass.<locals>.HorizontalRule.maybeN)r%r&r[rmr@r)r?rrrA�srAcs�t||�\}}|r��j��|�xw|D]o\}}}}yt�|�}Wn+tk
r���j||���Yq6X��j||����q6W|S)N)rOr@r<rBrCr�)rDrErKrFr(rirGrH)rHr4rr?r>rrrJ�s


zTextDoc.docclass.<locals>.spillcsit||�\}}|re�j��|�x3|D]+\}}}}��j||���q6W|S)N)rOr@rC)rDrErKrFr(rirGrH)rHr4r?r>rrrK�s

z*TextDoc.docclass.<locals>.spilldescriptorsc
s�t||�\}}|r��j��|�x�|D]�\}}}}t|�sctj|�rrt|�}nd}yt�|�}	Wntk
r�|j|}	YnX��j	|	|�ddd|�d�q6W|S)Nr2rrr"r)
rOr@rLrrgrr<r�r[r�)
rDrErKrFr(rirGrHr"r9)rHr4rr?r>rrrM�s


!z#TextDoc.docclass.<locals>.spilldatacs@g|]6\}}}}t|d��r||||f�qS)r9)re)r�r(rirjrH)rrrr��s	z$TextDoc.docclass.<locals>.<listcomp>rcs|d�kS)Nrr)r')rOrrr(sz"TextDoc.docclass.<locals>.<lambda>zdefined herezinherited from %szMethods %s:
cSs|ddkS)NrrPr)r'rrrr(szClass methods %s:
cSs|ddkS)Nrzclass methodr)r'rrrr(szStatic methods %s:
cSs|ddkS)Nrz
static methodr)r'rrrr(szData descriptors %s:
cSs|ddkS)Nrzdata descriptorr)r'rrrr(szData and other attributes %s:
cSs|ddkS)Nrr9r)r'rrrr(sz |  )r%rAr&rl�mapr!rr
rrrQr rfrRrOrSrr)r2rnr)r>rr(r4r5rTr#rwr�r$r"r�rUrIrArJrKrMrErWrXr)rHr4rr?r>rOrr��sl			


			!		







zTextDoc.docclasscCsd|j|�S)z)Format an argument default value as text.rY)r�)r>rrrrrZ&szTextDoc.formatvaluecCs�|j}|p|}d}d}t|�r�|jj}|ra||k	r�dt||�}n>|jdk	r�dt|jj|�}ndt||�}||kr�|j|�}	nE|r�||jkr�|j||kr�d}|j|�d|}	d}
tj|�r�ytj	|�}Wnt
tfk
rJd}YnX|r�t|�}
|d	kr�|j|�d
}	|
dd
�}
|
s�d}
|	|
|}|r�|dSt
|�p�d}
|d|
o�|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(...)rrt)r%r?r;r�r)rlr[rr,r\r]r�r-rrnr)r>rr(r4rErTr^r_r`r�rar\rbr"rrrr�*sJ	zTextDoc.docroutinecCstg}|j}|r2||j|��|d�t|�pAd}|rg||j|��|d�dj|�S)Nrr)r
rlrrnr!)r>r(rHr4rhr?r"rrrrC\s	

zTextDoc._docdescriptorcCs|j|||�S)z*Produce text documentation for a property.)rC)r>rr(r4rErrrr�iszTextDoc.docpropertycCs|j|||�S)z1Produce text documentation for a data descriptor.)rC)r>rr(r4rErrrr�mszTextDoc.docdatac
Cs�|j|�}|r_|r%|dp(d|}|t|�}	|	dkr_|d|	�d}|rx|j|�dp{d|}|dk	r�|d|jt|��7}|S)z-Produce text documentation for a data object.z = rrNz...r)r�r rlrnr-)
r>rr(r4r r2r"r�rwZchoprrrr�qs#zTextDoc.docother)r%r&r[rUrirhr�rlrnr�rr�r�rZr�rCr�r�r�rrrrrjs		e}2
rjc@s"eZdZdZdd�ZdS)�
_PlainTextDocz2Subclass of TextDoc which overrides string stylingcCs|S)Nr)r>r.rrrrlsz_PlainTextDoc.boldN)r%r&r[rUrlrrrrry}srycCst�at|�dS)zCThe first time this is called, determine what kind of pager to use.N)�getpager�pager)r.rrrr{�s	r{cCs�ttjd�stSttjd�s,tStjj�sLtjj�rPtSdtjkr�tjdkrxdd�Stjj	d�dkr�d	d�Sd
d�Stjj	d�dkr�tStjdkr�dd�Sttd�rtj
d
�dkrdd�Sddl}|j�\}}tj
|�z:ttd�rgtj
d|�dkrgdd�StSWdtj|�XdS)z2Decide what method to use for paging through text.�isatty�PAGER�win32cSstt|�tjd�S)Nr})�
tempfilepager�plainr	r�)r.rrrr(�szgetpager.<locals>.<lambda>ZTERM�dumb�emacscSstt|�tjd�S)Nr})�	pipepagerr�r	r�)r.rrrr(�scSst|tjd�S)Nr})r�r	r�)r.rrrr(�scSstt|�d�S)Nzmore <)rr�)r.rrrr(�s�systemz(less) 2>/dev/nullrcSs
t|d�S)NZless)r�)r.rrrr(�sNz	more "%s"cSs
t|d�S)NZmore)r�)r.rrrr(�s)r�r�)r�r�)rcr�stdin�
plainpager�stdoutr|r	r��platformr|r��tempfileZmkstemp�close�ttypager�unlink)r��fdr�rrrrz�s4 



$

(
rzcCstjdd|�S)z%Remove boldface formatting from text.z.r)rr)r.rrrr��sr�c Cs�ddl}|j|ddd|j�}yLtj|jdd��-}y|j|�Wntk
rmYnXWdQRXWntk
r�YnXx(y|j	�PWq�tk
r�Yq�Xq�WdS)z3Page through text by feeding it to another program.rN�shellTr��errors�backslashreplace)
�
subprocess�Popen�PIPE�io�
TextIOWrapperr��write�KeyboardInterruptr��wait)r.�cmdr��proc�piperrrr��s 



r�cCsvddl}|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�rvrrrr�srcCs4ttjdd�pd}|j|d�j|�S)N�encodingzutf-8r�)r<rr��encode�decode)r.r�rrr�_escape_stdout�sr�c
Cs5tt|��jd�}yGddl}tjj�}|j|�}|j|�dd�}Wn0t	t
tjfk
r�d}dd�}YnXz|yt
tjjdd��}Wntk
r�d}YnX|dkr�d	}|d}}tjjdj|d|��d�x�||d�rtjjd
�tjj�|�}	|	dkrrtjjd
�Pn5|	dkr�tjjd
||d�|d}q|	dkr�|||}|dkr�d}tjjddj||||��d�||}qWWd|r0|j||j|�XdS)z%Page through text on a text terminal.rrNcSstjjd�S)Nr)rr�r�rrrrr(�szttypager.<locals>.<lambda>cSs!tjj�dd�dd�S)Nrrt)rr�rurrrrr(�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�r|r]r�r�r!�flushZ	tcsetattrZ	TCSAFLUSH)
r.r#r�r��oldZgetchar�hr�Zincr"rrrr��sL

'
	
/r�cCs tjjtt|���dS)z>Simply print unformatted text.  This is the ultimate fallback.N)rr�r�r�r�)r.rrrr�sr�cCs$tj|�rQ|jtjkr,d|jSt|d�rFd|jSd|jStj|�rkd|jStj|�r�d|jj	|jj|jfStj
|�r�d|jj	|jj|jfStj|�r�d|jStj|�r�d	|jStj
|�rd
|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�describes.r�cCs�dd�|jd�D�}d\}}xW|t|�kr�tdj|d|d��|�}|r}||d}}q+Pq+W|r�|}nt}xD||d�D]2}yt||�}Wq�tk
r�dSYq�Xq�W|S)z@Locate an object by name or dotted path, importing as necessary.cSsg|]}|r|�qSrr)r�r�rrrr�#s	zlocate.<locals>.<listcomp>rNrr)Nr)rr r�r!rSr<r�)rr�r6r��nZ
nextmodulerr�rrr�locate!s &	

r�cCsyt|t�rDt||�}|dkr:td|��||fSt|dd�}|t|t�rn|ndfSdS)zDGiven an object or a path to an object, get the object and its name.Nz~No Python documentation found for %r.
Use help() to get the interactive help utility.
Use help(str) for help on the str class.r%)r�r-r�r�r<)r�r�rr(rrr�resolve:s

r�z Python Library Documentation: %scCs'|dkrt}t||�\}}t|�}tj|�}|rxd|krx|d|d|jd��7}n#|r�||k	r�|d|j7}tj|�p�tj|�p�tj	|�p�tj
|�p�tj|�p�t|t
�st|�}|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�rr/�rfindr%r*r+r,r�r�r�r�r�r�)r�r�r�Zrendererrr(rvr�rrr�
render_docHs$$
r�cCs�yE|dkr(tt|||��n|jt|||t��Wn5ttfk
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"as r"cCs�y~t||�\}}tjt|�tj||��}t|dddd��}|j|�WdQRXtd|d�Wn5tt	fk
r�}zt|�WYdd}~XnXdS)z<Write HTML documentation to a file in the current directory.z.htmlr�r�zutf-8NZwrote)
r��htmlr�r�r�r�r�r�r�r�)r�r�rr(r�rvrHrrr�writedocls$r�rcCsI|dkri}x0tj|g|�D]\}}}t|�q(WdS)zAWrite out HTML documentation for all modules in a directory tree.N)r0�
walk_packagesr�)r�pkgpath�doner;r'r<rrr�	writedocsws
%r�c�@s�eZdZddddddddddd	d5d
d6dd7dd8dd9dd:dddd;dddddd<dddd=dd>dd?d!d@d#d$d%dAd'dBd)dd*dd+dCd,dDd.dEddFd/dGddHd2dIi!Zd3dJd<dKd$dLdQdMdRdNd_dOd`dPiZdCdcd@dddedfdgdhdidjdkdldmdndod3dpdqdrdsdtdudvdwdxdwdydzd{dziZxaej�D]S\ZZxDeD]<Z	ej
e	e�Zeekr�ed|eZeee	<q�WquWd}dQd3dRd�dSd�dTd�dUd�dVd�dWd�dXd`dYd�dZd�d�d&d[d�d\d�d]d�d^d�d}d�d}d�d_djd`d�dad�dbd dcd�dd�ddd<d�d�d�d�ded�dfddgd�dhd�did"djd�dkd�dld�dmd�dnd�dod�d�d�d�d-dpd�dqd�drd�dsdqdtd�dud�d�d�dvd�dwd�dxd�dyd�dzd�d{d�d|d�d}d�d~ddddQd�d�d�d�d�d_d�d$d�dd�d�d	dd�dRd�dddd.dddddd�dd�dd�dd�iIZdddd�Ze
dd��Ze
dd��Zdd�Ze�Zedd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$d%d&�Zd'd(�Zd)d*�Zd+d,�Zdd-d.�Zdd/d0�Zd1d2�Zdd3d4�ZdS(��Helper�Falser�None�True�andZBOOLEAN�as�with�assert�break�	while for�class�CLASSES SPECIALMETHODS�continue�def�function�del�BASICMETHODS�elif�if�else�except�try�finally�for�break continue while�from�import�global�nonlocal NAMESPACES�
TRUTHVALUE�MODULES�in�SEQUENCEMETHODS�isZ
COMPARISON�lambdarq�nonlocal�global NAMESPACES�not�or�pass�raise�
EXCEPTIONS�return�while�break continue if TRUTHVALUE� CONTEXTMANAGERS EXCEPTIONS yield�yieldZSTRINGS�'�'''�r'�b'�"""r
�r"�b"�	OPERATORS�+rN�*�**r��//�%�<<�>>r��|�^�~r�r��<=�>=�==�!=�<>ZUNARY�AUGMENTEDASSIGNMENT�+=�-=�*=�/=�%=�&=�|=�^=�<<=�>>=�**=�//=ZBITWISEZCOMPLEX�j�JzOPERATORS FORMATTINGZPOWER�,zTUPLES LISTS FUNCTIONSrz ATTRIBUTES FLOAT MODULES OBJECTSz...�ELLIPSIS�:zSLICINGS DICTIONARYLITERALS�@z	def classrsr_ZPRIVATENAMESr^zPRIVATENAMES SPECIALMETHODS�`Z
BACKQUOTESrzTUPLES FUNCTIONS CALLSr�[zLISTS SUBSCRIPTS SLICINGS�]r��TYPES�types�RSTRINGS UNICODE NUMBERS SEQUENCES MAPPINGS FUNCTIONS CLASSES MODULES FILES inspect�strings�4str UNICODE SEQUENCES STRINGMETHODS FORMATTING TYPESZ
STRINGMETHODS�string-methods�STRINGS FORMATTINGZ
FORMATTING�
formatstrings�UNICODE�:encodings unicode SEQUENCES STRINGMETHODS FORMATTING TYPESZNUMBERS�numbers�INTEGER FLOAT COMPLEX TYPESZINTEGER�integers�	int rangeZFLOAT�floating�
float math�	imaginary�
complex cmathZ	SEQUENCES�typesseq�$STRINGMETHODS FORMATTING range LISTSZMAPPINGSZDICTIONARIES�typesfunctions�	def TYPESZMETHODS�typesmethods�class def CLASSES TYPESZCODEOBJECTS�bltin-code-objects�compile FUNCTIONS TYPESZTYPEOBJECTS�bltin-type-objects�types TYPESZFRAMEOBJECTSZ
TRACEBACKSZNONE�bltin-null-object�bltin-ellipsis-object�SLICINGSZSPECIALATTRIBUTES�specialattrsrp�!class SPECIALMETHODS PRIVATENAMES�typesmodulesZPACKAGES�EXPRESSIONS�operator-summary��lambda or and not in is BOOLEAN COMPARISON BITWISE SHIFTING BINARY FORMATTING POWER UNARY ATTRIBUTES SUBSCRIPTS SLICINGS CALLS TUPLES LISTS DICTIONARIESZ
PRECEDENCEZOBJECTS�objectsZSPECIALMETHODS�specialnames�bBASICMETHODS ATTRIBUTEMETHODS CALLABLEMETHODS SEQUENCEMETHODS MAPPINGMETHODS NUMBERMETHODS CLASSES�
customization�hash repr str SPECIALMETHODSZATTRIBUTEMETHODS�attribute-access�ATTRIBUTES SPECIALMETHODSZCALLABLEMETHODS�callable-types�CALLS SPECIALMETHODS�sequence-types�(SEQUENCES SEQUENCEMETHODS SPECIALMETHODSZMAPPINGMETHODS�MAPPINGS SPECIALMETHODS�
NUMBERMETHODS�
numeric-types�*NUMBERS AUGMENTEDASSIGNMENT SPECIALMETHODSZ	EXECUTION�	execmodel�%NAMESPACES DYNAMICFEATURES EXCEPTIONSZ
NAMESPACES�naming�3global nonlocal ASSIGNMENT DELETION DYNAMICFEATURESZDYNAMICFEATURES�dynamic-featuresZSCOPINGZFRAMESr��try except finally raiseZCONVERSIONS�conversionsZIDENTIFIERS�identifiers�keywords SPECIALIDENTIFIERSZSPECIALIDENTIFIERS�
id-classes�atom-identifiersZLITERALS�
atom-literals�=STRINGS NUMBERS TUPLELITERALS LISTLITERALS DICTIONARYLITERALSZTUPLESZ
TUPLELITERALS�	exprlists�TUPLES LITERALSZLISTS�typesseq-mutable�LISTLITERALS�lists�LISTS LITERALS�typesmapping�DICTIONARYLITERALSr�DICTIONARIES LITERALSZ
ATTRIBUTES�attribute-references�(getattr hasattr setattr ATTRIBUTEMETHODSZ
SUBSCRIPTS�
subscriptions�slicingsZCALLS�calls�power�unaryZBINARY�binaryZSHIFTING�shifting�bitwise�comparisons�EXPRESSIONS BASICMETHODS�booleans�EXPRESSIONS TRUTHVALUEZ	ASSERTIONZ
ASSIGNMENT�
assignment�	augassignZDELETIONZ	RETURNINGZ	IMPORTINGZCONDITIONALZLOOPING�compound�for while break continue�truth� if while and or not BASICMETHODSZ	DEBUGGING�debugger�pdbZCONTEXTMANAGERS�context-managersNcCs||_||_dS)N)�_input�_output)r>�inputr�rrrrm*s	zHelper.__init__cCs|jptjS)N)r|rr�)r>rrrr(.szHelper.<lambda>cCs|jptjS)N)r}rr�)r>rrrr(/scCs?tj�dddkr%|�dSd|jj|jjfS)Nrr0�?rz<%s.%s instance>)r�stackr�r&r[)r>rrr�__repr__1s
zHelper.__repr__cCsG||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__9s

	zHelper.__call__cCs�|jjd�x�y|jd�}|s,PWnttfk
rHPYnXt|dddd�j�}|j�d	krzP|dkr�|j�q|j	|�qWdS)
Nrzhelp> r
rr�r��quitr)r�r�)
r�r��getliner��EOFErrorr/rr�r�r)r>r�rrrr�Fs
zHelper.interactcCsJ|jtjkrt|�S|jj|�|jj�|jj�SdS)z.Read one line, using input() when appropriate.N)r~rr�r�r�r�ru)r>�promptrrrr�Us


zHelper.getlinecCs�t|�td�kro|j�}|dkr=|j�q�|dkrV|j�q�|dkro|j�q�|dkr�|j�q�|dd�dkr�|j|j�d�q�||jkr�|j|�q�|dkr�t	t
|�d�q�||jkr|j|�q�||j
kr7|j|�q�|rVt	|dd
|j�q�t	tdd
|j�n/t|t�r�|�nt	|dd
|j�|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}r-r�r�r�r�)r>r�rrrr^s6




zHelper.helpcCs2|jjdttjdd�gd��dS)Na�
Welcome to Python %s's help utility!

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/%s/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".
r0r)r�r�r}rr8)r>rrrr�ss	zHelper.introrr�Pc		Cs�tt|��}||}t|�|d|}x�t|�D]�}x�t|�D]t}|||}|t|�krT|jj||�||dkrT|jjdd|dt||��qTW|jjd�qAWdS)Nrr�r)r��sortedr r�r�r�)	r>�items�columnsr�Zcolwr�rowrrrrrr��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��s	zHelper.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��s	zHelper.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��s	zHelper.listtopicscCs�yddl}Wn&tk
r8|jjd�dSYnX|jj||jj|��}|s~|jjdt|��dSt|�td�kr�|j	||�S|\}}y|jj|}Wn0t
k
r�|jjdt|��dSYnXt|j�d�|r'|pdd|}|r�ddl
}ddj|j��d}	|j|	d	�}
|jjd
dj|
��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�r|r�r�r�r��KeyErrorr{r�textwrapr!rZwrap)r>�topic�
more_xrefs�
pydoc_data�target�label�xrefsr"r�r.Zwrapped_textrrrr��s4
		!
	zHelper.showtopiccCs�yddl}Wntk
r(dSYnX|jj||jj|��}|s\td��t|t�r{|j||�S|\}}|jj|}|r�|p�dd|}||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�r|r�r]r�r-�	_gettopic)r>r�r�r�r�r�r�r"rrrr��s	
	!zHelper._gettopiccCs9|j|}|jd�\}}}|j||�dS)Nr�)r��	partitionr�)r>�symbolr�r�r_r�rrrr��s
zHelper.showsymbolcs�|r,|jjdj|��t|�np|jjd�i}|dd���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...

cSsS|r0|dd�dkr0|dd�d}|jd�dkrOd||<dS)	N�	z	.__init__z
 (package)rrri����i����)�find)rr'rvr�rrr�callback�sz$Helper.listmodules.<locals>.callbackcs�d|d�dS)Nr)r')r�rr�onerror�sz#Helper.listmodules.<locals>.onerrorr�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�rq)r�r�)r�r)r�r�)r�rq)r�r�)r�r�)r�r�)r�r)r�r�r�r�r�r
r�r�)r�rNr�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr)r�r�rrrrr)rNr�)rrrr	r
rrr
rrrr)r�r�r�r�r�r�)rr)rr)rr)r r!)r"r�)rr$)r%r&)r'r()r)r*)r+r,)r-r.)r/r0)r1r2)r3r4)r5r6)r7r)r8r9)r:r)rr;)r<r�)r>r?)r@r)rArB)rCrD)rErF)rGrH)rIrJ)rIrK)rMrN)rOrP)rQrR)rSr)r�rT)rUr)rVrW)rXr)rYr)rZr[)r\r])r^r_)r`ra)rbrc)rrd)rerf)rgr�)rhr�)rir=)rjr=)rkr=)rlr=)rmr=)rnr=)rorp)rqrr)rsr)rtrL)rurv)rwrx)ryrz)r{r�) r%r&r[r�Z_symbols_inverser�r�r�Zsymbols_r�r|r�rmr�r~r�r�rr�r�r�r�rr�r�r�r�r�r�r�r�r�rrrrr�~s4
	
	
r�c@s+eZdZdZddddd�ZdS)r�z7An interruptible scanner that searches module synopses.NcCs�|r|j�}d|_i}x�tjD]�}|dkr+d||<|dkrf|d|d�q+t|�jpxd}|jd�d}|d|}|j�j|�dkr+|d||�q+Wx�tj	d|�D]�\}	}}
|jr�P|dkr|d|d�q�ytj
|	|�}Wntk
rCw�YnX|j}t
|d	�r�y|j|�}
Wn%tk
r�|r�||�w�YnXttj|
��p�d}t
|d
�r�|j|�}qNd}nrytjj|�}Wn%tk
r|r||�w�YnX|jr6|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�r0r��	_get_specr�ryrcr�rBrxr��StringIOr�r~r�r�r�r�r<)r>r�rGZ	completerr��seenr'r(rvr;r<r�ry�sourcerr�rrrr�s`	
"	
	

	

"zModuleScanner.run)r%r&r[rUr�rrrrr�sr�cCsVdd�}dd�}tj��+tjd�t�j||d|�WdQRXdS)zAPrint all the one-line module summaries that contain a substring.cSsE|dd�dkr*|dd�d}t||o=d|�dS)Nr�z	.__init__z
 (package)z- i����i����)r�)rr'rvrrrr�Cszapropos.<locals>.callbackcSsdS)Nr)r'rrrr�Gszapropos.<locals>.onerror�ignorer�N)�warnings�catch_warnings�filterwarningsr�r�)rGr�r�rrrr�As


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@s(eZdZdd�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�sr�cs:eZdZdd�Z�fdd�Zdd�ZdS)z _start_server.<locals>.DocServercSsMd|_|j|f|_||_|jj||j|j�d|_dS)NZ	localhostF)�hostZaddressr�rIrm�handlerr�)r>�portr�rrrrm�s
		z)_start_server.<locals>.DocServer.__init__cs[xJ|jsL�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[rmr�r�r)r�rr�	DocServer�sr�csUeZdZ�fdd�Z����fdd�Zdd�Zdd�Zd	S)
z#_start_server.<locals>.ServerThreadcs>||_t|�|_�jj|�d|_d|_dS)NF)r�rr��Threadrm�serving�error)r>r�r�)�	threadingrrrm�s
		z,_start_server.<locals>.ServerThread.__init__cs�ye�jj�_��_�jj�_t|j��_�|j	|j
�}||_|j�Wn.t
k
r�}z||_WYdd}~XnXdS)zStart the server.N)�server�
HTTPServerrIr�r�ZMessageZMessageClass�staticmethodr�r��ready�	docserverr�rBr�)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��s	z)_start_server.<locals>.ServerThread.readycSs"d|j_d|_d|_dS)z&Stop the server and this thread nicelyTFN)r�r�r�r
)r>rrr�stop�s	z(_start_server.<locals>.ServerThread.stopN)r%r&r[rmr�r�r�r)r�r�r�r�r�rr�ServerThread�s
r�g{�G�z�?)
Zhttp.serverZ
email.messager�r�r�ZBaseHTTPRequestHandlerr�r�rr�r��timeZsleep)r�r�r�Zthreadr)r�r�r�r�r�r�r�
_start_serverOs8"+"
r�z	text/htmlcs�G�fdd�dt�}|���fdd���fdd���fdd���fd	d
���fdd��	�fd
d���fdd���fdd���fdd�����������	f	dd�}|jd�r|dd�}|dkr{tjjtjjt��}tjj||�}t|��}dj|j	��SWdQRXn|dkr�||�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.
    cs.eZdZ�fdd�Zdd�ZdS)z_url_handler.<locals>._HTMLDoccs'd}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.pagecSsd||fS)Nz<a href="getfile?key=%s">%s</a>r)r>r
rrrrr�sz'_url_handler.<locals>._HTMLDoc.filelinkN)r%r&r[r�rr)r�rr�_HTMLDoc�s
r�csU�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>
            ZterseT)r�r�Zpython_versionZpython_buildZpython_compiler)r8)r�rrr�	s
z!_url_handler.<locals>.html_navbarcs�dd�}�jddd�}dd�tjD�}�j||�}|d�jd	dd
|�g}i}x*tjD]}|j�j||��q{W|jd�dd
j|�fS)zModule Index page.cSsd||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#7799eecSs"g|]}|dkr|�qS)r�r)r�r(rrrr�$	s	z4_url_handler.<locals>.html_index.<locals>.<listcomp>z<p>zBuilt-in Modulesz#ee77aaz|<p align=right><font color="#909090" face="helvetica,arial"><strong>pydoc</strong> by Ka-Ping Yee&lt;ping@lfw.org&gt;</font>zIndex of Modulesr)	r�rr�rr�rr
rgr!)r�r��namesr�r�r)r�rr�
html_index	sz _url_handler.<locals>.html_indexc	s�g��fdd�}tj��7tjd�dd�}t�j||d|�WdQRXdd	�}g}�jd
dd�}x+�D]#\}}|j||�|�q�W|�jd
|dddj|��}d|fS)zSearch results page.csK|dd�dkr*|dd�d}�j||o@d|f�dS)Nr�z	.__init__z
 (package)z- i����i����)r
)rr'rv)�
search_resultrrr�9	sz3_url_handler.<locals>.html_search.<locals>.callbackr�cSsdS)Nr)r'rrrr�@	sz2_url_handler.<locals>.html_search.<locals>.onerrorr�NcSsd||fS)Nz<a href="%s.html">%s</a>r)r(rrrr�E	sz4_url_handler.<locals>.html_search.<locals>.bltinlinkz5<big><big><strong>Search Results</strong></big></big>z#ffffffz#7799eezkey = %sz#ee77aaz<br>zSearch Results)	r�r�r�r�r�r�r
r�r!)	rGr�r�r�rhr�r(rvr�)r�)r�r�html_search4	s 

 	 z!_url_handler.<locals>.html_searchc
s�tjj|�}tj|��}�j|j��}WdQRXd|}�jddd�}|�jd|dd|�}d||fS)	z-Get and display a source file listing safely.Nz
<pre>%s</pre>z3<big><big><strong>File Listing</strong></big></big>z#ffffffz#7799eezFile: %sz#ee77aaz
getfile %s)	r+r,Zunquoter�r�r�r�r�r�)r�fpr#Zbodyr�r�)r�rr�html_getfileR	s
	z"_url_handler.<locals>.html_getfilecsndd�}�jddd�}ttjj��}�j||�}|�jddd|�}d|fS)zIndex of topic texts available.cSsd||fS)Nz<a href="topic?key=%s">%s</a>r)r(rrrr�b	sz4_url_handler.<locals>.html_topics.<locals>.bltinlinkz,<big><big><strong>INDEX</strong></big></big>z#ffffffz#7799eeZTopicsz#ee77aa)r�r�r�r�rDrr�)r�r�r�r�)r�rr�html_topics_	s	z!_url_handler.<locals>.html_topicscsn�jddd�}ttjj��}dd�}�j||�}|�jddd|�}d|fS)zIndex of keywords.z,<big><big><strong>INDEX</strong></big></big>z#ffffffz#7799eecSsd||fS)Nz<a href="topic?key=%s">%s</a>r)r(rrrr�v	sz6_url_handler.<locals>.html_keywords.<locals>.bltinlinkZKeywordsz#ee77aa)r�r�r�r�rDrr�)r�r�r�r�)r�rr�
html_keywordso	s	z#_url_handler.<locals>.html_keywordscstj�}t||�}|j|�\}}||jkrHd}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#ee77aacSsd||fS)Nz<a href="topic?key=%s">%s</a>r)r(rrrr��	sz7_url_handler.<locals>.html_topicpage.<locals>.bltinlinkzRelated help topics: z%s %sr)
r�r�r�r�r�r�rr�r�rrr�r!)r�ZbufZhtmlhelpr�r�r�r�r�)r�rr�html_topicpage~	s&		
z$_url_handler.<locals>.html_topicpagecs^t|dd�}|dkr6|dkr6td��t|�}�j||�}||fS)Nr�rr�zcould not find object)r�r]r�r�)r
r9r��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�)r�rw)r�rrre�	sz3_url_handler.<locals>.html_error.<locals>.<genexpr>z#bb0000z
Error - %s)r�r!rr�r�)r
r�r�r�)r�rr�
html_error�	s
z _url_handler.<locals>.html_errorcs
|}|jd�r%|dd�}y�|dkrF��\}}ny|dkrd��\}}n[|dkr���\}}n=d|kr�|jd�\}}}|d	kr��|�\}}q�|d
kr��|�\}}q�|dkr4y�|�\}}Wq�tk
r0�|�\}}Yq�Xq�|dkr�|dkr^��\}}q�y�|�\}}Wq�tk
r��|�\}}Yq�Xq�td
��n�|�\}}Wn:tk
r�}z�||�\}}WYdd}~XnX�j||�S)zGenerate an HTML page for url.z.htmlN�rrgr�r�rYz
search?keyzgetfile?keyz	topic?keyzget?keyz
bad pydoc url���)rrg)rrg)rbr�r]rBr�)r
Zcomplete_urlr�r��opr_r�)	r�r�r�r�r�r�r�r�r�rr�
get_html_page�	sB

(z#_url_handler.<locals>.get_html_pager�rNztext/cssrz	text/htmlz"unknown content type %r for url %s)r�rar	r�dirname�realpathrVr!r��	readlinesr�)r
r�r�r�Z	path_herer�r�r)
r�r�r�r�r�r�r�r�r�r�r�_url_handler�s,		

**
r��open_browserTcCs$ddl}tt|�}|jr5t|j�dS|jr d}|rZ|j|j�z�ytd|j�t|�x^|jr�td�}|j	�}|dkr�Pq}|dkr�|j|j�q}t|�q}WWnt
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�r�r�r�r�r�r
r~r�r�r�r�)r�r�r�ZserverthreadZserver_help_msgr�rrr�browse�	s2	
	
	
r�cCs%t|t�o$|jtj�dkS)Nr)r�r-r�r	�sep)rNrrr�ispath
sr�cCs�ddl}Gdd�dt�}dtjkr|tjjtjd�}|tjkritjj|�tjjdd�y�|jtjdd�d�\}}d	}d	}d	}d}xp|D]h\}	}
|	d
kr�d}d}|	dkrt	|
�dS|	d
krd}|
}|	dkr�d}q�W|r[|dkrGd}t
|d|�dS|sg|�x�|D]�}t|�r�tjj|�r�t
d|�Pyyt|�r�tjj|�r�t|�}|r
t|�rtjj|�rt|�qt|�n
tj|�Wqntk
rL}zt
|�WYdd}~XqnXqnWWnc|j|fk
r�tjjtjjtjd��d}
t
djd|
dtj��YnXdS)z@Command-line interface (looks at sys.argv to decide what to do).rNc@seZdZdS)zcli.<locals>.BadUsageN)r%r&r[rrrr�BadUsage
sr�rrrzbk:p:wFz-bTz-kz-pz-wr�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} -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�)�getoptrBrrr	r��argv�remove�insertr�r�r��existsr�rnr�rr�r�rr�r�r�r�r�r�)r�r�Z	scriptdirZoptsr�ZwritingZstart_serverr�r�Zopt�val�argrHr�rrr�cli	
sd%




%)r�r�)WrUr*rPrTrSrSZimportlib._bootstrapr~Zimportlib._bootstrap_external�importlib.machinery�importlib.utilrr�r	r0r�rrr�r�Zurllib.parser+r��collectionsr�reprlibr�	tracebackrrrr$r)r-r/r3r�
IGNORECASEr4r5r:r?rCrOrerfrprxr�rBr�r�r�r�r�r�rirjryr{rzr�r�rr�r�r�r�r�r.r�r�r�r�r"r�r�r�rr�r�r�r�r�r�r�r%rrrr�<module>$s�			

'
0>*��- �d!,			
��	=��%V