
    h#                     H    S r S
S jrS rS rSS jr\rS rS rS rSS jr	g	)z'
Miscellany of text-munging functions.
c                    Sn/ n[        U 5      [        L a  SnU R                  5        H  u  pE[        XQS-   5      n[	        U5      (       a:  [        U5      (       a  US[        S5      *  nUR                  U SU SU 35        M]  UR                  U SU SU[        U5      S	-   S  35        M     O[        U 5      [        L d  [        U 5      [        L aQ  [        U 5      [        L a  S
nOSnU  H3  n[        XaS-   5      nUR                  UR                  5       S-   5        M5     O+[        U4S j[        U 5      R                  S5      5      USS& U(       d  UR                  U5        U(       a-  XS   -   US   [        U5      S-   S -   US'   US   US   -   US'   SR                  U5      n[	        U5      (       a  [        U5      (       d  US-   nU$ )aP  
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                 
    X-   $ N )sis     Z/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/python/text.py<lambda>stringyString.<locals>.<lambda>/   s    QU           )typedictitemsstringyStringisMultilineendsInNewlinelenappendtuplelistrstripmapstrsplitjoin)objectindentationbracesslkeyvalueelementr   s           r   r   r      s    F	BF|t ,,.JC!%u)<=E5!! ''!,SYJ/E		[M3%s5':; 		[M3%r%K8H18L8N2O1PQR ) 
f	$v,$"6<5 FFG#G3->?GIIgnn&,-  2CK4E4Ed4KL1
		+Qi'"Q%K0@10D0F*GG1B&*$2		"A1~~mA..HHr   c                 *    U R                  S5      S:g  $ )z5
Returns C{True} if this string has a newline in it.
r   r   )findr   s    r   r   r   @   s     66$<2r   c                 &    U [        S5      * S S:H  $ )z3
Returns C{True} if this string ends in a newline.
r   N)r   r,   s    r   r   r   G   s     c$iZ\?d""r   c                 
   / nU R                  S5      S:  a:  U R                  S5      nU H!  nUR                  [        XA5      S/-   5        M#     U$ U R                  5       nSnSnU(       a  U[	        XW   5      -   nUS-   nXa:  a9  US:X  a  OUS-
  nUSU XWS pXUR                  SR                  U5      5        SnSnO:[	        U5      U:  d&  UR                  SR                  U5      5        USS2	 OUS-   nU(       a  M  U$ )z
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

r   r   r   Nr   )r+   r!   extend
greedyWrapr   r   r"   )	inStringwidthoutLines
paragraphsparainWordscolumnptr_linels	            r   r0   r0   N   s    H }}V!^^F+
DOOJt3rd:; nnGFH
#g/00a<>1} $a<#Ah/1COOCHHQK(HFg,)OOCHHW-.
 aZF- '2 Or   c                 z    / nU  H2  nU(       d  UR                  5       (       d  M!  UR                  U5        M4     U$ r	   )stripr   )linesretlines      r   removeLeadingBlanksr?      s1    
C$**,,JJt  Jr   c                     [        U R                  S5      5      nUR                  5         [        U5      nUR                  5         SR                  U5      S-   $ )Nr   )r?   r!   reverser"   )r   r<   s     r   removeLeadingTrailingBlanksrB      sD    .E	MMO&E	MMO99Ud""r   c                 `   / nSnSnU R                  5        H  nUc  U(       a  US   S;   a  US   nUSS n/ nUc  UR                  U5        M8  U(       aC  US   U:X  a:  USS nUR                  U5        UR                  SR                  U5      5        SnM  UR                  U5        M     U$ )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   )"'r   r   r   )r!   r   r"   )r   outquotphrasewords        r   splitQuotedrJ      s     CDF	>aJ.AwABx>JJtbT)CRyd#

388F+,d#! $ Jr   c                 ~   [        U 5      " 5       n[        [        U 5      S5      nU(       d  U R                  5       n  UR	                  U[        U 5      -
  5      nU(       d  UR                  5       n[        U5      nUS:X  a  g[        U5      U-   U-
  nUS::  a  X5-   nOX7S U-   nUR                  U 5      S:w  a  gM  )zO
Find whether string C{p} occurs in a read()able object C{f}.

@rtype: C{bool}
i   r   FNr   T)r   maxr   lowerreadr+   )pfcaseSensitivebufbuf_lenr
bytes_readr9   s           r   strFilerV      s     q')C#a&*%GGGI
FF7SV#$	AV
?Hz!G+6'Cb'A+C88A;" r   N)r   )P   )T)
__doc__r   r   r   r0   wordWrapr?   rB   rJ   rV   r
   r   r   <module>rZ      s<   
2j#/d # Fr   