Hacked By AnonymousFox

Current Path : /proc/thread-self/root/opt/alt/python36/lib64/python3.6/idlelib/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python36/lib64/python3.6/idlelib/__pycache__/paragraph.cpython-36.pyc

3

� f��@s�dZddlZddlmZGdd�d�Zej�dd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zedkr�ddl
mZedddd�dS)a�Format a paragraph, comment block, or selection to a max width.

Does basic, standard text formatting, and also understands Python
comment blocks. Thus, for editing Python source code, this
extension is really only suitable for reformatting these comment
blocks or triple-quoted strings.

Known problems with comment reformatting:
* If there is a selection marked, and the first line of the
  selection is not complete, the block will probably not be detected
  as comments, and will have the normal "text formatting" rules
  applied.
* If a comment block has leading whitespace that mixes tabs and
  spaces, they will not be considered part of the same block.
* Fancy comments, like this bulleted list, aren't handled :-)
�N)�idleConfc@s2eZdZdd�Zedd��Zdd�Zd
dd	�ZdS)�FormatParagraphcCs
||_dS)N)�editwin)�selfr�r�6/opt/alt/python36/lib64/python3.6/idlelib/paragraph.py�__init__szFormatParagraph.__init__cCstjdddddd�|_dS)N�
extensionsrz	max-width�int�H)�type�default)rZ	GetOption�	max_width)�clsrrr�reloadszFormatParagraph.reloadcCs
d|_dS)N)r)rrrr�close szFormatParagraph.closeNc	Cs�|dkr|jn|}|jj}|jj�\}}|rF|rF|j||�}t|�}nt||jd��\}}}}|rpt|||�}n
t	||�}|j
ddd�||kr�|jd|�|j�|j
||�|j||�|j�n|jd|�|jd�dS)a�Formats paragraph to a max width specified in idleConf.

        If text is selected, format_paragraph_event will start breaking lines
        at the max width, starting from the beginning selection.

        If no text is selected, format_paragraph_event uses the current
        cursor location to determine the paragraph (lines of text surrounded
        by blank lines) and formats it.

        The length limit parameter is for testing with a known value.
        N�insertZselz1.0�end�break)rr�textZget_selection_indices�get�get_comment_header�find_paragraph�index�reformat_comment�reformat_paragraphZ
tag_removeZmark_setZundo_block_start�deleterZundo_block_stopZsee)	rZevent�limitr�first�last�data�comment_header�newdatarrr�format_paragraph_event#s(



z&FormatParagraph.format_paragraph_event)N)�__name__�
__module__�__qualname__r�classmethodrrr#rrrrrsrc
CsJtt|jd��\}}|jd|d|�}x:|jd|dd�rbt|�rb|d}|jd|d|�}q*W|}t|�}t|�}x>t|�|kr�t||d��r�|d}|jd|d|�}qzWd|}|d}|jd|d|�}xL|dk�r(t|�|k�r(t||d���r(|d}|jd|d|�}q�Wd|d}	|	|||j|	|�fS)	z�Returns the start/stop indices enclosing the paragraph that mark is in.

    Also returns the comment format string, if any, and paragraph of text
    between the start/stop indices.
    �.z%d.0z%d.end�<r�Nr)�mapr
�splitrZcompare�is_all_whiter�len)
rZmark�lineno�col�lineZfirst_linenor!Zcomment_header_lenrrrrrrLs,rcCs�|jd�}d}t|�}x ||kr6t||�r6|d}qW||krD|St||�}|d|kr�t||d�r�t||d�}n|}|d|�}|}x�||ko�t||��rTtjd||�}	x�tdt|	�d�D]v}
|	|
}|s�q�t||j��|ko�||k�r|j|j��|}||d}|
dt|	�kr�|	|
ddkr�|d}q�W|d}q�W|j|j��|j	||d��dj
|�S)z3Return data reformatted to specified width (limit).�
rr*Nz(\s+)�� )r,r.r-�
get_indent�re�range�
expandtabs�append�rstrip�extend�join)r r�lines�i�nZindent1Zindent2�new�partialZwords�jZwordrrrrqs<

 rcs�t���dj�fdd�|jd�D��}t|t��d�}t||�}|jd�}d}|d	shd}|dd
�}dj�fdd�|D��|S)z?Return data reformatted to specified width with comment header.r2c3s|]}|�d�VqdS)Nr)�.0r1)�lcrr�	<genexpr>�sz#reformat_comment.<locals>.<genexpr>��r*Nc3s|]}�|VqdS)Nr)rCr1)r!rrrE�s���rH)r.r<r,�maxr)r rr!Zformat_widthr"Zblock_suffixr)r!rDrr�s

rcCstjd|�dk	S)z/Return True if line is empty or all whitespace.z^\s*$N)r6�match)r1rrrr-�sr-cCstjd|�j�S)z/Return the initial space or tab indent of line.z	^([ \t]*))r6rJ�group)r1rrrr5�sr5cCs"tjd|�}|dkrdS|jd�S)aReturn string with leading whitespace and '#' from line or ''.

    A null return indicates that the line is not a comment line. A non-
    null return, such as '    #', will be used to find the other lines of
    a comment block with the same  indent.
    z^([ \t]*#*)NrGr*)r6rJrK)r1�mrrrr�sr�__main__)�mainz idlelib.idle_test.test_paragraphr3F)�	verbosity�exit)�__doc__r6Zidlelib.configrrrrrrr-r5rr$ZunittestrNrrrr�<module>s4%$

Hacked By AnonymousFox1.0, Coded By AnonymousFox