ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python34/lib64/python3.4/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python34/lib64/python3.4/__pycache__/pydoc.cpython-34.pyc

�
e fc��@s1dZdgZdZdZdZddlZddlZddlZddl	Zddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlZddlmZddlmZdd	lmZd
d�Zdd
�Zdd�Zdd�Zdd�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,�Z/Gd-d.�d.e0�Z1d/d0�Z2did1d2�Z3Gd3d4�d4�Z4Gd5d6�d6e�Z5Gd7d8�d8e4�Z6Gd9d:�d:e�Z7Gd;d<�d<e4�Z8Gd=d>�d>e8�Z9d?d@�a:dAdB�Z;dCdD�Z<dEdF�Z=dGdH�Z>dIdJ�Z?dKdL�Z@dMdN�ZAdOdP�ZBddQdR�ZCe8�ZDe9�ZEe6�ZFddSdT�ZGdUdddVdW�ZHdUdddXdY�ZIddZd[�ZJd\dd]d^�ZKGd_d`�d`�ZLeL�ZMGdadb�db�ZNdcdd�ZOdedf�ZPdgdhdi�ZQddjdkdldm�ZRdndo�ZSdpdq�ZTeUdrkr-eT�ndS)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

    http://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}xvtjD]k}tjj|p.d�}tjj|�}||krtjj|�r|j|�|j|�qqW|S)zAConvert sys.path into a list of absolute, existing, unique paths.�.)�sys�path�os�abspath�normcase�isdir�append)�dirsZnormdirs�dirZnormdir�r�*/opt/alt/python34/lib64/python3.4/pydoc.py�pathdirsLs
rcCsCtj|�ptj|�}|r?tjdd|j��pBdS)z-Get the doc string or comments for an object.z^ *
�)�inspect�getdocZgetcomments�re�sub�rstrip)�object�resultrrrrXsrcCs�|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$cCs0|j}|j|kr,|jd|}n|S)z@Get a class name and qualify it with a module name if necessary.r)�__name__�
__module__)r�modname�namerrr�	classnamefs	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�isdatamsr-cGsAx:|r<|dj|j|d��}|dd�}qW|S)z/Do a series of global replacements on a string.rrrN)r!r)�textZpairsrrr�replacess	 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�cramzs
*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>�__file__�__name__�__version__�__credits__�__doc__�
__loader__�__package__�__builtins__�__date__�
__author__�
__module__�__spec__�	__slots__�__path__�__qualname__�
__cached__)�
startswith�endswith�hasattr)r(�allr9rrr�visiblename�s	
rucCsag}xTtj|�D]C\}}}}tj|�r@d}n|j||||f�qW|S)zCWrap inspect.classify_class_attrs, with fixup for data descriptors.zdata descriptor)r�classify_class_attrs�isdatadescriptorr
)r�resultsr(�kind�clsrHrrrrv�s"	rvcCsStjj|�rOx:dD]/}tjjtjj|d|��rdSqWndS)z3Guess whether a path refers to a package directory.�.py�.pyc�.pyo�__init__TF)r{r|r})r	rr�isfiler!)r�extrrr�	ispackage�s

%r�cCs|j�}x=|dd�dks2|j�rK|j�}|sPqqW|j�}|dd�dkr�|dd�}n|dd�dkr|dd�}|d	d�dkr�|dd
�}nx&|j�s�|j�}|s�Pq�q�W|jd�dj�}nd}|S)Nr�#�zr"""r0z"""�\r���r�)�readlinerr)�file�linerrrr�source_synopsis�s&&r�cCs�tj|�j}|j|d�\}}|dksB||kr�|jttjj��rltjj	}n0|jttjj
��r�tjj}nd}|dkr�ytj
|�}Wntk
r�dSYnX|�t|�}WdQXn�|d|�}tjjd|d|�}tjj|�}	y|	j�}
WndSYnXtjd=|
jrq|
jj�dnd}||f||<n|S)z.Get the one-line summary out of a module file.NZ__temp__�loaderr)NN)r	�stat�st_mtime�getrr�tuple�	importlib�	machinery�BYTECODE_SUFFIXES�SourcelessFileLoader�EXTENSION_SUFFIXES�ExtensionFileLoader�tokenize�open�OSErrorr��util�spec_from_file_location�
_bootstrap�_SpecMethods�loadr�modulesrU�
splitlines)�filename�cache�mtimeZ
lastupdaterZ
loader_clsr�r��spec�_spec�modulerrr�synopsis�s6
			
"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_inforrrr~s	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[rUr~r�rrrrr�sr�c
Cs�tjj}t|d��"}||jt|��k}WdQXtjj|�}tjj	|�\}}|r�tj
j||�}ntj
j||�}tjj
||d|�}tj
j|�}	y|	j�SWnt|tj���YnXdS)z<Import a Python source file or compiled file given its path.�rbNr�)r�r��MAGIC_NUMBERr��readr r	r�basename�splitextr�r��SourceFileLoaderr�r�r�r�rr�)
r�magicr�Zis_bytecoder�r(r�r�r�r�rrr�
importfile s!r�cs�y�|r|�tjkr|�tjkr|�fdd�tjD�}x3�g|D]!}tj|||<tj|=qQWq|nt��}Wn�tj�\}}}}	�tjkr�ttj�j|	��nU|tkr�t|j|	��n4|t	kr|j
�krdSt�tj���YnXxM�jd�dd�D]2}
yt||
�}WqGt
k
rxdSYqGXqGW|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)rq)�.0�m)rrr�
<listcomp>Gs	zsafeimport.<locals>.<listcomp>Nrr)rr��builtin_module_names�
__import__r�r�rV�SyntaxErrorr��ImportErrorr(rr<�AttributeError)r�	forceloadr�ZsubsrGr�r�rHr��info�partr)rr�
safeimport3s. 

r�c@szeZdZejjddejdd��Zddd�Z	ddd�Z
e
ZZZ
ZZZd	d
�ZdS)�Doc�
PYTHONDOCSz$http://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�documentis"





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�fail{s&zDoc.failcCs*ytj|�}Wntk
r-d}YnXtjjd|j�}tjjt	j
ddt	jdd��}t|t
t��r |jdks�|j|�r |jtjj|d��r |jdkr |jd�rd|jd�|jf}q&tjj||jd�}nd}|S)z*Return the location of module docs or Nonez
(built-in)r��libzpython%d.%dNr�errno�
exceptions�gc�imp�marshal�posix�signalr�_thread�	zipimportz
site-packages�	xml.etree�test.pydoc_modzhttp://z%s/%s�/z.html)
zerrnoz
exceptionszgcr�zmarshalzposixzsignalzsysz_threadr�)r�r�)r�
getabsfiler�r	�environr�r�rr!r�base_exec_prefix�version_infor�r�r%rqr)r>rr��doclocZbasedirrrr�	getdocloc�s&
	z
Doc.getdocloc)r%r&r[r	r�r�rr�r�r�r�r�r�r�r�r�r�r�rrrrr�cs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)rr~�maxlist�maxtuple�maxdict�	maxstring�maxother)r>rrrr~�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||�||�Sn|jttt	|��|j
��S)Nr%�repr_r_)rsr�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)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_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[rUr~r�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	
Csz|dkr!dd|d}nd|||f}	|rW|	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�rrr�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�
bigsection�s
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.preformatr�cCs�d}t|�|d|}x�t|�D]u}|dd|}xPt|||||�D]3}|t|�kr_||||�d}q_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�multicolumn	s"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&rsr<r))r>rr'r(r�rrr�	classlinks
$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(rr��shadowed�urlr.rrr�
modpkglink*s


zHTMLDoc.modpkglinkcCsd||fS)zMake a link to source file.z<a href="file:%s">%s</a>r)r>rrrrr�filelink9szHTMLDoc.filelinkcCs|p|j}g}d}tjd�}x�|j||�}	|	sIPn|	j�\}
}|j||||
���|	j�\}}
}}}}|
r�||�jdd�}|jd||f�n|rdt|�}|jd|||�f�n�|r:dt|�}|jd|||�f�n�|r�|||d�d	krz|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�classesrFrx�here�pattern�match�start�endrt�schemeZrfcZpepZselfdotr(rrrr�markup=s<   "
zHTMLDoc.markupc
Csd}x�|D]�}t|�tf�kr�|\}}|d}||j||�}|r�||fkr�g}x'|D]}	|j|j|	|��qyW|ddj|�d}n|d}q
t|�tg�kr
|d|j|||�}q
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,hs 



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/kr{|d0d�d	kr{|dd1�j�}n|jd�j|��nt|d�r�|j�jt|j���n|r�|
d
dj|�}
n�j|�}|dk	rdt�}nd}�j|
ddd|
|�}tj|tj�}gi}}x�tj|tj�D]t\}}|dk	s�tj|�p�||krrt|||�r�|j||f�d|||<||<q�qrqrWx�|D]�\}}x�|jD]�}|j|j}}tj j!|�}||kr|rt||�rt"||�|kr�||kr�|d|||<||<q�q�qqWq�Wgi}}x�tj|tj#�D]�\}}|dk	s�tj$|�s�tj|�|kr�t|||�rW|j||f�d|||<tj%|�rT||||<qTqWq�q�Wg}xHtj|t&�D]4\}}t|||�rt|j||f�qtqtW�j't(|��j)||�}|o�d|}|d|}t|d�r}g}x<t*j+|j,�D](\}}} |j||| df�qW|j-��j.|�j/�}!|�j0ddd|!�}nC|r��j.|�fdd��}!|�j0ddd|!�}n|r[d d!�|D�}"�j1tj2|"d�|�g}!x6|D].\}}|!j�j3|||||��qW|�j0d"dd#d$j|!��}n|r�g}!x6|D].\}}|!j�j3|||||��qnW|�j0d%dd&d$j|!��}n|r,g}!x-|D]%\}}|!j�j3||��q�W|�j0d'dd(d)j|!��}nt|d*�rx�j't|j4��j)�}!|�j0d+dd|!�}nt|d,�r��j't|j5��j)�}!|�j0d-dd|!�}n|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>rr�<lambda>�sz#HTMLDoc.docmodule.<locals>.<lambda>�ModulescSsg|]\}}|�qSrr)r�rGrHrrrr��s	z%HTMLDoc.docmodule.<locals>.<listcomp>ZClassesz#ee77aar�Z	Functionsz#eeaa77ZDataz#55aa55z<br>
rPZAuthorrSZCreditsr�z$Revision: r�r�)6r%�__all__r�rrr r
r!rr��urllib�parseZquoterr�rs�strr]rr�rTr��localsrr@r*r+�	getmodulerurAr&rr�r�r<r,r8r6r-r*rr
�pkgutil�iter_modulesrZ�sortrrrr,�getclasstreer�rPrS)#r>rr(�mod�ignoredrt�partsZlinksrZ
linkedname�headrrrr��versionr�rr�r#ZcdictrGrHrIr'r�r"Zfdict�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�n��������fdd�}
����fd	d
�}��������fdd�}�fd
d�t
��D�}i�x|D]w\}}}}d|d|�|<}yt�|�}Wntk
r�YnXy|�|<WqZt
k
r�YqZXqZWx[|r2|r�|j��n|dd�t|�fdd��\}}�tjkr=|}q�n.��krRd}nd�j��j	�}|d7}|jddd��|
d||dd��}|
d||dd��}|
d||dd��}|d||d d��}|d!||d"d��}|gks)t�|}q�Wd#j|	�}	||krad$||f}nd%|||f}|r�g}x*|D]"}|j�j|�j	��q�W|d&d'j|�}n�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>rrrr~sz1HTMLDoc.docclass.<locals>.HorizontalRule.__init__cs#|jr�d�nd|_dS)Nz<hr>
r)rL)r>)�pushrr�maybes	
z.HTMLDoc.docclass.<locals>.HorizontalRule.maybeN)r%r&r[r~rNr)rMrr�HorizontalRule�srOrz&<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�q6Wn|S)Nr)rOrNr<�	Exception�_docdescriptorr�)�msg�attrsrK�okr(ry�homeclsrH)r#r"�hr�mdictrBrrMr>rr�spills


zHTMLDoc.docclass.<locals>.spillcslt||�\}}|rh�j��|�x6|D]+\}}}}��j||���q6Wn|S)N)rOrNrQ)rRrSrKrTr(ryrUrH)rVrBrMr>rr�spilldescriptors$s

 z*HTMLDoc.docclass.<locals>.spilldescriptorsc
st||�\}}|r�j��|�x�|D]�\}}}}�jt�|�|��}t|�s�tj|�r�t|dd�}	nd}	|	dkr��d|�nB�jt|��j	����}	d|	}	�d||	f��d�q6Wn|S)NrUz<dl><dt>%s</dl>
z<dd><tt>%s</tt>z<dl><dt>%s%s</dl>
r)
rOrNr�r<�callablerrwr*rr
)
rRrSrKrTr(ryrUrHrIr")r#r"rVrWrBrrMr>rr�	spilldata-s"


z#HTMLDoc.docclass.<locals>.spilldatacs@g|]6\}}}}t|d��r||||f�qS)r9)ru)r�r(ryrzrH)rrrr�Bs	z$HTMLDoc.docclass.<locals>.<listcomp>r��-rcs|d�kS)Nrr)r5)�	thisclassrrr6[sz"HTMLDoc.docclass.<locals>.<lambda>zdefined herezinherited from %sz:<br>
rGcSs|dS)Nrr)r5rrrr6hsz
Methods %scSs|ddkS)Nr�methodr)r5rrrr6lszClass methods %scSs|ddkS)Nrzclass methodr)r5rrrr6nszStatic methods %scSs|ddkS)Nrz
static methodr)r5rrrr6pszData descriptors %scSs|ddkS)Nrzdata descriptorr)r5rrrr6rszData and other attributes %scSs|ddkS)NrrGr)r5rrrr6tsrz*<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 rNrr&rvr<rPr��popleftrO�builtinsrr@�AssertionErrorr!r*rr
r)r>rr(rBr"r#rC�realnamer1rrO�mrorIrXrYr[rSrGryrUrH�anchor�	inherited�tagr�r2r"r)	r#r"rVrWrBrrMr>r]rr��s�				



'	'

		!	








 $zHTMLDoc.docclasscCs|jd|j|��S)z)Format an argument default value as text.�=)rr�)r>rrrr�formatvalue�szHTMLDoc.formatvaluecCsf|j}|p|}|r$|jp'dd|}	d}
d}t|�r�|jj}|r�||k	r�d|j||�}
q�q�|jdk	r�d|j|jj|�}
q�d|j||�}
n||kr�d|	|f}
ne|r6||jkr6|j||kr6d	|jd||f}d
}n|}d|	||f}
d}tj|�r�ytj|�}Wnt	t
fk
r�d}YnX|r�t|�}|dkr�d
|}
|d
d�}q�q�n|s�d}n|
|j|�|
o|j
d|
�}|r d|S|jt|�|j|||�}|oQd|}d||fSdS)z;Produce HTML documentation for a function or method object.rr\rz 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�r�__dict__rr,�	signature�
ValueErrorr�r;r�rr*rr
)r>rr(rBr"r#rFrErcre�note�skipdocs�imclassr�Zreallink�argspecrk�declr"rrrr��sZ			
	zHTMLDoc.docroutinecCsxg}|j}|r&|d|�n|jdk	ra|jt|�|j�}|d|�n|d�dj|�S)Nz!<dl><dt><strong>%s</strong></dt>
z<dd><tt>%s</tt></dd>
z</dl>
r)r
rUr*rr
r!)r>r(rHrBrxrMr"rrrrQ�s	
zHTMLDoc._docdescriptorcCs|j|||�S)z*Produce html documentation for a property.)rQ)r>rr(rBrErrrr��szHTMLDoc.docpropertycGs'|rd|pd}||j|�S)z-Produce HTML documentation for a data object.z<strong>%s</strong> = r)r�)r>rr(rBrCZlhsrrrr��szHTMLDoc.docothercCs|j|||�S)z1Produce html documentation for a data descriptor.)rQ)r>rr(rBrErrrr��szHTMLDoc.docdatacCs�g}|dkri}nxktj|g�D]W\}}}tdd�|D��r\q.n|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)r>r?�anyr
r@rrr)r>rrrHrIr(rJrrrr�index�s	"
z
HTMLDoc.index)r%r&r[rUr��_repr_instancer�r�rrrrr
rrrrrrrr*r,r�r�rir�rQr�r�r�rvrrrrr��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�)rr~r�r�r�r�r�)r>rrrr~�s
	zTextRepr.__init__cCs{tt|�d�r_ddjt|�jj��}t||�r_t||�||�Snttt|��|j	�S)Nr%r�r_)
rsr�r!r%rr<r3r5r�r�)r>rNr�r�rrrr��s
"zTextRepr.repr1cCs^t||j�}t|�}d|krZdt|dd�krZd|d||dS|S)Nr�z\\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[rUr~r�r�r�r�rrrrrx�s	rxc@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�rsrrrrtszTextDoc.bold.<locals>.<genexpr>)r!)r>r.rrr�boldszTextDoc.boldz    csV|s
dS�fdd�|jd�D�}|rI|dj�|d<ndj|�S)z6Indent text by prepending a given prefix to each line.rcsg|]}�|�qSrr)r�r�)�prefixrrr�$s	z"TextDoc.indent.<locals>.<listcomp>rrr�r�)rrr!)r>r.r|r#r)r|r�indent!s"zTextDoc.indentcCs.|j|�j�}|j|�d|dS)z&Format a section with a given heading.rz

)r}rr{)r>r�rZclean_contentsrrrr(szTextDoc.sectionNrc
s�d}x�|D]�}t|�tf�kr�|\}}||t|��}|r�||fkr��fdd�|D�}	|ddj|	�}n|d}q
t|�tg�kr
||j|�||d�}q
q
W|S)zBRender in text a class tree as returned by inspect.getclasstree().rc3s|]}t|��VqdS)N)r))r�r0)r'rrrt7sz%TextDoc.formattree.<locals>.<genexpr>z(%s)z, rz    )r�r)r!r,)
r>r-r'r.r|rr/r0r1r2r)r'rr,/s

	zTextDoc.formattreecCs�|j}tt|��\}}|jd||o:d|�}t|dd�}|j|�}|dk	r�||jd|d�}n|r�||jd|�}ng}	xutj|tj�D]^\}
}|dk	s�tj	|�p�||kr�t
|
||�r$|	j|
|f�q$q�q�Wg}x~tj|tj�D]g\}
}|dk	s�tj
|�s�tj	|�|krDt
|
||�r�|j|
|f�q�qDqDWg}
xHtj|t�D]4\}
}t
|
||�r�|
j|
|f�q�q�Wg}t�}t|d�r�xWtj|j�D]C\}}}|j|�|rg|j|d	�q1|j|�q1W|j�||jd
dj|��}ng}xUtj|tj�D]>\}
}|jj|d�r�|
|kr�|j|
�q�q�W|r4|j�||jd
dj|��}n|	r�dd�|	D�}|jtj|d�|�g}x0|	D](\}
}|j|j||
|��quW||jddj|��}n|r$g}x0|D](\}
}|j|j||
|��q�W||jddj|��}n|
r�g}x6|
D].\}
}|j|j||
|dd��q7W||jddj|��}nt|d�rt|j�}|dd�d#kr�|d$d�dkr�|dd%�j�}n||jd|�}nt|d�r8||jdt|j ��}nt|d�ri||jdt|j!��}nt|d�r�||jd t|j"��}nytj#|�}Wnt$k
r�d!}YnX||jd"|�}|S)&z5Produce text documentation for a given module object.�NAMEz - r8NzMODULE 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]r3r4z
Revision: �VERSIONrTZDATErPZAUTHORrSZCREDITSz
(built-in)ZFILEz$Revision: r�r�)%r%r$rrr<r�rr@r+r=rur
r,r8r-�setrsr>r?rZ�addr@r!r*rqr,rAr�r�r;r]rrTrPrSr�r�)r>rr(rBZsynop�descrrtr�r#rGrHr"rGrHZ
modpkgs_namesrIr'rJZ
submodulesrKrrFr�rrrr�?s�	 ""$	"

	""
	 " "&","""
zTextDoc.docmodulecsE�j}|p|}�j}�jdd�}||krRd�j|�}n�j|�d|}|r�t||�}	|ddj|	�}nt��}
|
r�|
dgp�g}|j�tt	j
���}t|�dkr)�d	�x"|D]}
�d
||
��q�W�d�nG�fdd
�d
�}|�������fdd�}����fdd�}�����fdd�}�fdd�t��D�}xB|r|r�|j
��n|dd�t|�fdd��\}}�tjkr)|}q�n+��kr>d}ndt��j�}|j�|d||dd��}|d||dd��}|d||d d��}|d!||d"d��}|d#||d$d��}|gks�t�|}q�Wdj|�}|s#|dS|d�j|j�d%�dS)&z4Produce text documentation for a given class object.cSs
t||�S)N)r))r0r�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)rL)r>rrrr~�sz1TextDoc.docclass.<locals>.HorizontalRule.__init__cs'|jr�dd�nd|_dS)Nr\r�r)rL)r>)rMrrrN�s	z.TextDoc.docclass.<locals>.HorizontalRule.maybeN)r%r&r[r~rNr)rMrrrO�srOcs�t||�\}}|r��j��|�xz|D]o\}}}}yt�|�}Wn+tk
r���j||���Yq6X��j||����q6Wn|S)N)rOrNr<rPrQr�)rRrSrKrTr(ryrUrH)rVrBrrMr>rrrX�s


zTextDoc.docclass.<locals>.spillcslt||�\}}|rh�j��|�x6|D]+\}}}}��j||���q6Wn|S)N)rOrNrQ)rRrSrKrTr(ryrUrH)rVrBrMr>rrrY�s

 z*TextDoc.docclass.<locals>.spilldescriptorsc
s�t||�\}}|r��j��|�x�|D]�\}}}}t|�sctj|�rrt|�}nd}yt�|�}	Wntk
r�|j|}	YnX��j	|	|�ddd|�d�q6Wn|S)Nr2r�r"r)
rOrNrZrrwrr<r�rjr�)
rRrSrKrTr(ryrUrHr"r9)rVrBrrMr>rrr[�s


!z#TextDoc.docclass.<locals>.spilldatacs@g|]6\}}}}t|d��r||||f�qS)r9)ru)r�r(ryrzrH)rrrr��s	z$TextDoc.docclass.<locals>.<listcomp>rcs|d�kS)Nrr)r5)r]rrr6sz"TextDoc.docclass.<locals>.<lambda>zdefined herezinherited from %szMethods %s:
cSs|ddkS)Nrr^r)r5rrrr6szClass methods %s:
cSs|ddkS)Nrzclass methodr)r5rrrr6szStatic methods %s:
cSs|ddkS)Nrz
static methodr)r5rrrr6szData descriptors %s:
cSs|ddkS)Nrzdata descriptorr)r5rrrr6szData and other attributes %s:
cSs|ddkS)NrrGr)r5rrrr6sz |  )r%rAr&r{�mapr!rr
rrr_r rvr`rOrarr)r@rbr}r)r>rr(rBrCrcr1r�r�r2r"rrdrIrOrXrYr[rSrfrgr)rVrBrrMr>r]rr��sn			


			!		







zTextDoc.docclasscCsd|j|�S)z)Format an argument default value as text.rh)r�)r>rrrrri!szTextDoc.formatvaluecCs|j}|p|}d}d}t|�r�|jj}|rd||k	r�dt||�}q�q�|jdk	r�dt|jj|�}q�dt||�}n||kr�|j|�}	nH|r�||jkr�|j||kr�d}n|j|�d|}	d}
tj|�r�ytj	|�}Wnt
tfk
rSd}YnX|r�t|�}
|d	kr�|j|�d
}	|
dd
�}
q�q�n|
s�d}
n|	|
|}|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(...)rr�)r%r?r;r�r)r{rjrr,rkrlr�r;rr}r)r>rr(rBrErcrmrnror�rprkrqr"rrrr�%sJ			zTextDoc.docroutinecCszg}|j}|r5||j|��|d�nt|�pDd}|rm||j|��|d�ndj|�S)Nrr)r
r{rr}r!)r>r(rHrBrxrMr"rrrrQWs	

zTextDoc._docdescriptorcCs|j|||�S)z*Produce text documentation for a property.)rQ)r>rr(rBrErrrr�dszTextDoc.docpropertycCs|j|||�S)z1Produce text documentation for a data descriptor.)rQ)r>rr(rBrErrrr�hszTextDoc.docdatac
Cs�|j|�}|re|r%|dp(d|}|t|�}	|	dkre|d|	�d}qen|r~|j|�dp�d|}|dk	r�|d|jt|��7}n|S)z-Produce text documentation for a data object.z = rrNz...r)r�r r{r}r;)
r>rr(rBr.r2r"r�r�Zchoprrrr�ls# zTextDoc.docother)r%r&r[rUrxrwr�r{r}rr,r�r�rir�rQr�r�r�rrrrrys		e}2
ryc@s"eZdZdZdd�ZdS)�
_PlainTextDocz2Subclass of TextDoc which overrides string stylingcCs|S)Nr)r>r.rrrr{zsz_PlainTextDoc.boldN)r%r&r[rUr{rrrrr�xsr�cCst�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�Sntjj	d�dkr�tStjdkr�dd�Sttd�r
tj
d
�dkr
dd�Sddl}|j�\}}tj
|�z:ttd�rjtj
d|�dkrjdd�StSWdtj|�XdS)z2Decide what method to use for paging through text.�isatty�PAGER�win32cSstt|�tjd�S)Nr�)�
tempfilepager�plainr	r�)r.rrrr6�szgetpager.<locals>.<lambda>ZTERM�dumb�emacscSstt|�tjd�S)Nr�)�	pipepagerr�r	r�)r.rrrr6�scSst|tjd�S)Nr�)r�r	r�)r.rrrr6�scSstt|�d�S)Nzmore <)r�r�)r.rrrr6�s�systemz(less) 2>/dev/nullrcSs
t|d�S)NZless)r�)r.rrrr6�sNz	more "%s"cSs
t|d�S)NZmore)r�)r.rrrr6�s)r�r�)r�r�)rsr�stdin�
plainpager�stdoutr�r	r��platformr�r��tempfileZmkstemp�close�ttypager�unlink)r��fdr�rrrr��s4 



$

(
r�cCstjdd|�S)z%Remove boldface formatting from text.z.r)rr)r.rrrr��sr�cCs�ddl}|j|ddd|j�}yKtj|jdd��-}y|j|�Wntk
rmYnXWdQXWntk
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�cCsuddl}|j�}t|ddd��}|j|�WdQXztj|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��sr�cCs4ttjdd�pd}|j|d�j|�S)N�encodingzutf-8r�)r<rr��encode�decode)r.r�rrr�_escape_stdout�sr�c
CsDtt|��jd�}yGddl}tjj�}|j|�}|j|�dd�}Wn0t	t
tjfk
r�d}dd�}YnXz�yt
tjjdd��}Wntk
r�d}YnX|dkr�d	}n|d}}tjjdj|d|��d�x�||d�rtjjd
�tjj�|�}	|	dkrutjjd
�Pn8|	dkr�tjjd
||d�|d}qn|	dkr�|||}|dkr�d}q�ntjjddj||||��d�||}qWWd|r?|j||j|�nXdS)z%Page through text on a text terminal.rrNcSstjjd�S)Nr)rr�r�rrrrr6�szttypager.<locals>.<lambda>cSs!tjj�dd�dd�S)Nrr�)rr�r�rrrrr6�sZLINESr�z
-- more --�q�Qz
          
�
�b�B�)r�r�)r�r)r�r�r�)r�r�r�ttyrr��filenoZ	tcgetattrZ	setcbreakr�r�r��UnsupportedOperationr!r	r�r�rlr�r�r!�flushZ	tcsetattrZ	TCSAFLUSH)
r.r#r�r��oldZgetchar�hr�Zincr0rrrr��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|�rT|jtjkr,d|jSt|d�rFd|jSd|jSntj|�rnd|jStj|�r�d|jj	|jj|jfStj
|�r�d|jj	|jj|jfStj|�r�d|jStj|�rd	|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�rsr8r��__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!rar<r�)rr�rDr��nZ
nextmodulerr�rrr�locates &	

r�cCs|t|t�rGt||�}|dkr=td|��n||fSt|dd�}|t|t�rq|ndfSdS)zDGiven an object or a path to an object, get the object and its name.Nz$no Python documentation found for %rr%)r�r;r�r�r<)r�r�rr(rrr�resolve5s
r�z Python Library Documentation: %scCs0|dkrt}nt||�\}}t|�}tj|�}|r{d|kr{|d|d|jd��7}n&|r�||k	r�|d|j7}ntj|�p�tj|�p�tj	|�p�tj
|�p�tj|�p�t|t
�st|�}|d7}n||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(r�r�rrr�
render_doc@s$	$
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"Ys r"cCs�y~t||�\}}tjt|�tj||��}t|dddd�}|j|�|j�td|d�Wn5t	t
fk
r�}zt|�WYdd}~XnXdS)z<Write HTML documentation to a file in the current directory.z.htmlr�r�zutf-8ZwroteN)r��htmlrr�r�r�r�r�r�r�r�)r�r�rr(rr�rHrrr�writedocds$

r�rcCsL|dkri}nx0tj|g|�D]\}}}t|�q+WdS)zAWrite out HTML documentation for all modules in a directory tree.N)r>�
walk_packagesr�)r�pkgpath�donerIr'rJrrr�	writedocsps
	%r�c@seZdZi!dd6dd6dd6dd6dd6d5d	6d6d
6d7d6d8d6d9d6d:d6dd6d;d6dd6dd6d<d6dd6d=d6d>d6d?d6d@d!6d#d$6dAd%6dBd'6dd)6dd*6dCd+6dDd,6dEd.6dFd6dGd/6dHd6dId26ZidJd;6dKdP6dLd#6dMdQ6dNd^6dOd_6dPdb6ZidcdB6ddd?6dedf6dgdh6didj6dkdl6dmdn6d;do6dpdq6drds6dtdu6dvdw6dvdx6dydz6dyd{6Zxdej�D]V\ZZxGeD]?Z	ej
e	e�Zeekr�ed|eZneee	<q�Wq�WiIdQd6dRd;6dSd�6dTd�6dUd�6dVd�6dWd�6dXd�6dYdb6dZd�6d�d�6d[d&6d\d�6d]d�6d^d�6dd�6dd�6d_d�6d`di6dad�6dbd�6dcd 6dd�6ddd�6d�dP6d�d�6ded�6dfd�6dgd6dhd�6did�6djd"6dkd�6dld�6dmd�6dnd�6dod�6d�d�6d�d�6dpd-6dqd�6drd�6dsd�6dtdp6dud�6d�d�6dvd�6dwd�6dxd�6dyd�6dzd�6d{d�6d|d�6d}d�6d~d�6ddd6d�dQ6d�d�6d�d�6d�d_6d�d#6d�d6d	d�6d�d6d�d^6dd6d.d6dd6dd6d�d	6d�d6d�d6d�d6Zdddd�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(��Helperr�False�None�TrueZBOOLEAN�and�with�as�assert�break�	while for�class�CLASSES SPECIALMETHODS�continue�function�def�del�BASICMETHODS�if�elif�else�try�except�finally�for�break continue while�import�from�global�nonlocal NAMESPACES�
TRUTHVALUE�MODULES�in�SEQUENCEMETHODSZ
COMPARISON�is�lambdar��nonlocal�global NAMESPACES�not�or�pass�raise�
EXCEPTIONS�return�while�break continue if TRUTHVALUE� CONTEXTMANAGERS EXCEPTIONS yield�yield�'�'''�r'�b'�"""r�r"�b"ZSTRINGS�+r\�*�**r��//�%�<<�>>r��|�^�~r�r��<=�>=�==�!=�<>�	OPERATORSZUNARY�+=�-=�*=�/=�%=�&=�|=�^=�<<=�>>=�**=�//=�AUGMENTEDASSIGNMENTZBITWISE�j�JZCOMPLEXzOPERATORS FORMATTINGZPOWERzTUPLES LISTS FUNCTIONS�,z ATTRIBUTES FLOAT MODULES OBJECTSr�ELLIPSISz...zSLICINGS DICTIONARYLITERALS�:z	def class�@r�ZPRIVATENAMESr_zPRIVATENAMES SPECIALMETHODSr^Z
BACKQUOTES�`zTUPLES FUNCTIONS CALLSrr+zLISTS SUBSCRIPTS SLICINGS�[�]r��types�RSTRINGS UNICODE NUMBERS SEQUENCES MAPPINGS FUNCTIONS CLASSES MODULES FILES inspect�TYPES�strings�4str UNICODE SEQUENCES STRINGMETHODS FORMATTING TYPES�string-methods�STRINGS FORMATTINGZ
STRINGMETHODS�
formatstringsZ
FORMATTING�:encodings unicode SEQUENCES STRINGMETHODS FORMATTING TYPES�UNICODE�numbers�INTEGER FLOAT COMPLEX TYPESZNUMBERS�integers�	int rangeZINTEGER�floating�
float mathZFLOAT�	imaginary�
complex cmath�typesseq�$STRINGMETHODS FORMATTING range LISTSZ	SEQUENCESZDICTIONARIESZMAPPINGS�typesfunctions�	def TYPES�typesmethods�class def CLASSES TYPESZMETHODS�bltin-code-objects�compile FUNCTIONS TYPESZCODEOBJECTS�bltin-type-objects�types TYPESZTYPEOBJECTSZFRAMEOBJECTSZ
TRACEBACKS�bltin-null-objectZNONE�bltin-ellipsis-object�SLICINGS�specialattrsZSPECIALATTRIBUTES�!class SPECIALMETHODS PRIVATENAMESr�typesmodulesZPACKAGES�operator-summary��lambda or and not in is BOOLEAN COMPARISON BITWISE SHIFTING BINARY FORMATTING POWER UNARY ATTRIBUTES SUBSCRIPTS SLICINGS CALLS TUPLES LISTS DICTIONARIES�EXPRESSIONSZ
PRECEDENCE�objectsZOBJECTS�specialnames�bBASICMETHODS ATTRIBUTEMETHODS CALLABLEMETHODS SEQUENCEMETHODS MAPPINGMETHODS NUMBERMETHODS CLASSESZSPECIALMETHODS�
customization�hash repr str SPECIALMETHODS�attribute-access�ATTRIBUTES SPECIALMETHODSZATTRIBUTEMETHODS�callable-types�CALLS SPECIALMETHODSZCALLABLEMETHODS�sequence-types�(SEQUENCES SEQUENCEMETHODS SPECIALMETHODS�MAPPINGS SPECIALMETHODSZMAPPINGMETHODS�
numeric-types�*NUMBERS AUGMENTEDASSIGNMENT SPECIALMETHODS�
NUMBERMETHODS�	execmodel�%NAMESPACES DYNAMICFEATURES EXCEPTIONSZ	EXECUTION�naming�3global nonlocal ASSIGNMENT DELETION DYNAMICFEATURESZ
NAMESPACES�dynamic-featuresZDYNAMICFEATURESZSCOPINGZFRAMESr��try except finally raise�conversionsZCONVERSIONS�identifiers�keywords SPECIALIDENTIFIERSZIDENTIFIERS�
id-classesZSPECIALIDENTIFIERS�atom-identifiers�
atom-literals�=STRINGS NUMBERS TUPLELITERALS LISTLITERALS DICTIONARYLITERALSZLITERALSZTUPLES�	exprlists�TUPLES LITERALSZ
TUPLELITERALS�typesseq-mutable�LISTLITERALSZLISTS�lists�LISTS LITERALS�typesmapping�DICTIONARYLITERALSr�DICTIONARIES LITERALS�attribute-references�(getattr hasattr setattr ATTRIBUTEMETHODSZ
ATTRIBUTES�
subscriptionsZ
SUBSCRIPTS�slicings�callsZCALLS�power�unary�binaryZBINARY�shiftingZSHIFTING�bitwise�comparisons�EXPRESSIONS BASICMETHODS�booleans�EXPRESSIONS TRUTHVALUEZ	ASSERTION�
assignmentZ
ASSIGNMENT�	augassignZDELETIONZ	RETURNINGZ	IMPORTINGZCONDITIONAL�compound�for while break continueZLOOPING�truth� if while and or not BASICMETHODS�debugger�pdbZ	DEBUGGING�context-managersZCONTEXTMANAGERSNcCs||_||_dS)N)�_input�_output)r>�inputr�rrrr~#s	zHelper.__init__cCs|jptjS)N)r�rr�)r>rrrr6'szHelper.<lambda>cCs|jptjS)N)r�rr�)r>rrrr6(scCs)tj�dddkr%|�dSdS)Nrr0�?rz<pydoc.Helper instance>)r�stack)r>rrr�__repr__*szHelper.__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__1s

	zHelper.__call__cCs�|jjd�x~y|jd�}|s/PnWnttfk
rKPYnXt|dddd�j�}|j�dkr�Pn|j|�qWdS)	Nrzhelp> rrr�r��quit)r�zquit)	r�r��getliner��EOFErrorr/r�lowerr)r>r�rrrr�>szHelper.interactcCsJ|jtjkrt|�S|jj|�|jj�|jj�SdS)z.Read one line, using input() when appropriate.N)r�rr�r�r�r�r�)r>�promptrrrr�Js


zHelper.getlinecCs�t|�td�krr|j�}|dkr=|j�q�|dkrV|j�q�|dkro|j�q�|dkr�|j�q�|dkr�|j�q�|dd�dkr�|j|j�d	�q�||jkr�|j	|�q�|dkrt
t|�d
�q�||jkr1|j
|�q�||jkrP|j
|�q�|r�t
|d
d|j�q�n/t|t�r�|�nt
|d
d|j�|jjd�dS)Nrr�keywords�symbols�topicsr��zmodules rr�r�r�zHelp on %s:r�r)zTruezFalsezNone)r�rr��listkeywords�listsymbols�
listtopics�listmodulesrr��
showsymbolr"�evalr��	showtopicr�r�r�r�r�r�)r>r�rrrrSs8





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�rrF)r>rrrr�hs	zHelper.intror��Pc		Cs�tt|��}||}t|�|d|}x�t|�D]�}x�t|�D]z}|||}|t|�krT|jj||�||dkr�|jjdd|dt||��q�qTqTW|jjd�qAWdS)Nrr�r)r�sortedr rr�r�)	r>�items�columnsrZcolwr�rowrrrrrrys
4zHelper.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|}n|r�ddl
}ddj|j��d}	|j|	d	�}
|jjd
dj|
��ndS)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��nt|t�r~|j||�S|\}}|jj|}|r�|p�dd|}n||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�rlr�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...

cSsY|r3|dd�dkr3|dd�d}n|jd�dkrUd||<ndS)	N�	z	.__init__z
 (package)rrri����i����)�find)rr'r�r�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)zassertr)zbreakr�)zclassr�)zcontinuer�)r�r)zdelr�)zelser�)zforr�)zglobalr�)zifr�)�importr�)zinr�)zlambda�	FUNCTIONS)znonlocalr�)zpassr)zraiser�)zreturnr�)ztryr�)zwhiler�)�withr�)zyieldr)r�r�r�rrrrr)rr\rrr�rrr	r
r�rrr
r�r�rrrrr)r�r�rrrrr)r\r
)rrrrrrrrrrrr)r	r
r�rrr
)r!r")�typesr+)r-r.)r/r0)r1r)r-r2)r4r5)r6r7)r8r9)r:r;)r<r=)r>r?)r@rA)rBrC)rDrE)rFr)rGrH)rIr)r�rJ)rKr�)rLrM)rOr,)rPrQ)rRrS)rTrU)rVrW)rXrY)rXrZ)r[r\)r^r_)r`ra)rbr)z
exceptionsrc)rdr)rerf)rgr)rhr)rirj)rkrl)rmrn)rorp)rqrr)zdictrs)rtru)rvr�)rwr�)rxrN)ryrN)rzrN)r{rN)r|rN)r}rN)r~r)r�r�)r�r )r�r])r�r�)ztruthr�)r�r�)r�r�) r%r&r[r�Z_symbols_inverser�r�r�Zsymbols_r�r�r�r~r�r�r�r�rr�r�r�r�rr�rr�r�r�r�r�r�r�rrrrr�ws<





	
	
r�c@s+eZdZdZddddd�ZdS)r�z7An interruptible scanner that searches module synopses.NcCs�|r|j�}nd|_i}x�tjD]�}|dkr.d||<|dkri|d|d�q�t|�jp{d}|jd�d}|d|}|j�j|�dkr�|d||�q�q.q.Wx�tj	d|�D]�\}	}}
|jrPn|dkr"|d|d�q�ytj
|	|�}Wntk
rOw�YnX|j}t
|d	�r�y|j|�}
Wn(tk
r�|r�||�nw�YnXttj|
��p�d}t
|d
�r�|j|�}qld}n�tjj|�}y|j�}Wn(tk
r7|r0||�nw�YnX|jrT|jj�dnd}t|dd�}|d|}|j�j|�dkr�||||�q�q�W|r�|�ndS)NF�__main__rrrrz - r��
get_source�get_filenamerV)r�r�rr�r�rUrr�r>r��	_get_specr�r�rsr�rPr�r��StringIOr�r�r�r�r�r�r�r<)r>r�rGZ	completerr��seenr'r(r�rIrJr�r��sourcerr�r�rrrr��sb	
"	
	

	

"zModuleScanner.run)r%r&r[rUr�rrrrr��sr�cCsUdd�}dd�}tj��+tjd�t�j||d|�WdQXdS)zAPrint all the one-line module summaries that contain a substring.cSsH|dd�dkr-|dd�d}nt||o@d|�dS)Nr�z	.__init__z
 (package)z- i����i����)r�)rr'r�rrrr�9szapropos.<locals>.callbackcSsdS)Nr)r'rrrr�=szapropos.<locals>.onerror�ignorer�N)�warnings�catch_warnings�filterwarningsr�r�)rGr�r�rrrr�7s


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)	rrrZ
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�rIr~�handlerr�)r>�portr�rrrr~�s
		z)_start_server.<locals>.DocServer.__init__cs^xM|jsO�j|jj�gggd�\}}}|r|j�qqW|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|�ndS)N)rI�server_activater�)r>rrrr��s	z0_start_server.<locals>.DocServer.server_activateN)r%r&r[r~r�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�r!r��Threadr~�serving�error)r>r�r�)�	threadingrrr~�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�rPr�)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[r~r�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_serverEs8"+"
r�z	text/htmlc
s�G�fdd�dt�}|���fdd���fdd���fdd���fd	d
���fdd��	�fd
d���fdd���fdd���fdd�����������	f	dd�}|jd�r|dd�}n|dkr}tjjtjjt��}tjj||�}t|��}dj|j	��SWdQXn|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>rrrrrr�sz'_url_handler.<locals>._HTMLDoc.filelinkN)r%r&r[rrr)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)rF)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)	rrr�rrrr
rvr!)r�r�namesrr�r)r�rr�
html_index	sz _url_handler.<locals>.html_indexc	
s�g��fdd�}tj��7tjd�dd�}t�j||d|�WdQXdd	�}g}�jd
dd�}x+�D]#\}}|j||�|�q�W|�jd
|dddj|��}d|fS)zSearch results page.csN|dd�dkr-|dd�d}n�j||oCd|f�dS)Nr�z	.__init__z
 (package)z- i����i����)r
)rr'r�)�
search_resultrrr�/	sz3_url_handler.<locals>.html_search.<locals>.callbackr�cSsdS)Nr)r'rrrr�6	sz2_url_handler.<locals>.html_search.<locals>.onerrorr�NcSsd||fS)Nz<a href="%s.html">%s</a>r)r(rrrr�;	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�rxrr(r�r)r�)r�r�html_search*	s 

	 z!_url_handler.<locals>.html_searchcs�tjj|�}tj|��}�j|j��}WdQXd|}�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)	r9r:Zunquoter�r�r�r�rr)r�fpr#Zbodyrr)r�rr�html_getfileH	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�X	sz4_url_handler.<locals>.html_topics.<locals>.bltinlinkz,<big><big><strong>INDEX</strong></big></big>z#ffffffz#7799eeZTopicsz#ee77aa)rr�r�r�rDrr)r�rr�r)r�rr�html_topicsU	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�l	sz6_url_handler.<locals>.html_keywords.<locals>.bltinlinkZKeywordsz#ee77aa)rr�r�r�rDrr)rr�r�r)r�rr�
html_keywordse	s	z#_url_handler.<locals>.html_keywordscs	tj�}t||�}|j|�\}}||jkrHd}nd}�jd|dd�}d�j|�}�j|dd|�}|r�t|j	��}dd	�}�j
||�}�jd
dd|�}nd||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�rr*rr�rrrr!)r�ZbufZhtmlhelprr�r�rr�)r�rr�html_topicpaget	s&		
z$_url_handler.<locals>.html_topicpagecsat|dd�}|dkr9|dkr9td��nt|�}�j||�}||fS)Nr�rr�zcould not find object)r�rlr�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�)r�r�)r�rrrt�	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_errorcs|}|jd�r(|dd�}ny�|dkrI��\}}ny|dkrg��\}}n[|dkr���\}}n=d|kr�|jd�\}}}|d	kr��|�\}}q�|d
kr��|�\}}q�|dkr7y�|�\}}Wq�tk
r3�|�\}}Yq�Xq�|dkr�|dkra��\}}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�rrvr�r�rhz
search?keyzgetfile?keyz	topic?keyzget?keyz
bad pydoc url���)r�index)rr�)rrr�rlrPr)rZ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�rqr	r�dirname�realpathrVr!r��	readlinesr�)rr�r�rZ	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}|r]|j|j�nz�ytd|j�t|�x^|jr�td�}|j	�}|dkr�Pq�|dkr�|j|j�q�t|�q�WWnt
tfk
rt�YnXWd|jr%|j�td�nXndS)	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	
	
	
rcCs%t|t�o$|jtj�dkS)Nr)r�r;r�r	�sep)rNrrr�ispath�	sr
cCs�ddl}Gdd�dt�}dtjkr�tjjtjd�}|tjkrltjj|�ntjjdd�ny�|jtjdd�d�\}}d	}d	}d	}d}xy|D]q\}	}
|	d
kr�d}d}n|	dkr
t	|
�dS|	d
kr%d}|
}n|	dkr�d}q�q�W|rm|dkrYd}nt
|d|�dS|s||�nx�|D]�}t|�r�tjj|�r�t
d|�Pny|t|�r�tjj|�r�t|�}n|r(t|�rtjj|�rt|�q5t|�n
tj|�Wq�tk
rg}zt
|�WYdd}~Xq�Xq�WWnc|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rrrrzbk:p:wFz-bTz-kz-pz-wrzfile %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	)�getoptrPrrr	r�argv�remove�insertr�rr
�existsr�rr�rr�r�rr�r�r�r�r
r	)rrZ	scriptdirZoptsr�ZwritingZstart_serverrr�Zopt�val�argrHr�rrr�cli�	sd%	
	
		


%)rr�)VrUr8rPrTrSraZimportlib._bootstrapr��importlib.machinery�importlib.utilrr�r	r>r�rrr�r�Zurllib.parser9r��collectionsr�reprlibr�	tracebackrrrr$r)r-r/r3r�
IGNORECASEr4r5r:r?rCrOrurvr�r�r�rPr�r�r�r�r�r�rxryr�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!,			
��	>��%V

Zerion Mini Shell 1.0