403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib64/python3.9/site-packages/mercurial/utils/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib64/python3.9/site-packages/mercurial/utils/__pycache__/stringutil.cpython-39.opt-1.pyc
a

�+�b�r�@s�ddlmZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
mZmZe�d�Zdd	�eD�Zd
d	�eD�Zdd�ZdJdd�ZdKdd�Zdd�Zdd�Zdd�Zdd�ZdLdd�ZdMdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Z ej!dd'�Gd(d)�d)e"��Z#d*d+�Z$d,d-�Z%d.d/�Z&e�'d0�Z(d1d2�Z)dNd4d5�Z*d6d7�Z+d8d9�Z,d:d;�Z-d<d=�Z.d>d?�a/dOdAdB�Z0dddddd
d
d
d
d
dC�
Z1dDdE�Z2dFdG�Z3dHdI�Z4dS)P�)�absolute_importN�)�_)�attr)�encoding�error�pycompats()[]{}?*+-|^$\.&~# 	

cCs i|]}t|�d|�d��qS)�\�latin1)�ord�decode��.0�i�r�@/usr/lib64/python3.9/site-packages/mercurial/utils/stringutil.py�
<dictcomp>�rcCsi|]}|d|�qS)r	rr
rrrrrcCs8d}t|t�rd}|�d�}|�t�}|r.|S|�d�S)z"Drop-in replacement for re.escape.TFr
)�
isinstance�bytesr�	translate�_regexescapemap�encode)�patZwantunirrr�reescape"s


rFcCsd�t||||d��S)zPretty print an object.r��bprefix�indent�level)�join�	pprintgen)�orrrrrr�pprint1sr"ccs�t|t�r0|rdt|�Vndt|�V�n�t|t�rPdtt|��V�n�t|t��r|sjdVdSdV|r�|d7}dVd	||Vt|�D]T\}}t||||d
�D]
}|Vq�|dt|�kr�|r�dVd	||Vq�dVq�|�r|d8}dVd	||Vd
V�n�t|t��r |�s6dVdSdV|�r^|d7}dVd	||Vtt	|�
���D]�\}\}}t||||d
�D]}|V�q�dVt||||d
�D]}|V�q�|dt|�k�rn|�r�dVd	||VndV�qn|�r|d8}dVd	||VdV�n�t|t��r�|�s<dVdSdV|�rd|d7}dVd	||Vtt	|��D]\\}}t||||d
�D]}|V�q�|dt|�k�rp|�r�dVd	||VndV�qp|�r�|d8}dVd	||VdV�n�t|t��r�|�sdVdSdV|�r>|d7}dVd	||Vt|�D]\\}}t||||d
�D]}|V�q^|dt|�k�rF|�r�dVd	||VndV�qF|�r�|d8}dVd	||VdV�nt|t
j��r�zt|�}	Wnt�ydVYdS0dV|�r0|d7}dVd	||Vd}
|
�s�|	}zt|�}	Wnt�ybd}
Yn0t||||d
�D]}|V�qt|
�s4|�r�dVd	||VndV�q4|�r�|d8}dVd	||Vd
Vnt�|�VdS)a�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[]N�[��
� rs,
s, �]s{}�{s: �}sset([])sset([s])s()�(�)sgen[]sgen[FT)rr�	escapestr�	bytearray�list�	enumerater �len�dict�sorted�items�set�tuple�types�
GeneratorType�next�
StopIterationr�byterepr)r!rrrr�a�chunk�k�vZnextitemZlast�currentrrrr 6s

�

�

�



�



�




�


r cCs�g}t�|�}d}}|t|�kr�d}|�d|d�}|dkrHt|�}n2||dkrz|�d|d�rz|�d|d|d�}|dkr�|}n|d7}|�dd|�|�dd|�}|�||||���f�||}}qd�	d	d
�|D��S)z9Pretty print a representation of a possibly-nested objectr����<r$�=r&�>r%css|]\}}d||VqdS)s  Nr)r�l�srrr�	<genexpr>rzprettyrepr.<locals>.<genexpr>)
rr:r0�find�
startswith�rfind�count�append�rstripr)r!�linesZrsZp0Zp1Zq0Zq1rDrrr�
prettyrepr�s"

rNcCs\|durdSt|t�r4|dt�tj|dd��St|t�rB|St|�rP|�St|�SdS)arFormat 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
    ========  =================================
    Nrrr$)rr5rZrapplyZmaybebytestrr�callabler")�rrrr�	buildreprs

rQcCst|od|v�S)z&return true if a string is binary data�)�bool�rErrr�binary5srUcCs<|�d�rd|dd�fS|�d�r4d|dd�fSd|fS)Nsre:�re�sliteral:�literal�)rH)�patternrrr�
_splitpattern:s


r[Tc
s�t|�\}}|dkr|zd}|s$tj}t�||�}Wn<tjyn}z"t�td�t|���WYd}~n
d}~00|||jfS|dkr�|r�|j	}nt
�|���fdd�}|||fSt�d|��dS)	a�
    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])
    rVr�invalid regular expression: %sNrXcs�t�|�kS)N)r�lowerrT�Zipatrr�<lambda>yrzstringmatcher.<locals>.<lambda>�unhandled pattern kind: %s)
r[�remod�I�compiler�
ParseErrorr�forcebytestr�search�__eq__rr]�ProgrammingError)rZZ
casesensitive�kind�flagsZregex�e�matchrr^r�
stringmatcherBs&&�

rmc
Cs�t|�\}}|dkrbzt�||�WStjy^}z"t�td�t|���WYd}~q|d}~00n|dkr|t�t�|�|�St�d|��dS)a�Build a regexp object from a string pattern possibly starting with
    're:' or 'literal:' prefix.

    helper for tests:
    >>> def test(pattern, *tests):
    ...     regexp = substringregexp(pattern)
    ...     return [bool(regexp.search(t)) for t in tests]
    >>> def itest(pattern, *tests):
    ...     regexp = substringregexp(pattern, remod.I)
    ...     return [bool(regexp.search(t)) for t in tests]

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

    substring pattern should be escaped:
    >>> substringregexp(b'.bc').pattern
    '\\.bc'
    >>> test(b'.bc', b'abc', b'def', b'abcdefg')
    [False, False, False]

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

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

    case insensitive literal matches
    >>> itest(b'BCDE', b'abc', b'def', b'abcdefg')
    [False, False, True]

    case insensitive regex matches
    >>> itest(b're:A.+b', b'nomatch', b'fooadef', b'fooadefBar')
    [False, False, True]
    rVr\NrXr`)	r[rarcrrdrre�escaperh)rZrjrirkrrr�substringregexps&�rocCs�|�d�}|dkr|d|�}|�d�}|dkr@||dd�}|�d�}|dkr^|d|�}|�d�}|dkr||d|�}|S)z>Return a short representation of a user name or email address.�@rNrAr$r&�.�rG��user�frrr�	shortuser�s



rvcCsD|�d�}|dkr|d|�}|�d�}|dkr@||dd�}|S)z,Return the user portion of an email address.rprNrAr$rrrsrrr�	emailuser�s

rwcCs,|�d�}|dkrd}||�d�d|�S)zget email of author.rCr@NrAr$rr)�authorrPrrr�email�s
rycCsVd|vr|S|�d�}|dkr8|d|��d��dd�S|�d�}|d|��dd	�S)
a�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'
    rprAr@Ns "s\"�"rqr&)rG�strip�replace)rxrurrr�person�s

r})�hashc@s$eZdZdZe��Zejdd�ZdS)�mailmappingz>Represents a username/email key or value in
    a mailmap fileN)�default)�__name__�
__module__�__qualname__�__doc__rZibry�namerrrrr�srcCs|p|ot|�dkS)auReturns 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
    r)r0)�names�emailsrrr�_ismailmaplineinvalid�sr�cCsi}|dur|S|��D]�}|���d�r,qgg}}g}|��D]n}|�d�rVq�qB|�d�r�|�d�r�|�|dd��|r�|�d�|��g}t|�dkr�q�qB|�|�qBt||�r�qt	|dt|�dkr�|dndd	�}t	|d
|r�|d
ndd	�||<q|S)axParses 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')
    N�#rArCr$r@r&r)ryr�r)
�
splitlines�lstriprH�split�endswithrKrr0r�r)Zmailmapcontent�mailmap�liner�r�Znamebuilder�elementZ
mailmapkeyrrr�parsemailmaps<


��r�c	Cs�t|�r|s|Stt|�t|�d�}z||}Wn0ty`t|jd�}|�|tdd��}Yn0d|jrp|jn|j|jr�|jn|jfS)a.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>'
    )r�ry)ryNs%s <%s>)�isauthorwellformedrr}ry�KeyError�getr�)r�rxZcommitZproperZcommit2rrr�mapnamehs�r�s^[^<]+\s<[^<>]+@[^<>]+>$cCst�|�duS)a&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)�_correctauthorformatrl)rxrrrr��sr��cCstj||dd�S)zCTrim string to at most maxlength (default: 400) columns in display.s...)�ellipsis)rZtrim)�textZ	maxlengthrrrr��sr�cCs t|t�rt|�}t�|�dS�Nr)r�
memoryviewr�codecs�
escape_encoderTrrrr,�s
r,cCst�|�dSr�)r��
escape_decoderTrrr�unescapestr�sr�c	Cs8zt�|�WSty2t�t�t|���YS0dS)zLPortably format an arbitrary object (e.g. exception) into a byte
    string.N)r�bytestr�UnicodeEncodeErrorrZ
strtolocal�str)�objrrrre�srecCst�t�|���dd�S)Ns\\r	)rr:r�r|rTrrr�uirepr�sr�cKs$Gdd�dtj�}|a|fi|��S)Nc@s(eZdZdZdd�Zdd�Zdd�ZdS)	z_MBTextWrapper.<locals>.twa8
        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.
        cSsZd}tj}t�t|��D]8}||||�7}||kr|d|�||d�fSq|dfS)Nrr)r�	ucolwidthrZxranger0)�selfZucstr�
space_leftrD�colwidthrrrr�_cutdown�sz#_MBTextWrapper.<locals>.tw._cutdowncSsRt||d�}|jr<|�|d|�\}}|�|�||d<n|sN|�|���dS)Nr$r@)�maxZbreak_long_wordsr�rK�pop)r�Zreversed_chunks�cur_line�cur_len�widthr�Zcut�resrrr�_handle_long_word�s

z,_MBTextWrapper.<locals>.tw._handle_long_wordc	Sstj}g}|jdkr"td|j��|��|�rg}d}|rD|j}n|j}|jt|�}|jrx|d�	�dkrx|rx|d=|r�||d�}|||kr�|�
|���||7}qxq�qx|r�||d�|kr�|�||||�|jr�|r�|d�	�dkr�|d=|r*|�
|d�
|��q*|S)Nrsinvalid width %r (must be > 0)r@�)rr�r��
ValueError�reverse�subsequent_indent�initial_indentr0Zdrop_whitespacer{rKr�r�r)	r��chunksr�rMr�r�rr�rDrrr�_wrap_chunks�s@

���z'_MBTextWrapper.<locals>.tw._wrap_chunksN)r�r�r�r�r�r�r�rrrr�tw�s
r�)�textwrapZTextWrapper�_MBTextWrapper)�kwargsr�rrrr��sgr�rcCs�tt|�t|��}||kr(td|d�}|�t�tj�t�tj��}|�t�tj�t�tj��}|�t�tj�t�tj��}t|||d�}|�|��	t�tj��S)N�Nr$)r�r�r�)
r�r0rrZsysstrrZencodingmoder��fillr)r�r�Z
initindentZ
hangindentZ	maxindent�wrapperrrr�wrap>s&

�

�

��r�)
�1syesstruesonsalways�0snosfalsesoffsnevercCst�|��d�S)zLParse s into a boolean.

    If s is not a valid boolean, returns None.
    N)�	_booleansr�r]rTrrr�	parseboolcsr�csV��fdd����fdd���fdd��|durJt|t�rJ�|�d��}n|}|pTgS)	z�parse a configuration value as a list of comma/space separated strings

    >>> parselist(b'this,is "a small" ,test')
    ['this', 'is', 'a small', 'test']
    csd}|t|�krF|||d���s8|||d�dkrFd}|d7}q|t|�kr\d||fS|rj|�d�|||d�dkr�|ds��||dfS|||d�dkr�|ddd�dkr�|ddd�|||d�|d<�||dfS|d|||d�7<�||dfS)	NFr$�,Trrzr@r	)r0�isspacerK)�partsrE�offsetZ
whitespace)�_parse_plain�_parse_quoterrr�rs&��


($zparselist.<locals>._parse_plaincs|t|�krz|||d�dkrz|�d�|d7}|t|�krp|||d���sf|||d�dkrp|d7}q2�||fS|t|�k�r|||d�dk�r|||d�dkr�|dt|�kr�||d|d�dkr�|d7}|dd7<n|d|||d�7<|d7}qz|t|�k�rt�|d�}|�sDd|d<n&d|d|d<|dd�}|�|�d||fS|d7}|t|�k�r�|||d�d	v�r�|d7}�q||t|�k�r|dt|�k�r�|||d�dk�r�|dd7<|d7}n
|�d�n
d||fS�||fS)
Nr$rzrr�r	rr@r)r&r�)r0rKr��extend)r�rEr�Z
real_parts)�_configlistr�rrr��sN 
��

$���



$(

zparselist.<locals>._parse_quotecs@|�d�}|sgS�dgd}}}|r<||||�\}}}q$|S)Ns ,rr)rL)rE�parserr�r�)r�rrr��s
zparselist.<locals>._configlistNs ,
)rrr�)�value�resultr)r�r�r�r�	parselistks0	r�cCs tjrt�|�d��St�|�S)z8Evaluate a string containing a Python literal expressionr
)rZispy3�astZliteral_evalrrTrrr�evalpythonliteral�sr�)Frr)Frr)T)r)r�)rr)5Z
__future__rr�r��rerar�r6Zi18nrZ
thirdpartyrr�rrrr�Z
_respecialrZregexbytesescapemaprr"r rNrQrUr[rmrorvrwryr}rE�objectrr�r�r�rcr�r�r�r,r�rer�r�r�r�r�r�r�rrrr�<module>
sj


I
=
4
S0


l
�Z

Youez - 2016 - github.com/yon3zu
LinuXploit