%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python2.7/idlelib/
Upload File :
Create Path :
Current File : //usr/local/lib/python2.7/idlelib/FormatParagraph.pyo

ó
Pêáac@s£dZddlZddlmZddd„ƒYZd„Zd„Zd„Zd	„Zd
„Z	d„Z
edkrŸddlZej
d
dddeƒndS(sÐExtension 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 :-)
iÿÿÿÿN(tidleConftFormatParagraphcBs8eZddgfgZd„Zd„Zdd„ZRS(tformatsFormat Paragraphs<<format-paragraph>>cCs
||_dS(N(teditwin(tselfR((s3/usr/local/lib/python2.7/idlelib/FormatParagraph.pyt__init__scCs
d|_dS(N(tNoneR(R((s3/usr/local/lib/python2.7/idlelib/FormatParagraph.pytclose sc	CsS|d
kr0tjdddddddƒ}n|jj}|jjƒ\}}|r~|r~|j||ƒ}t|ƒ}n$t||j	dƒƒ\}}}}|r½t
|||ƒ}nt||ƒ}|jd	d
dƒ||kr2|j
d|ƒ|jƒ|j||ƒ|j||ƒ|jƒn|j
d|ƒ|jdƒdS(sÕ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.
        t
extensionsRs	max-widthttypetinttdefaultiHtinserttsels1.0tendtbreakN(RRt	GetOptionRttexttget_selection_indicestgettget_comment_headertfind_paragraphtindextreformat_commenttreformat_paragrapht
tag_removetmark_settundo_block_starttdeleteRtundo_block_stoptsee(	RteventtlimitRtfirsttlasttdatatcomment_headertnewdata((s3/usr/local/lib/python2.7/idlelib/FormatParagraph.pytformat_paragraph_event#s.$


(sFormat Paragraphs<<format-paragraph>>N(t__name__t
__module__tmenudefsRRRR&(((s3/usr/local/lib/python2.7/idlelib/FormatParagraph.pyRs
		c
Cs¦tt|jdƒƒ\}}|jd|d|ƒ}xM|jd|ddƒr‡t|ƒr‡|d}|jd|d|ƒ}q;W|}t|ƒ}t|ƒ}xKt|ƒ|krót||ƒró|d}|jd|d|ƒ}q©Wd|}|d}|jd|d|ƒ}xW|dkr{t|ƒ|kr{t||ƒr{|d}|jd|d|ƒ}q%Wd|d}	|	|||j|	|ƒfS(s»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.
    t.s%d.0s%d.endt<Rii(tmapR
tsplitRtcomparetis_all_whiteRtlen(
Rtmarktlinenotcoltlinetfirst_linenoR$tcomment_header_lenR"R!((s3/usr/local/lib/python2.7/idlelib/FormatParagraph.pyRMs,(




cCs÷|jdƒ}d}t|ƒ}x*||krMt||ƒrM|d}q$W||kr^|St||ƒ}|d|krªt||dƒrªt||dƒ}n|}|| }|}x||krÅt||ƒrÅtjd||ƒ}	x¿tdt|	ƒdƒD]¥}
|	|
}|s+qnt||jƒƒ|kro||kro|j|jƒƒ|}n||d}|
dt|	ƒkr|	|
ddkr|d}qqW|d}qÃW|j|jƒƒ|j	||ƒdj
|ƒS(s3Return data reformatted to specified width (limit).s
iis(\s+)it (R-R0R/t
get_indenttretranget
expandtabstappendtrstriptextendtjoin(R#R tlinestitntindent1tindent2tnewtpartialtwordstjtword((s3/usr/local/lib/python2.7/idlelib/FormatParagraph.pyRrs<%
 
	*cs¯tˆƒ‰dj‡fd†|jdƒDƒƒ}t|tˆƒdƒ}t||ƒ}|jdƒ}d}|dsŽd}|d }ndj‡fd†|Dƒƒ|S(s?Return data reformatted to specified width with comment header.s
c3s|]}|ˆVqdS(N((t.0R4(tlc(s3/usr/local/lib/python2.7/idlelib/FormatParagraph.pys	<genexpr>›sitiÿÿÿÿc3s|]}ˆ|VqdS(N((RJR4(R$(s3/usr/local/lib/python2.7/idlelib/FormatParagraph.pys	<genexpr>ªs(R0R?R-tmaxR(R#R R$tformat_widthR%tblock_suffix((R$RKs3/usr/local/lib/python2.7/idlelib/FormatParagraph.pyR–s(

cCstjd|ƒdk	S(s/Return True if line is empty or all whitespace.s^\s*$N(R9tmatchR(R4((s3/usr/local/lib/python2.7/idlelib/FormatParagraph.pyR/¬scCstjd|ƒjƒS(s/Return the initial space or tab indent of line.s	^([ \t]*)(R9RPtgroup(R4((s3/usr/local/lib/python2.7/idlelib/FormatParagraph.pyR8±scCs/tjd|ƒ}|dkr"dS|jdƒS(sReturn 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.
    s^([ \t]*#*)RLiN(R9RPRRQ(R4tm((s3/usr/local/lib/python2.7/idlelib/FormatParagraph.pyRµst__main__s&idlelib.idle_test.test_formatparagrapht	verbosityitexit((t__doc__R9tidlelib.configHandlerRRRRRR/R8RR'tunittesttmaintFalse(((s3/usr/local/lib/python2.7/idlelib/FormatParagraph.pyt<module>s8	%	$				

Zerion Mini Shell 1.0