nfc@sdZdZddlZddlZy eZWn'ek rWdefdYZnXdddd gZd Z dfd YZ d d Z d dZ ej dejZej dejZdZedkredGHndS(sText wrapping and filling. s$Id$iNt_unicodecBseZRS((t__name__t __module__(((s /usr/lib64/python2.7/textwrap.pyRst TextWrappertwraptfilltdedents c BseZdZejedeeZiZe dZ x!e e eD]Z e ee string Munge whitespace in text: expand tabs and convert all other whitespace characters to spaces. Eg. " foo bar baz" becomes " foo bar baz". ( R t expandtabsR t isinstancetstrt translatetwhitespace_transRtunicode_whitespace_trans(Rttext((s /usr/lib64/python2.7/textwrap.pyt_munge_whitespaces  cCspt|tr0|jr$|j}qN|j}n|jrE|j}n |j}|j|}td|}|S(sN_split(text : string) -> [string] Split the text to wrap into indivisible chunks. Chunks are not quite the same as words; see _wrap_chunks() for full details. As an example, the text Look, goof-ball -- use the -b option! breaks into the following chunks: 'Look,', ' ', 'goof-', 'ball', ' ', '--', ' ', 'use', ' ', 'the', ' ', '-b', ' ', 'option!' if break_on_hyphens is True, or in: 'Look,', ' ', 'goof-ball', ' ', '--', ' ', 'use', ' ', 'the', ' ', '-b', ' ', option!' otherwise. N( RRRRRRRtsplittfiltertNone(RR"tpattchunks((s /usr/lib64/python2.7/textwrap.pyt_splits      cCs|d}|jj}xc|t|dkrw||ddkrj|||rjd||d<|d7}q|d7}qWdS(sf_fix_sentence_endings(chunks : [string]) Correct for sentence endings buried in 'chunks'. Eg. when the original text contains "... foo. Bar ...", munge_whitespace() and split() will convert that to [..., "foo.", " ", "Bar", ...] which has one too few spaces; this method simply changes the one space to two. iiRs iN(tsentence_end_retsearchtlen(RR(tit patsearch((s /usr/lib64/python2.7/textwrap.pyt_fix_sentence_endingss  $ cCsr|dkrd}n ||}|jrR|j|d| |d||d [string] Wrap a sequence of text chunks and return a list of lines of length 'self.width' or less. (If 'break_long_words' is false, some lines may be longer than this.) Chunks correspond roughly to words and the whitespace between them: each chunk is indivisible (modulo 'break_long_words'), but a line break can come between any two chunks. Chunks should not have internal whitespace; ie. a chunk is either all whitespace or a "word". Whitespace chunks will be removed from the beginning and end of lines, but apart from that whitespace is preserved. isinvalid width %r (must be > 0)iR( R t ValueErrortreverseR R R,RtstripR0R1R6tjoin(RR(tlinesR3R4tindentR tl((s /usr/lib64/python2.7/textwrap.pyt _wrap_chunkss4     %   % !cCsD|j|}|j|}|jr7|j|n|j|S(s^wrap(text : string) -> [string] Reformat the single paragraph in 'text' so it fits in lines of no more than 'self.width' columns, and return a list of wrapped lines. Tabs in 'text' are expanded with string.expandtabs(), and all other whitespace characters (including newline) are converted to space. (R#R)RR/R>(RR"R(((s /usr/lib64/python2.7/textwrap.pyR<s  cCsdj|j|S(sfill(text : string) -> string Reformat the single paragraph in 'text' to fit in lines of no more than 'self.width' columns, and return a new string containing the entire wrapped paragraph. s (R:R(RR"((s /usr/lib64/python2.7/textwrap.pyRKs(RRt__doc__tstringt maketranst _whitespaceR,R R!tordtuspacetmaptxRRRRt lowercaseR*tTruetFalseRR#R)R/R6R>RR(((s /usr/lib64/python2.7/textwrap.pyR(s6(         ! I iFcKstd||}|j|S(sWrap a single paragraph of text, returning a list of wrapped lines. Reformat the single paragraph in 'text' so it fits in lines of no more than 'width' columns, and return a list of wrapped lines. By default, tabs in 'text' are expanded with string.expandtabs(), and all other whitespace characters (including newline) are converted to space. See TextWrapper class for available keyword args to customize wrapping behaviour. R (RR(R"R tkwargstw((s /usr/lib64/python2.7/textwrap.pyRWs cKstd||}|j|S(sFill a single paragraph of text, returning a new string. Reformat the single paragraph in 'text' to fit in lines of no more than 'width' columns, and return a new string containing the entire wrapped paragraph. As with wrap(), tabs are expanded and other whitespace characters converted to space. See TextWrapper class for available keyword args to customize wrapping behaviour. R (RR(R"R RJRK((s /usr/lib64/python2.7/textwrap.pyRds s^[ ]+$s(^[ ]*)(?:[^ ])cCsd}tjd|}tj|}xT|D]L}|dkrI|}q.|j|r[q.|j|rs|}q.d}Pq.Wdr|rxF|jdD]2}| s|j|std||fqWn|rtjd|d|}n|S(s9Remove any common leading whitespace from every line in `text`. This can be used to make triple-quoted strings line up with the left edge of the display, while still presenting them in the source code in indented form. Note that tabs and spaces are both treated as whitespace, but they are not equal: the lines " hello" and " hello" are considered to have no common leading whitespace. (This behaviour is new in Python 2.5; older versions of this module incorrectly expanded tabs before searching for common leading whitespace.) Ris sline = %r, margin = %rs(?m)^N( R&t_whitespace_only_retsubt_leading_whitespace_retfindallt startswithR$tAssertionErrorR(R"tmargintindentsR<tline((s /usr/lib64/python2.7/textwrap.pyRvs&     t__main__s Hello there. This is indented.(R?t __revision__R@RtunicodeRt NameErrortobjectt__all__RBRRRRt MULTILINERLRNRR(((s /usr/lib64/python2.7/textwrap.pyts"    0  0