Hacked By AnonymousFox

Current Path : /opt/alt/python37/lib64/python3.7/idlelib/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/idlelib/__pycache__/help.cpython-37.pyc

B

� f�-�@s�dZddlmZddlmZmZmZmZddlm	Z	ddl
mZmZm
Z
mZddlmZmZddl
mZddlmZGd	d
�d
e�ZGdd�de
�ZGd
d�de�ZGdd�de�Zdd�Zdd�Zedkr�ddlmZedddd�ddlm Z e e�dS)a help.py: Implement the Idle help menu.
Contents are subject to revision at any time, without notice.


Help => About IDLE: display About Idle dialog

<to be moved here from help_about.py>


Help => IDLE Help: Display help.html with proper formatting.
Doc/library/idle.rst (Sphinx)=> Doc/build/html/library/idle.html
(help.copy_strip)=> Lib/idlelib/help.html

HelpParser - Parse help.html and render to tk Text.

HelpText - Display formatted help.html.

HelpFrame - Contain text, scrollbar, and table-of-contents.
(This will be needed for display in a future tabbed window.)

HelpWindow - Display HelpFrame in a standalone window.

copy_strip - Copy idle.html to help.html, rstripping each line.

show_idlehelp - Create HelpWindow.  Called in EditorWindow.help_dialog.
�)�
HTMLParser)�abspath�dirname�isfile�join)�python_version)�Toplevel�Frame�Text�Menu)�
Menubutton�	Scrollbar)�font)�idleConfc@s:eZdZdZdd�Zddd�Zdd�Zd	d
�Zdd�Zd
S)�
HelpParsera~Render help.html into a text widget.

    The overridden handle_xyz methods handle a subset of html tags.
    The supplied text should have the needed tag configurations.
    The behavior for unsupported tags, such as table, is undefined.
    If the tags generated by Sphinx change, this class, especially
    the handle_starttag and handle_endtags methods, might have to also.
    cCs`tj|dd�||_d|_d|_d|_d|_d|_d|_d|_	d|_
d|_g|_d|_
d|_dS)NT)Zconvert_charrefs�Fr)r�__init__�text�tags�chartags�show�hdrlink�level�pre�hprefix�	nested_dl�
simplelist�toc�header�prevtag)�selfr�r!�1/opt/alt/python37/lib64/python3.7/idlelib/help.pyr3szHelpParser.__init__�cCs0|j|7_|jdkrdndt|j�|_dS)z#Change indent (+1, 0, -1) and tags.rr�lN)r�strr)r Zamtr!r!r"�indentCszHelpParser.indentcCs>d}x|D]\}}|dkr
|}q
Wd}|dkr@|dkr@d|_�n�|dkrZ|dkrZd|_�n�|dkr�|jr�|jd	s�|j�d
d�}|r�|��s�dnd
}�nx|dkr�|dkr�d|_�n^|dkr�|dkr�d|_�nD|dkr�d|_�n2|dk�r|�d�dk�rd
}d|_nd|_|��n�|dk�r2|j	d	k�rd|_
n�|dk�rN|j�rHdnd}n�|dk�rp|j
�sddnd
}d|_
n�|dk�r�|��d
}n�|dk�r�d|_|j�r�|j�dd�d|_
nZ|dk�r�|dk�r�d|_n>|dk�r�||_
n,|d k�r|j�r
d|_|j�dd�||_
|j�r0|j�d||j
|jf�d|f|_d!S)"zHandle starttags in help.html.r�classZdivZsectionTZ
sphinxsidebarF�przend-1c linestartzend-1cz

�
�spanrZversionmodified�em)�ul�olZsimple���ZdlZliz
* z

* Zdt�dd�end�preblock�aZ
headerlink�h1)�h2�h3N)rrr�get�isspacer�findrr&rrr�insertrrr)r �tagZattrsZclass_r2�v�sZlastliner!r!r"�handle_starttagHsh













zHelpParser.handle_starttagcCs�|dkr^|jdkst�|jrV|dkr(dn|dkr4dnd}|j�||j|j�d�f�d|_nH|d	krnd|_	n8|d
kr~d|_
n(|dkr�d|_d|_n|d
kr�|�d�d|f|_
dS)zHandle endtags in help.html.)r3r4r5rr5z        r4z    rr9)r*r+r2Fr)r,r/r-r.N)r�AssertionErrorrr�appendrr�indexrrrrr&r)r r:r&r!r!r"�
handle_endtag�s$
zHelpParser.handle_endtagcCs�|jr�|js�|jr|n
|�dd�}|jdkr`y|d|�d��|_Wntk
r^d|_YnX|jdkr�|jdkr�|dt|j��|jkr�|t|j�d�}|j	|�
�7_	|j�d||j|j
f�dS)	z"Handle date segments in help.html.r)� r3rr)r3r4r5Nr0)rrr�replacerr@r�
ValueError�lenr�striprr9r)r �data�dr!r!r"�handle_data�s


zHelpParser.handle_dataN)r#)	�__name__�
__module__�__qualname__�__doc__rr&r=rArIr!r!r!r"r*s
:rc@s eZdZdZdd�Zdd�ZdS)�HelpTextzDisplay help.html.c	
Csvtjddddd�}tjddddd�}d|d}tj||d	d
dd
||d�|�d
ddg�}|�dddg�}|df|d<|jd|ddfd�|jd|ddfd�|jd|ddfd�|jd|ddfd�|jd|dfd d!�|jd"|d#fd$d%d&d'd(�|jd)d$d$d*�|jd+d,d,d*�|jd-d.d.d*�|jd/d0d0d*�t|�|_t|d1d2��}|�	�}Wd3QRX|j�
|�d4|d5<d3S)6z'Configure tags and feed file to parser.�mainZEditorWindow�width�int)�type�height��Zwordr�)ZwrapZhighlightthicknessZpadx�borderwidthrPrSZ
TkDefaultFontZarialZ	helveticaZTkFixedFontZmonacoZcourier�rr+Zitalic)rr3�Zboldr4�r5�rz#f6f6ff)r�
backgroundr1�
�r#Zsolidz#eeffcc)r�lmargin1rWZreliefr\�l1)r_Zlmargin2�l2�2�l3�K�l4�dzutf-8)�encodingNZdisabled�state)rZ	GetOptionr
r�findfontZ
tag_configurer�parser�open�readZfeed)	r �parent�filenameZuwideZuhighZ
normalfontZ	fixedfont�f�contentsr!r!r"r�s0
zHelpText.__init__cCsnxh|D]`}|��dd�tj|d�D�krDtj|d|d�}|��dS|��dd�tj|d�D�kr|SqWdS)	z4Return name of first font family derived from names.css|]}|��VqdS)N)�lower)�.0�xr!r!r"�	<genexpr>�sz$HelpText.findfont.<locals>.<genexpr>)�rootT)�name�existsruZfamilycss|]}|��VqdS)N)rq)rrrsr!r!r"rt�sN)rq�tkfont�namesZFontZactualZfamilies)r ryrvrr!r!r"ri�s
zHelpText.findfontN)rJrKrLrMrrir!r!r!r"rN�srNc@s eZdZdZdd�Zdd�ZdS)�	HelpFramez&Display html text, scrollbar, and toc.cCs�t�||�t||�|_}|d|d<|�|�|_}t||jd�|_}|j	|d<|j
ddd�|jddd�|jdddd�|jddd	d�|jdd
dd�dS)Nr\)�commandZyscrollcommandrr#)�weightZnw)�row�column�sticky�nsew��ns)
r	rrNr�toc_menurr
�yview�scroll�setZrowconfigureZcolumnconfigure�grid)r rmrnrrr�r!r!r"r�s
zHelpFrame.__init__csTt|dd�}t|dd�}x.�jjD]"\}}|j||f�fdd�	d�q"W||d<|S)	z+Create table of contents as drop-down menu.ZTOC)rF)Ztearoffcs
��|�S)N)r�)�dex)rr!r"�<lambda>��z$HelpFrame.toc_menu.<locals>.<lambda>)Zlabelr{Zmenu)rrrjrZadd_command)r rrZdropZlblr�r!)rr"r��szHelpFrame.toc_menuN)rJrKrLrMrr�r!r!r!r"rz�srzc@seZdZdZdd�ZdS)�
HelpWindowz!Display frame with rendered html.cCsZt�||�|�|�|�d|j�t||�jdddd�|jddd�|jddd�dS)NZWM_DELETE_WINDOWrr�)r~r}rr#)r|)	rrZwm_titleZprotocolZdestroyrzr�Zgrid_columnconfigureZgrid_rowconfigure)r rmrn�titler!r!r"r�s
zHelpWindow.__init__N)rJrKrLrMrr!r!r!r"r��sr�c
Cs�tttttt����ddddd�}tttt��d�}t|d��<}t|d��&}x|D]}|�|��d	�qRWWd
QRXWd
QRXt|�d|���d
S)a^Copy idle.html to idlelib/help.html, stripping trailing whitespace.

    Files with trailing whitespace cannot be pushed to the git cpython
    repository.  For 3.x (on Windows), help.html is generated, after
    editing idle.rst on the master branch, with
      sphinx-build -bhtml . build/html
      python_d.exe -c "from idlelib.help import copy_strip; copy_strip()"
    Check build/html/library/idle.html, the help.html diff, and the text
    displayed by Help => IDLE Help.  Add a blurb and create a PR.

    It can be worthwhile to occasionally generate help.html without
    touching idle.rst.  Changes to the master version and to the doc
    build system may result in changes that should not changed
    the displayed text, but might break HelpParser.

    As long as master and maintenance versions of idle.rst remain the
    same, help.html can be backported.  The internal Python version
    number is not displayed.  If maintenance idle.rst diverges from
    the master version, then instead of backporting help.html from
    master, repeat the procedure above to generate a maintenance
    version.
    ZDocZbuildZhtmlZlibraryz	idle.htmlz	help.html�rb�wb�
Nz copied to )rrr�__file__rk�write�rstrip�print)�src�dstZinn�out�liner!r!r"�
copy_strip�s
*r�cCs4tttt��d�}t|�sdSt||dt��dS)z7Create HelpWindow; called from Idle Help event handler.z	help.htmlNzIDLE Help (%s))rrrr�rr�r)rmrnr!r!r"�
show_idlehelpsr��__main__)rOzidlelib.idle_test.test_helpr�F)�	verbosity�exit)�runN)!rMZhtml.parserrZos.pathrrrr�platformrZtkinterrr	r
rZtkinter.ttkrr
rrxZidlelib.configrrrNrzr�r�r�rJZunittestrOZidlelib.idle_test.htestr�r!r!r!r"�<module>s$~* 

Hacked By AnonymousFox1.0, Coded By AnonymousFox