Ϫf#BdZd dZdZdZd dZeZdZdZdZd dZ y ) z' Miscellany of text-munging functions. c fd}g}t|turd}|jD]{\}}t||dz}t |r4t |r|dt d }|j|d|d|T|j|d|d|t |d zd}nt|tust|turOt|turd }nd }|D]3}t||dz}|j|jd z5n*t|fd t|jd|dd|s|j||r.||dz|dt |dzdz|d<|d|dz|d<dj|}t |rt |s|dz}|S)al Expansive string formatting for sequence types. C{list.__str__} and C{dict.__str__} use C{repr()} to display their elements. This function also turns these sequence types into strings, but uses C{str()} on their elements instead. Sequence elements are also displayed on separate lines, and nested sequences have nested indentation. z{}z N  z: z: z()z[],c ||zSN)sis 5/usr/lib/python3/dist-packages/twisted/python/text.pyzstringyString../s QU)typedictitems stringyString isMultiline endsInNewlinelenappendtuplelistrstripmapstrsplitjoin)object indentationbracesslkeyvalueelementr s r rr sF B F|t ,,. SJC!%u)<=E5! '!,SYJ/E [M3%s5':; [M3%r%K8H18L8N2O1PQR S f $v,$"6 <5 FF .G#G[3->?G IIgnn&, - . 2CK4E4Ed4KL1  + fQi'"Q%K0@10D0F*GG1B&*$2 " A1~mA. H Hrc*|jddk7S)z= Returns C{True} if this string has a newline in it. rr)findr s r rr@s 66$<2 rc&|td ddk(S)z; Returns C{True} if this string ends in a newline. rN)rr+s r rrGs c$iZ\?d ""rcg}|jddk\r9|jd}|D]!}|jt||dgz#|S|j}d}d}|r|t ||z}|dz}||kDr:|dk(rn|dz }|d|||d}}|j dj |d}d}n9t ||kDs&|j dj ||dd=n|dz}|r|S)a Given a string and a column width, return a list of lines. Caveat: I'm use a stupid greedy word-wrapping algorythm. I won't put two spaces at the end of a sentence. I don't do full justification. And no, I've never even *heard* of hypenation. z rrrNr)r*r extend greedyWraprrr!) inStringwidthoutLines paragraphsparainWordscolumnptr_linels r r/r/NsH}}V!^^F+  1}$a<#Ah/1CQ OOCHHQK (HFg,) OOCHHW- . aZF- 2 Orc`g}|D]&}|s|js|j|(|Sr )stripr)linesretlines r removeLeadingBlanksr>s4 C $**, JJt  Jrct|jd}|jt|}|jdj|dzS)Nr)r>r reverser!)r r;s r removeLeadingTrailingBlanksrAsD  .E MMO  &E MMO 99U d ""rc:g}d}d}|jD]}||r|ddvr |d}|dd}g}||j|.|rA|d|k(r9|dd}|j||jdj|d}q|j||S)a= Like a string split, but don't break substrings inside quotes. >>> splitQuoted('the "hairy monkey" likes pie') ['the', 'hairy monkey', 'likes', 'pie'] Another one of those "someone must have a better solution for this" things. This implementation is a VERY DUMB hack done too quickly. Nr)"'rrr)r rr!)r outquotphrasewords r splitQuotedrIs C D F $ >aJ.AwABx > JJt bT)CRy d# 388F+, d#!$$ Jrcft|}tt|d}|s|j} |j |t|z }|s|j}t|}|dk(ryt||z|z }|dkr||z}n||d|z}|j |dk7ryz)z[ Find whether string C{p} occurs in a read()able object C{f}. @rtype: C{bool} irFNrT)rmaxrlowerreadr*)pf caseSensitivebufbuf_lenr bytes_readr8s r strFilerUs $q')C#a&*%G  GGI FF7SV# $ AV ? Hz !G + 6'Cab'A+C 88A;"  rN)r)P)T) __doc__rrrr/wordWrapr>rArIrUr rr rYs<  2 j#/d # Fr