
    \d)                     D    d Z ddZd Zd ZddZeZd Zd Zd	 ZddZ	dS )z'
Miscellany of text-munging functions.
 c                 X   d}g }t          |           t          u rd}|                                 D ]\  }}t          ||dz             }t	          |          rEt          |          r|dt          d                    }|                    | d| d|            l|                    | d| d|t          |          d	z   d                     nt          |           t          u st          |           t          u r^t          |           t          u rd
}nd}| D ]?}t          ||dz             }|                    |
                                dz              @n8t          |fdt          |                               d                    |dd<   |s|                    |           |rC||d         z   |d         t          |          dz   d         z   |d<   |d         |d         z   |d<   d                    |          }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.
    r   z{}z   N
 z:
z:    z()z[],c                     || z   S N )sis     3lib/python3.11/site-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      si    F	BF||t ,,.. 	S 	SJC!%u)<==E5!! S '' 0!,SYYJ,/E		[::3::5::;;;; 		[QQ3QQ%K8H8H18L8N8N2OQQRRRR	S 
f		$v,,$"6"6<<5  FFF 	. 	.G#G[3->??GIIgnn&&,----	. 222CKK4E4Ed4K4KLL111 
		+ %fQi'"Q%K0@0@10D0F0F*GG1B&*$2		"A1~~ mA.. HHr   c                 4    |                      d          dk    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$iiZ\\?d""r   P   c                 f   g }|                      d          dk    rC|                     d          }|D ])}|                    t          ||          dgz              *|S |                                 }d}d}|r|t	          ||                   z   }|dz   }||k    rM|dk    rn|dz
  }|d|         ||d         }}|                    d                    |                     d}d}nFt	          |          |k    s.|                    d                    |                     |dd= n|dz   }||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   r0   r0   N   si    H }}V!!^^F++
 	< 	<DOOJtU33rd:;;;;nnGFH
  #gh/000a<E>>1}} $a<#AhJ/1CQOOCHHQKK(((HFFg,,))OOCHHW--...

 aZF-   2 Or   c                 j    g }| D ]-}|s|                                 r|                    |           .|S r	   )stripr   )linesretlines      r   removeLeadingBlanksr?      sE    
C   	$**,, 	JJtJr   c                     t          |                     d                    }|                                 t          |          }|                                 d                    |          dz   S )Nr   )r?   r    reverser!   )r   r<   s     r   removeLeadingTrailingBlanksrB      sW    ..E	MMOOO&&E	MMOOO99Ud""r   c                    g }d}d}|                                  D ]}| |r|d         dv r|d         }|dd         }g }||                    |           <|rV|d         |k    rJ|dd         }|                    |           |                    d                    |                     d}|                    |           |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   splitQuotedrJ      s     CDF		 $ $> aJ..AwABBx>JJt $bT))CRCyd###

388F++,,,d####Jr   Tc                     t          |                       }t          t          |           d          }|s|                                 } 	 |                    |t          |           z
            }|s|                                }t          |          }|dk    rdS t          |          |z   |z
  }|dk    r||z   }n||d         |z   }|                    |           dk    rdS )z[
    Find whether string C{p} occurs in a read()able object C{f}.

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