Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/python/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/python/text.pyc


Mc@sdZddlZddlZddlmZmZddZdZdZej	ej
dd	d
dded
dZddZ
e
ZdZdZdZedZdS(s'
Miscellany of text-munging functions.
iN(t	deprecatetversionstcCsd}g}t|tjkrd}xL|jD]\}}t||d}t|rt|r|td }n|jd|||fq4|jd|||t|dfq4Wnt|tj	tj
fkrNt|tj	krd}nd	}xf|D]3}t||d
}|jtj|dqWn(t
|dtjt|d|(|s|j|n|r||d
|d
t|d|d
<|d|d|d<ntj|d}t|rt|r|d}n|S(s`
    Expansive string formatting for sequence types.

    list.__str__ and dict.__str__ use repr() to display their
    elements.  This function also turns these sequence types
    into strings, but uses str() on their elements instead.

    Sequence elements are also displayed on seperate lines,
    and nested sequences have nested indentation.
    Rs{}s   s
s	%s %s:
%ss	%s %s: %sis()s[]t t,cSs||S(N((tsti((s7/usr/lib/python2.7/dist-packages/twisted/python/text.pyt<lambda>5siii(ttypettypestDictTypetitemst
stringyStringtisMultilinet
endsInNewlinetlentappendt	TupleTypetListTypetstringtrstriptmaptsplittstrtjoin(tobjecttindentationtbracestsltkeytvaluetelementR((s7/usr/lib/python2.7/dist-packages/twisted/python/text.pyRs< 	
!(
cCstj|ddkS(s0Returns True if this string has a newline in it.s
i(Rtfind(R((s7/usr/lib/python2.7/dist-packages/twisted/python/text.pyR
FscCs|tddkS(s.Returns True if this string ends in a newline.s
(R(R((s7/usr/lib/python2.7/dist-packages/twisted/python/text.pyRJstTwistedi
iis"Please use inspect.getdoc instead.tdocstringLStripcCs|s
|Stj|dd}tj|d}d}xgtdt|D]P}||}tj|rx$||dkr|d}qoPqon|rMPqMqMW|dd!}x2tdt|D]}|j|||qWtj|dS(s
    Gets rid of unsightly lefthand docstring whitespace residue.

    You'd think someone would have done this already, but apparently
    not in 1.5.2.

    BUT since we're all using Python 2.1 now, use L{inspect.getdoc}
    instead.  I{This function should go away soon.}
    s	Ris
iis        (RtreplaceRtxrangeRtstripRR(t	docstringtlinestleadingtltlinetoutlines((s7/usr/lib/python2.7/dist-packages/twisted/python/text.pyR"Ws$


iPc	CsJg}|jddkr_tj|d}x+|D]#}|jt||dgq4W|Stj|}d}d}x|rE|t||}|d}||kr|dkrn
|d}|d|!||}}|jtj|dd}d}q}t||ks8|jtj|d|2q}|d}q}W|S(s
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.
    s

iRiR(R RRtextendt
greedyWrapRRR(	tinStringtwidthtoutLinest
paragraphstparatinWordstcolumntptr_lineR)((s7/usr/lib/python2.7/dist-packages/twisted/python/text.pyR-zs2	
!	

	cCs=g}x0|D](}|s%|jr
|j|q
q
W|S(N(R%R(R'tretR*((s7/usr/lib/python2.7/dist-packages/twisted/python/text.pytremoveLeadingBlankss

cCsFt|jd}|jt|}|jdj|dS(Ns
(R7RtreverseR(RR'((s7/usr/lib/python2.7/dist-packages/twisted/python/text.pytremoveLeadingTrailingBlankss


cCsg}d}d}x|jD]}|dkrg|rg|ddkrg|d}|d}g}qgn|dkr|j|q|r|d|kr|d }|j||jdj|d}q|j|qW|S(	s6Like 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.
    is"t'iiRN(s"R:(tNoneRRR(Rtouttquottphrasetword((s7/usr/lib/python2.7/dist-packages/twisted/python/text.pytsplitQuoteds$




	cCsd}tt|ddd}|s8|j}nx|j|t|}|si|j}nt|}|dkrtSt|||}|dkr||}n|||}|j|dkr;tSq;dS(sNFind whether string p occurs in a read()able object f
    @rtype: C{bool}
    RiiiNi(tmaxRtlowertreadtFalseR tTrue(tptft
caseSensitivetbuftbuf_lentrt
bytes_readR)((s7/usr/lib/python2.7/dist-packages/twisted/python/text.pytstrFiles"
(t__doc__RR	ttwisted.pythonRRRR
RtdeprecatedModuleAttributetVersiont__name__R"R-twordWrapR7R9R@RERM(((s7/usr/lib/python2.7/dist-packages/twisted/python/text.pyt<module>	s 6		
	#1			!