B XӴ@sddlZddddddgZdZGd ddZdd dZdd dZd dZedejZ edejZ ddZ dddZ e dkree ddS)N TextWrapperwrapfilldedentindentshortenz c @seZdZiZedZxeD]Zeeee<qWdZdZ de eZ de ddZ e dee e e d e jZ[[ [ e d e Z[ e d Zd%dddddZddZddZddZddZddZdd Zd!d"Zd#d$ZdS)&r z [\w!"\'&.,?]z[^\d\W]z[%s]z[^Na ( # any whitespace %(ws)s+ | # em-dash between words (?<=%(wp)s) -{2,} (?=\w) | # word, possibly hyphenated %(nws)s+? (?: # hyphenated word -(?: (?<=%(lt)s{2}-) | (?<=%(lt)s-%(lt)s-)) (?= %(lt)s -? %(lt)s) | # end of word (?=%(ws)s|\Z) | # em-dash (?<=%(wp)s) (?=-{2,}\w) ) ))ZwpltZwsZnwsz(%s+)z[a-z][\.\!\?][\"\']?\ZFTFz [...]) max_lines placeholderc  CsL||_||_||_||_||_||_||_||_| |_| |_ | |_ | |_ dS)N) widthinitial_indentsubsequent_indent expand_tabsreplace_whitespacefix_sentence_endingsbreak_long_wordsdrop_whitespacebreak_on_hyphenstabsizerr) selfrrrrrrrrrrrrr+/opt/alt/python37/lib/python3.7/textwrap.py__init__sszTextWrapper.__init__cCs(|jr||j}|jr$||j}|S)N)r expandtabsrr translateunicode_whitespace_trans)rtextrrr_munge_whitespaces   zTextWrapper._munge_whitespacecCs6|jdkr|j|}n |j|}dd|D}|S)NTcSsg|] }|r|qSrr).0crrr sz&TextWrapper._split..)r wordsep_resplitwordsep_simple_re)rr!chunksrrr_splits   zTextWrapper._splitcCs`d}|jj}xN|t|dkrZ||ddkrP|||rPd||d<|d7}q|d7}qWdS)Nrr rz )sentence_end_researchlen)rr)iZ patsearchrrr_fix_sentence_endingss   z!TextWrapper._fix_sentence_endingscCs^|dkrd}n||}|jrH||dd||d|d|d<n|sZ||dS)Nr )rappendpop)rZreversed_chunkscur_linecur_lenrZ space_leftrrr_handle_long_words zTextWrapper._handle_long_wordc Csg}|jdkrtd|j|jdk rb|jdkr8|j}n|j}t|t|j|jkrbtd|x"|rg}d}|r|j}n|j}|jt|}|j r|d dkr|r|d=x:|rt|d}|||kr| | ||7}qPqW|r.t|d|kr.| ||||ttt|}|j rd|rd|d dkrd|t|d8}|d=|rn|jdkst|d|jks|r|j rt|dkr|d s||kr| |d|qnx|r8|d r|t|j|kr| |j| |d|P|t|d8}|d=qW|rv|d}t|t|j|jkrv||j|d<P| ||jPqnW|S)Nrzinvalid width %r (must be > 0)r z#placeholder too large for max widthr1r )r ValueErrorrrrr.rlstripreverserstripr2r3r6summapjoinrstrip) rr)linesrr4r5rlZ prev_linerrr _wrap_chunkssp              zTextWrapper._wrap_chunkscCs||}||S)N)r"r*)rr!rrr _split_chunksPs zTextWrapper._split_chunkscCs$||}|jr||||S)N)rBrr0rA)rr!r)rrrrVs  zTextWrapper.wrapcCsd||S)N )r=r)rr!rrrrdszTextWrapper.fill) r r r TTFTTTr )__name__ __module__ __qualname__r ordZuspace _whitespacexZ word_punctZletterreescapeZ whitespaceZ nowhitespacecompileVERBOSEr&r(r,rr"r*r0r6rArBrrrrrrrsH1   !gr cKstfd|i|}||S)Nr)rr)r!rkwargswrrrrps cKstfd|i|}||S)Nr)rr)r!rrNrOrrrr}s cKs,tf|dd|}|d|S)Nr )rrr)rrr=r:r')r!rrNrOrrrrs z^[ ]+$z(^[ ]*)(?:[^ ])cCsd}td|}t|}xl|D]d}|dkr2|}q ||r>q ||rN|}q x4tt||D]"\}\}}||kr^|d|}Pq^Wq Wdr|rx|dD]}qW|rtd|d|}|S)Nr rrCz(?m)^) _whitespace_only_resub_leading_whitespace_refindall startswith enumeratezipr'rJ)r!Zmarginindentsrr/rIylinerrrrs(       cs,dkrddfdd}d|S)NcSs|S)N)r:)rYrrr predicateszindent..predicatec3s.x(dD]}|r |n|Vq WdS)NT) splitlines)rY)rZprefixr!rrprefixed_linesszindent..prefixed_linesr )r=)r!r\rZr]r)rZr\r!rrs__main__z Hello there. This is indented.)r )r )N)rJ__all__rHrrrrrL MULTILINErPrRrrrDprintrrrrsa 3