Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/twisted/python/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/twisted/python/__pycache__/text.cpython-37.pyc

B

:��]j�@sRdZddd�Zdd�Zdd�Zdd	d
�ZeZdd�Zd
d�Zdd�Zddd�Z	dS)z'
Miscellany of text-munging functions.
�c	Cs�d}g}t|�tkr�d}x~|��D]r\}}t||d�}t|�rpt|�rZ|dtd��}|�d|||f�q"|�d|||t|�dd�f�q"Wn�t|�tks�t|�t	kr�t|�tkr�d	}nd
}xR|D]$}t||d�}|�|�
�d�q�Wn$t|fd
d�t|��
d��|dd�<|�s,|�|�|�rn||d|dt|�dd�|d<|d|d|d<d�|�}t|��r�t|��s�|d}|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.
    rz{}z   N�
z	%s %s:
%sz	%s %s: %s�z()z[]� �,cSs||S)N�)�s�irr�F/opt/alt/python37/lib64/python3.7/site-packages/twisted/python/text.py�<lambda>0�zstringyString.<locals>.<lambda>�����)�type�dict�items�
stringyString�isMultiline�
endsInNewline�len�append�tuple�list�rstrip�map�str�split�join)�objectZindentationZbraces�sl�key�value�elementrrrr	rs<
 

(
rcCs|�d�dkS)z=
    Returns C{True} if this string has a newline in it.
    rr)�find)rrrr	rBsrcCs|td�d�dkS)z;
    Returns C{True} if this string ends in a newline.
    rN)r)rrrr	rIsr�Pc	Cs�g}|�d�dkrD|�d�}x"|D]}|�t||�dg�q"W|S|��}d}d}x�|r�|t||�}|d}||kr�|dkr�n|d}|d|�||d�}}|�d�|��d}d}qVt|�|ks�|�d�|��|dd�=qV|d}qVW|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rr
Nr)r#r�extend�
greedyWraprrr)	ZinString�widthZoutLinesZ
paragraphsZparaZinWords�columnZptr_line�lrrr	r&Ps2


r&cCs,g}x"|D]}|s|��r
|�|�q
W|S)N)�stripr)�lines�ret�linerrr	�removeLeadingBlanks�s

r.cCs4t|�d��}|��t|�}|��d�|�dS)Nr)r.r�reverser)rr+rrr	�removeLeadingTrailingBlanks�s
r0cCs�g}d}d}x�|��D]�}|dkrJ|rJ|ddkrJ|d}|dd�}g}|dkr^|�|�q|r�|d|kr�|dd�}|�|�|�d�|��d}q|�|�qW|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
rr)rrr)r�outZquot�phrase�wordrrr	�splitQuoted�s$
r6TcCs�t|��}tt|�d�}|s$|��}xz|�|t|��}|sD|��}t|�}|dkrXdSt|�||}|dkrz||}n||d�|}|�|�dkr&dSq&WdS)z[
    Find whether string C{p} occurs in a read()able object C{f}.

    @rtype: C{bool}
    irFNrT)r�maxr�lower�readr#)�p�fZ
caseSensitive�bufZbuf_len�rZ
bytes_readr)rrr	�strFile�s"

r>N)r)r$)T)
�__doc__rrrr&ZwordWrapr.r0r6r>rrrr	�<module>s
7
2#