File "FormatParagraph.cpython-34.pyc"

Full Path: /home/attunedd/public_html/byp/izo/con7ext_sym404/rintoar.txt/opt/alt/python34/lib64/python3.4/idlelib/__pycache__/FormatParagraph.cpython-34.pyc
File size: 6.22 KB
MIME-type: text/x-bytecode.python
Charset: 8 bit


f fw@sdZddlZddlmZGdddZddZdd	Zd
dZdd
ZddZ	ddZ
edkrddlZej
dddddndS)aExtension to format a paragraph 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@sIeZdZddgfgZddZddZdd	d
ZdS)FormatParagraphformatFormat Paragraph<<format-paragraph>>cCs
||_dS)N)editwin)selfrr	</opt/alt/python34/lib64/python3.4/idlelib/FormatParagraph.py__init__szFormatParagraph.__init__cCs
d|_dS)N)r)rr	r	r
close szFormatParagraph.closeNc	CsS|dkr0tjddddddd}n|jj}|jj\}}|r~|r~|j||}t|}n$t||jd	\}}}}|rt	|||}nt
||}|jd
dd||kr2|jd	||j
|j|||j|||jn|jd	||jd	d
S)aFormats 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
extensionsrz	max-widthtypeintdefaultHinsertZselz1.0endbreak)rZ	GetOptionrtextZget_selection_indicesgetget_comment_headerfind_paragraphindexreformat_commentreformat_paragraphZ
tag_removeZmark_setZundo_block_startZdeleterZundo_block_stopZsee)	rZeventlimitrfirstlastdatacomment_headernewdatar	r	r
format_paragraph_event#s.$


z&FormatParagraph.format_paragraph_event)rr)__name__
__module____qualname__Zmenudefsrrr"r	r	r	r
rs
rc
Cstt|jd\}}|jd|d|}xM|jd|ddrt|r|d}|jd|d|}q;W|}t|}t|}xQt||krt||dr|d}|jd|d|}qWd|}|d}|jd|d|}x]|dkrt||krt||dr|d}|jd|d|}q+Wd|d}	|	|||j|	|fS)	zReturns 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<rNr)maprsplitrZcompareis_all_whiterlen)
rmarklinenocollineZfirst_linenor Zcomment_header_lenrrr	r	r
rMs,(




rcCs|jd}d}t|}x*||krMt||rM|d}q$W||kr^|St||}|d|krt||drt||d}n|}|d|}|}x||krt||rtjd||}	xtdt|	dD]}
|	|
}|s1qnt||j|kru||kru|j|j|}n||d}|
dt|	kr|	|
ddkr|d}qqW|d}qW|j|j|j	||ddj
|S)z3Return data reformatted to specified width (limit).
rr(Nz(\s+) )r*r,r+
get_indentrerange
expandtabsappendrstripextendjoin)rrlinesinZindent1Zindent2newpartialZwordsjZwordr	r	r
rrs<% 
	*rcstdjfdd|jdD}t|td}t||}|jd}d}|d	sd}|dd
}ndjfdd|D|S)z?Return data reformatted to specified width with comment header.r1c3s|]}|dVqdS)Nr	).0r0)lcr	r
	<genexpr>sz#reformat_comment.<locals>.<genexpr>r(Nc3s|]}|VqdS)Nr	)rBr0)r r	r
rDsrG)r,r;r*maxr)rrr Zformat_widthr!Zblock_suffixr	)r rCr
rs+
rcCstjd|dk	S)z/Return True if line is empty or all whitespace.z^\s*$N)r5match)r0r	r	r
r+sr+cCstjd|jS)z/Return the initial space or tab indent of line.z	^([ \t]*))r5rIgroup)r0r	r	r
r4sr4cCs/tjd|}|dkr"dS|jdS)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]*#*)NrFr()r5rIrJ)r0mr	r	r
rsr__main__z&idlelib.idle_test.test_formatparagraph	verbosityr2exitF)__doc__r5Zidlelib.configHandlerrrrrrr+r4rr#Zunittestmainr	r	r	r
<module>s8%$