
    Ϫf#                     B    d Z d
dZd Zd ZddZeZd Zd Zd ZddZ	y	)z'
Miscellany of text-munging functions.
c                 f   d}g }t        |       t        u rd}| j                         D ]{  \  }}t        ||dz         }t	        |      r4t        |      r|dt        d        }|j                  | d| d|        T|j                  | d| d|t        |      d	z   d         } nt        |       t        u st        |       t        u rOt        |       t        u rd
}nd}| D ]3  }t        ||dz         }|j                  |j                         dz          5 n*t        |fdt        |       j                  d            |dd |s|j                  |       |r.||d   z   |d   t        |      dz   d z   |d<   |d   |d   z   |d<   dj                  |      }t	        |      rt        |      s|dz   }|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                     || z   S N )sis     5/usr/lib/python3/dist-packages/twisted/python/text.py<lambda>zstringyString.<locals>.<lambda>/   s
    QU            )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 ,,. 	SJC!%u)<=E5! '!,SYJ/E		[M3%s5':; 		[M3%r%K8H18L8N2O1PQR	S 
f	$v,$"6<5 FF 	.G#G[3->?GIIgnn&,-	. 2CK4E4Ed4KL1
		+fQi'"Q%K0@10D0F*GG1B&*$2		"A1~mA.HHr   c                 *    | j                  d      dk7  S )z=
    Returns C{True} if this string has a newline in it.
    r   r   )findr   s    r   r   r   @   s     66$<2r   c                 &    | t        d       d dk(  S )z;
    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                    g }| j                  d      dk\  r9| j                  d      }|D ]!  }|j                  t        ||      dgz          # |S | j                         }d}d}|r|t	        ||         z   }|dz   }||kD  r:|dk(  rn|dz
  }|d| ||d }}|j                  dj                  |             d}d}n9t	        |      |kD  s&|j                  dj                  |             |dd= n|dz   }|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

r   r   r   Nr   )r*   r    extend
greedyWrapr   r   r!   )	inStringwidthoutLines
paragraphsparainWordscolumnptr_linels	            r   r/   r/   N   s    H }}V!^^F+
 	<DOOJtU3rd:;	<nnGFH
#gh/00a<E>1} $a<#Ah/1CQOOCHHQK(HFg,)OOCHHW-.
 aZF- 2 Or   c                 `    g }| D ]&  }|s|j                         s|j                  |       ( |S r	   )stripr   )linesretlines      r   removeLeadingBlanksr>      s4    
C $**,JJt Jr   c                     t        | j                  d            }|j                          t        |      }|j                          dj                  |      dz   S )Nr   )r>   r    reverser!   )r   r;   s     r   removeLeadingTrailingBlanksrA      sD    .E	MMO&E	MMO99Ud""r   c                 :   g }d}d}| j                         D ]  }||r|d   dv r|d   }|dd }g }||j                  |       .|rA|d   |k(  r9|dd }|j                  |       |j                  dj                  |             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   )"'r   r   r   )r    r   r!   )r   outquotphrasewords        r   splitQuotedrI      s     CDF	 $>aJ.AwABx>JJtbT)CRyd#

388F+,d#!$$ Jr   c                 f    t        |              }t        t        |       d      }|s| j                         } 	 |j	                  |t        |       z
        }|s|j                         }t        |      }|dk(  ryt        |      |z   |z
  }|dk  r||z   }n||d |z   }|j                  |       dk7  ryz)z[
    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_readr8   s           r   strFilerU      s     $q')C#a&*%GGGI
FF7SV#$	AV
?Hz!G+6'Cab'A+C88A;" r   N)r   )P   )T)
__doc__r   r   r   r/   wordWrapr>   rA   rI   rU   r
   r   r   <module>rY      s<   
2j#/d # Fr   