HEX
Server: Apache
System: Linux p102.lithium.hosting 4.18.0-553.141.1.el8_10.x86_64 #1 SMP Fri Jul 10 17:48:02 UTC 2026 x86_64
User: bvzmoamr (9955)
PHP: 8.1.34
Disabled: syslog
Upload Files
File: //proc/thread-self/root/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyo
�
1�3\c@@s$ddlmZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
mZmZejd�Zd�eD�Zd	�Zeddd
�Zeddd�Zd�Zd
�Zd�Zed�Zd�Zd�Zd�Zd�Zej de�de!fd��Y�Z"d�Z#d�Z$d�Z%ej&d�Z'd�Z(dd�Z)d�Z*d�Z+d �Z,d!�Z-d"�a.d#d#d$�Z/i
ed%6ed&6ed'6ed(6ed)6ed*6ed+6ed,6ed-6ed.6Z0d/�Z1d0�Z2dS(1i(tabsolute_importNi(t_(tattr(tencodingterrortpycompats()[]{}?*+-|^$\.&~# 	

cC@s,i|]"}d|jd�t|��qS(s\tlatin1(tdecodetord(t.0ti((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pys
<dictcomp>s	cC@sSt}t|t�r-t}|jd�}n|jt�}|rF|S|jd�S(s"Drop-in replacement for re.escape.R(tTruet
isinstancetbytestFalseRt	translatet_regexescapemaptencode(tpattwantuni((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pytreescape sc	C@s%djt|d|d|d|��S(sPretty print an object.ttbprefixtindenttlevel(tjoint	pprintgen(toRRR((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pytpprint.sc	c@s�t|t�r9|r'dt|�Vq�dt|�Vn�t|t�r`dtt|��Vnjt|t�rY|s~dVdSdV|r�|d7}dVd	||Vnx�t|�D]s\}}x+t|d
|d|d|�D]}|Vq�W|dt|�kr�|r d
Vd	||Vq(dVq�q�W|rQ|d8}dVd	||VndVnqt|t�r�|swdVdSdV|r�|d7}dVd	||Vnx�tt	|j
���D]�\}\}}x+t|d
|d|d|�D]}|Vq�WdVx+t|d
|d|d|�D]}|VqW|dt|�kr�|r^d
Vd	||VqfdVq�q�W|r�|d8}dVd	||VndVn3t|t�r�|s�dVdSdV|r�|d7}dVd	||Vnx�tt	|��D]s\}}x+t|d
|d|d|�D]}|VqW|dt|�kr�|r]d
Vd	||VqedVq�q�W|r�|d8}dVd	||VndVn4t|t�r�|s�dVdSdV|r�|d7}dVd	||Vnx�t|�D]s\}}x+t|d
|d|d|�D]}|VqW|dt|�kr�|rVd
Vd	||Vq^dVq�q�W|r�|d8}dVd	||VndVn;t|t
j�r�yt|�}	Wntk
r�dVdSXdV|r�|d7}dVd	||Vnt}
x�|
s�|	}yt|�}	Wntk
r3t}
nXx+t|d
|d|d|�D]}|VqSW|
s�|r�d
Vd	||Vq�dVq�q�W|r�|d8}dVd	||VndVntj|�VdS(s�Pretty print an object to a generator of atoms.

    ``bprefix`` is a flag influencing whether bytestrings are preferred with
    a ``b''`` prefix.

    ``indent`` controls whether collections and nested data structures
    span multiple lines via the indentation amount in spaces. By default,
    no newlines are emitted.

    ``level`` specifies the initial indent level. Used if ``indent > 0``.
    sb'%s's'%s'sbytearray['%s']s[]Nt[is
t RRRs,
s, t]s{}t{s: t}sset([])sset([s])s()t(t)sgen[]sgen[(RR
t	escapestrt	bytearraytlistt	enumerateRtlentdicttsortedtitemstsetttuplettypest
GeneratorTypetnextt
StopIterationRRRtbyterepr(RRRRR
tatchunktktvtnextitemtlasttcurrent((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyR2s


	

+
	
	


	


	


	


	
cC@s@g}tj|�}d}}x|t|�kr(d}|jd|d�}|dkrkt|�}nF||dkr�|jd|d�r�|jd|d|d�}n|dkr�|}n
|d7}|jdd|�|jdd|�}|j||||!j�f�||}}q"Wdj	d	�|D��S(
s9Pretty print a representation of a possibly-nested objectii����t<it=Rt>s
cs@s#|]\}}d||VqdS(s  N((R	tlts((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pys	<genexpr>s(
RR2R(tfindt
startswithtrfindtcounttappendtrstripR(Rtlinestrstp0tp1tq0tq1R=((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyt
prettyrepr�s"
& 	
( cC@sr|dkrdSt|t�r>|dtjtj|d�St|t�rQ|St|�rd|�St|�SdS(srFormat an optional printable representation from unexpanded bits

    ========  =================================
    type(r)   example
    ========  =================================
    tuple     ('<not %r>', other)
    bytes     '<branch closed>'
    callable  lambda: '<branch %r>' % sorted(b)
    object    other
    ========  =================================
    RiiN(	tNoneRR-RtrapplytmaybebytestrR
tcallableR(tr((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyt	buildrepr
scC@st|od|k�S(s&return true if a string is binary datas(tbool(R>((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pytbinary$sc@s�|jd�r�|d}y.d}|s4tj}ntj||�}Wn/tjk
rx}tjtd�|��nXd||jfS|jd�r�|d}n|j}|s�t	j
|���fd�}nd	||fS(
s�
    accepts a string, possibly starting with 're:' or 'literal:' prefix.
    returns the matcher name, pattern, and matcher function.
    missing or unknown prefixes are treated as literal matches.

    helper for tests:
    >>> def test(pattern, *tests):
    ...     kind, pattern, matcher = stringmatcher(pattern)
    ...     return (kind, pattern, [bool(matcher(t)) for t in tests])
    >>> def itest(pattern, *tests):
    ...     kind, pattern, matcher = stringmatcher(pattern, casesensitive=False)
    ...     return (kind, pattern, [bool(matcher(t)) for t in tests])

    exact matching (no prefix):
    >>> test(b'abcdefg', b'abc', b'def', b'abcdefg')
    ('literal', 'abcdefg', [False, False, True])

    regex matching ('re:' prefix)
    >>> test(b're:a.+b', b'nomatch', b'fooadef', b'fooadefbar')
    ('re', 'a.+b', [False, False, True])

    force exact matches ('literal:' prefix)
    >>> test(b'literal:re:foobar', b'foobar', b're:foobar')
    ('literal', 're:foobar', [False, True])

    unknown prefixes are ignored and treated as literals
    >>> test(b'foo:bar', b'foo', b'bar', b'foo:bar')
    ('literal', 'foo:bar', [False, False, True])

    case insensitive regex matches
    >>> itest(b're:A.+b', b'nomatch', b'fooadef', b'fooadefBar')
    ('re', 'A.+b', [False, False, True])

    case insensitive literal matches
    >>> itest(b'ABCDEFG', b'abc', b'def', b'abcdefg')
    ('literal', 'ABCDEFG', [False, False, True])
    sre:iisinvalid regular expression: %stresliteral:ic@s�tj|�kS(N(Rtlower(R>(tipat(s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyt<lambda>`Rtliteral(R@tremodtItcompileRt
ParseErrorRtsearcht__eq__RRU(tpatternt
casesensitivetflagstregextetmatch((RVs@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyt
stringmatcher(s$&

	cC@s�|jd�}|dkr(|| }n|jd�}|dkrT||d}n|jd�}|dkr||| }n|jd�}|dkr�|| }n|S(s>Return a short representation of a user name or email address.t@iR:iRt.(R?(tusertf((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyt	shortusercs


cC@sX|jd�}|dkr(|| }n|jd�}|dkrT||d}n|S(s,Return the user portion of an email address.RfiR:i(R?(RhRi((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyt	emailuserss
cC@s<|jd�}|dkr$d}n||jd�d|!S(sget email of author.R<i����R:iN(R?RL(tauthorRP((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pytemail}s	cC@skd|kr|S|jd�}|dkrH|| jd�jdd�S|jd�}|| jdd�S(	s�Returns the name before an email address,
    interpreting it as per RFC 5322

    >>> person(b'foo@bar')
    'foo'
    >>> person(b'Foo Bar <foo@bar>')
    'Foo Bar'
    >>> person(b'"Foo Bar" <foo@bar>')
    'Foo Bar'
    >>> person(b'"Foo "buz" Bar" <foo@bar>')
    'Foo "buz" Bar'
    >>> # The following are invalid, but do exist in real-life
    ...
    >>> person(b'Foo "buz" Bar <foo@bar>')
    'Foo "buz" Bar'
    >>> person(b'"Foo Bar <foo@bar>')
    'Foo Bar'
    RfR:i����s "s\"t"RgR(R?tstriptreplace(RlRi((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pytperson�sthashtmailmappingcB@s,eZdZej�Zejdd�ZRS(s>Represents a username/email key or value in
    a mailmap filetdefaultN(t__name__t
__module__t__doc__RtibRmRLtname(((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyRs�scC@s|p|ot|�dkS(suReturns True if the parsed names and emails
    in a mailmap entry are invalid.

    >>> # No names or emails fails
    >>> names, emails = [], []
    >>> _ismailmaplineinvalid(names, emails)
    True
    >>> # Only one email fails
    >>> emails = [b'email@email.com']
    >>> _ismailmaplineinvalid(names, emails)
    True
    >>> # One email and one name passes
    >>> names = [b'Test Name']
    >>> _ismailmaplineinvalid(names, emails)
    False
    >>> # No names but two emails passes
    >>> names = []
    >>> emails = [b'proper@email.com', b'commit@email.com']
    >>> _ismailmaplineinvalid(names, emails)
    False
    i(R((tnamestemails((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyt_ismailmaplineinvalid�scC@s}i}|dkr|Sx`|j�D]R}|j�jd�rDq#ngg}}g}x�|j�D]�}|jd�r}Pqd|jd�r�|jd�r�|j|dd!�|r�|jdj|��g}nt|�dkr�Pq�qd|j|�qdWt	||�rq#nt
d|ddt|�d	kr?|dnd�}t
d|d
d|rh|d
nd�||<q#W|S(sxParses data in the .mailmap format

    >>> mmdata = b"\n".join([
    ... b'# Comment',
    ... b'Name <commit1@email.xx>',
    ... b'<name@email.xx> <commit2@email.xx>',
    ... b'Name <proper@email.xx> <commit3@email.xx>',
    ... b'Name <proper@email.xx> Commit <commit4@email.xx>',
    ... ])
    >>> mm = parsemailmap(mmdata)
    >>> for key in sorted(mm.keys()):
    ...     print(key)
    mailmapping(email='commit1@email.xx', name=None)
    mailmapping(email='commit2@email.xx', name=None)
    mailmapping(email='commit3@email.xx', name=None)
    mailmapping(email='commit4@email.xx', name='Commit')
    >>> for val in sorted(mm.values()):
    ...     print(val)
    mailmapping(email='commit1@email.xx', name='Name')
    mailmapping(email='name@email.xx', name=None)
    mailmapping(email='proper@email.xx', name='Name')
    mailmapping(email='proper@email.xx', name='Name')
    t#R:R<ii����RRmRyiiN(RLt
splitlinestlstripR@tsplittendswithRCRR(R|Rs(tmailmapcontenttmailmaptlineRzR{tnamebuildertelementt
mailmapkey((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pytparsemailmap�s8
	
%
!cC@s�t|�s|r|Stdt|�dt|��}y||}Wn>tk
r�td|j�}|j|tdd��}nXd|jr�|jn|j|jr�|jn|jfS(s.Returns the author field according to the mailmap cache, or
    the original author field.

    >>> mmdata = b"\n".join([
    ...     b'# Comment',
    ...     b'Name <commit1@email.xx>',
    ...     b'<name@email.xx> <commit2@email.xx>',
    ...     b'Name <proper@email.xx> <commit3@email.xx>',
    ...     b'Name <proper@email.xx> Commit <commit4@email.xx>',
    ... ])
    >>> m = parsemailmap(mmdata)
    >>> mapname(m, b'Commit <commit1@email.xx>')
    'Name <commit1@email.xx>'
    >>> mapname(m, b'Name <commit2@email.xx>')
    'Name <name@email.xx>'
    >>> mapname(m, b'Commit <commit3@email.xx>')
    'Name <proper@email.xx>'
    >>> mapname(m, b'Commit <commit4@email.xx>')
    'Name <proper@email.xx>'
    >>> mapname(m, b'Unknown Name <unknown@email.com>')
    'Unknown Name <unknown@email.com>'
    RyRms%s <%s>N(tisauthorwellformedRsRqRmtKeyErrortgetRLRy(R�Rltcommittpropertcommit2((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pytmapnames!
s^[^<]+\s\<[^<>]+@[^<>]+\>$cC@stj|�dk	S(s&Return True if the author field is well formed
    (ie "Contributor Name <contrib@email.dom>")

    >>> isauthorwellformed(b'Good Author <good@author.com>')
    True
    >>> isauthorwellformed(b'Author <good@author.com>')
    True
    >>> isauthorwellformed(b'Bad Author')
    False
    >>> isauthorwellformed(b'Bad Author <author@author.com')
    False
    >>> isauthorwellformed(b'Bad Author author@author.com')
    False
    >>> isauthorwellformed(b'<author@author.com>')
    False
    >>> isauthorwellformed(b'Bad Author <author>')
    False
    N(t_correctauthorformatRdRL(Rl((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyR�Asi�cC@stj||dd�S(sCTrim string to at most maxlength (default: 400) columns in display.tellipsiss...(Rttrim(ttextt	maxlength((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyR�VscC@s/t|t�rt|�}ntj|�dS(Ni(Rt
memoryviewR
tcodecst
escape_encode(R>((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyR$ZscC@stj|�dS(Ni(R�t
escape_decode(R>((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pytunescapestrascC@sBytj|�SWn*tk
r=tjtjt|���SXdS(sLPortably format an arbitrary object (e.g. exception) into a byte
    string.N(RtbytestrtUnicodeEncodeErrorRt
strtolocaltstr(tobj((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pytforcebytestrds
cC@s"tjtj|��jdd�S(Ns\\s\(RR2R�Rp(R>((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pytuireprmscK@s)dtjfd��Y}|a||�S(NttwcB@s)eZdZd�Zd�Zd�ZRS(s8
        Extend TextWrapper for width-awareness.

        Neither number of 'bytes' in any encoding nor 'characters' is
        appropriate to calculate terminal columns for specified string.

        Original TextWrapper implementation uses built-in 'len()' directly,
        so overriding is needed to use width information of each characters.

        In addition, characters classified into 'ambiguous' width are
        treated as wide in East Asian area, but as narrow in other.

        This requires use decision to determine width of such characters.
        cS@skd}tj}xOtjt|��D]8}||||�7}||kr%|| ||fSq%W|dfS(NiR(Rt	ucolwidthRtxrangeR((tselftucstrt
space_leftR=tcolwidthR
((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyt_cutdown�s	cS@srt||d�}|jrR|j|d|�\}}|j|�||d<n|sn|j|j��ndS(Nii����(tmaxtbreak_long_wordsR�RCtpop(R�treversed_chunkstcur_linetcur_lentwidthR�tcuttres((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyt_handle_long_word�s	

c	S@s�tj}g}|jdkr4td|j��n|j�xH|r�g}d}|re|j}n	|j}|jt|�}|jr�|dj	�dkr�|r�|d=nxK|r�||d�}|||kr�|j
|j��||7}q�Pq�W|r3||d�|kr3|j||||�n|jrb|rb|dj	�dkrb|d=n|rA|j
|dj
|��qAqAW|S(Nisinvalid width %r (must be > 0)i����R(RR�R�t
ValueErrortreversetsubsequent_indenttinitial_indentR(tdrop_whitespaceRoRCR�R�R(	R�tchunksR�RER�R�RR�R=((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyt_wrap_chunks�s8	
		%
	
	
!(RuRvRwR�R�R�(((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyR�ss	
	(ttextwraptTextWrappert_MBTextWrapper(tkwargsR�((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyR�rscRcC@s�tt|�t|��}||kr=td|d�}n|jtjtj�tjtj��}|jtjtj�tjtj��}|jtjtj�tjtj��}td|d|d|�}|j|�j	tjtj��S(NiNiR�R�R�(
R�R(RRtsysstrRtencodingmodeR�tfillR(R�R�t
initindentt
hangindentt	maxindenttwrapper((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pytwrap�s	t1tyesttruetontalwayst0tnotfalsetofftnevercC@stj|j�d�S(sLParse s into a boolean.

    If s is not a valid boolean, returns None.
    N(t	_booleansR�RURL(R>((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyt	parsebool�scC@s,tjrtj|jd��Stj|�S(s8Evaluate a string containing a Python literal expressionR(Rtispy3tasttliteral_evalR(R>((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pytevalpythonliteral�s	(3t
__future__RR�R�RTRYR�R.ti18nRt
thirdpartyRRRRRR�t
_respecialRRRRRRKRQRSRReRjRkRmRqR>tobjectRsR|R�R�R[R�R�R�R$R�R�R�R�R�R�R�R�(((s@/usr/lib64/python2.7/site-packages/mercurial/utils/stringutil.pyt<module>
sP	�			;		
				R	/							g&