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 :  /usr/lib64/python3.9/site-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /usr/lib64/python3.9/site-packages/mercurial/__pycache__/encoding.cpython-39.pyc
a

�+�b�[�@s�ddlmZmZddlZddlZddlZddlZddlmZddl	m
Z
mZmZddlm
Zejr�ddlmZmZmZmZmZmZmZeeeeeefD]Zes�J�q�edd	d
�Ze�d�Z
e
jZe
jZe
jZe
jZej Z!ej"r�e#Z$dd
�d�%�D�Z&e'dd�e&D���sJ�dd�Z(ej"�p"ej)Z*ej"�s4ej+Z+n"e*�rBej,Z+ndd�ej+�-�D�Z+ddd�Z.ej/�rxej"�sxde.d<z4e+�0d�Z1e1�s�e�2��3d��p�dZ1e.�0e1e1�Z1Wnej4�y�dZ1Yn0e+�0dd�Z5dZ6Gdd	�d	e7�Z8Gdd �d e7�Z9d!d"�Z:d#d$�Z;d%d&�Z<d'd(�Z=d)d*�Z>ej"�r6e<Z?e=Z@e>ZAnd+d,�Z?d-d.�Z@ejBZAd/d0�ZCd1d2�ZDd3d4�ZEe*�s�ej/�r�ej"�r�Gd5d6�d6eF�ZGeG�Z+ej+�-�D]&\ZHZIe:eI�3d7��e+e:eH�3d7��<�q�e�Jd8�ZKej"�r�ej/�r�d9d:�ZLnejMZLnejLZLe!e+�0d;d<�d=k�rd>�pd?�ZNd@dA�ZOdBdC�ZPdDdE�ZQdWdHdI�ZRGdJdK�dKeS�ZTdXdLdM�ZUej"�r^dNZVndOZVgdP�ZWdQdR�ZXdSdT�ZYdUdV�ZZdS)Y�)�absolute_import�print_functionN�)�getattr)�error�policy�pycompat)�
charencode)�Any�Callable�List�Text�Type�TypeVar�Union�
_Tlocalstr�localstr)�boundr	cCs g|]}tt|d���d��qS)��utf-8)�unichr�int�encode)�.0�x�r�8/usr/lib64/python3.9/site-packages/mercurial/encoding.py�
<listcomp>8s�rsO200c 200d 200e 200f 202a 202b 202c 202d 202e 206a 206b 206c 206d 206e 206f feffccs|]}|�d�VqdS))����N)�
startswith)r�irrr�	<genexpr>>�r"cCs*d|vsd|vr&tD]}|�|d�}q|S)u�Remove codepoints ignored by HFS+ from s.

    >>> hfsignoreclean(u'.h‌g'.encode('utf-8'))
    '.hg'
    >>> hfsignoreclean(u'.hg'.encode('utf-8'))
    '.hg'
    rrr#)�_ignore�replace)�s�crrr�hfsignorecleanAs	r(cCs"i|]\}}|�d�|�d��qS)r)r)r�k�vrrr�
<dictcomp>Zs�r+sascii)s646sANSI_X3.4-1968sutf-8scp65001s
HGENCODING�asciisHGENCODINGMODEsstricts
ISO-8859-1cs6eZdZdZdd�Zejr&�fdd�Zdd�Z�Z	S)rzdThis class allows strings that are unmodified to be
    round-tripped to the local encoding and backcCst�||�}||_|S�N)�bytes�__new__�_utf8)�cls�u�lr&rrrr/xszlocalstr.__new__cstt|��|�||_dSr-)�superr�__init__r0)�selfr2r3��	__class__rrr5szlocalstr.__init__cCs
t|j�Sr-)�hashr0)r6rrr�__hash__�szlocalstr.__hash__)
�__name__�
__module__�__qualname__�__doc__r/r�
TYPE_CHECKINGr5r:�
__classcell__rrr7rrts
c@seZdZdZdS)�safelocalstraDTagged string denoting it was previously an internal UTF-8 string,
    and can be converted back to UTF-8 losslessly

    >>> assert safelocalstr(b'\xc3') == b'\xc3'
    >>> assert b'\xc3' == safelocalstr(b'\xc3')
    >>> assert b'\xc3' in {safelocalstr(b'\xc3'): 0}
    >>> assert safelocalstr(b'\xc3') in {b'\xc3': 0}
    N)r;r<r=r>rrrrrA�srAcCsNt|�r|S�zzV|�d�}tdkr,|WWS|�tt�d�}||�tt��krZt|�WWSt||�WWSt�y
zX|�tt��}|�tt�d�}||�tt��kr�t|�WYWSt|�d�|�WYWSt�y|�dd�}|�tt�d�YYWS0Yn0Wn:t	�yH}z t
jt�
|�dd��WYd}~n
d}~00dS)a�
    Convert a string from internal UTF-8 to local encoding

    All internal strings should be UTF-8 but some repos before the
    implementation of locale support may contain latin1 or possibly
    other character sets. We attempt to decode everything strictly
    using UTF-8, then Latin-1, and failing that, we use UTF-8 and
    replace unknown characters.

    The localstr class is used to cache the known UTF-8 encoding of
    strings next to their local representation to allow lossless
    round-trip conversion back to UTF-8.

    >>> u = b'foo: \xc3\xa4' # utf-8
    >>> l = tolocal(u)
    >>> l
    'foo: ?'
    >>> fromlocal(l)
    'foo: \xc3\xa4'
    >>> u2 = b'foo: \xc3\xa1'
    >>> d = { l: 1, tolocal(u2): 2 }
    >>> len(d) # no collision
    2
    >>> b'foo: ?' in d
    False
    >>> l1 = b'foo: \xe4' # historical latin1 fallback
    >>> l = tolocal(l1)
    >>> l
    'foo: ?'
    >>> fromlocal(l) # magically in utf-8
    'foo: \xc3\xa4'
    zUTF-8sUTF-8r%r�!please check your locale settings��hintN)�
isasciistr�decode�encodingr�_sysstrrAr�UnicodeDecodeError�fallbackencoding�LookupErrorr�Abortr�bytestr)r&r2�rr)rrr�tolocal�s2#
&
�rOc
Cs�t|t�r|jSt|�r|Sz |�tt�tt��}|�d�WSt	y�}zB|t
d|jd�|jd�}t�
d|t�|�f��WYd}~n@d}~0ty�}z tj
t�|�dd��WYd}~n
d}~00dS)a�
    Convert a string from the local character encoding to UTF-8

    We attempt to decode strings using the encoding mode set by
    HGENCODINGMODE, which defaults to 'strict'. In this mode, unknown
    characters will cause an error message. Other modes include
    'replace', which replaces unknown characters with a special
    Unicode character, and 'ignore', which drops the character.
    rr�
sdecoding near '%s': %s!NrBrC)�
isinstancerr0rErFrHrG�encodingmoderrI�max�startrrLrrMrK)r&r2�inst�subr)rrr�	fromlocal�s 
�
�rWcCst|�d��S)z;Convert a unicode string to a byte string of local encodingr)rOr)r2rrr�
unitolocal�srXcCst|��d�S)z;Convert a byte string of local encoding to a unicode stringr)rWrF�r&rrr�unifromlocal�srZcs�fdd�}|S)z^Create a proxy method that forwards __unicode__() and __str__() of
    Python 3 to __bytes__()cst�|��Sr-)rZ)�obj��	bytesfuncrr�unifunc	szunimethod.<locals>.unifuncr)r]r^rr\r�	unimethodsr_cCs|Sr-rrYrrr�
strtolocalsr`cCs|Sr-rrYrrr�strfromlocalsrac
Cs�z
t|�WStyYn0zRt|t�r8|j�d�}n|�tt�tt��}|�	�}||krb|WS|�
tt��WSty�|�	�YSty�}z t
jt�|�dd��WYd}~n
d}~00dS)�9best-effort encoding-aware case-folding of local string srrBrCN)�
asciilowerrIrQrr0rFrHrGrR�lowerr�UnicodeErrorrKrrLrrM)r&r2Zlur)rrrrd#s$


�rdcCs*z
t|�WSty$t|�YS0dS)rbN)�
asciiupperrI�
upperfallbackrYrrr�upper<s
rhc
Cs�zRt|t�r|j�d�}n|�tt�tt��}|��}||krD|WS|�tt��WSt	yl|��YSt
y�}z tjt
�|�dd��WYd}~n
d}~00dS)NrrBrC)rQrr0rFrHrGrRrhrrerKrrLrrM)r&r2�uur)rrrrgEs

�rgcs"eZdZdZd�fdd�	Z�ZS)�WindowsEnvironzE`os.environ` normalizes environment variables to uppercase on windowsNcst��t|�|�Sr-)r4�getrh)r6�key�defaultr7rrrkaszWindowsEnviron.get)N)r;r<r=r>rkr@rrr7rrj^srjrs^[a-z]:cCsFt��}tj�|�}t|�}t�|�rB|dd���|dd�}|S)Nrr)�os�getcwd�path�realpathr`�DRIVE_RE�matchrh)�cwdrrrro~s
rosHGENCODINGAMBIGUOUSsnarrowswidesWFAsWFcCst|�tt�d��S)zCFind the column width of a string for display in the local encodingr%)�	ucolwidthrFrHrGrYrrr�colwidth�srvcs2ttdd���dur*t�fdd�|D��St|�S)z5Find the column width of a Unicode string for display�east_asian_widthNcs g|]}�|�tvrdpd�qS)�r)�_wide)rr'�Zeawrrr�r#zucolwidth.<locals>.<listcomp>)r�unicodedata�sum�len)�drrzrru�srucCsFt�||t|��D]$}|||�}t|�|kr|Sqtd��dS)zOUse colwidth to find a c-column substring of s starting at byte
    index startzsubstring not foundN)rZxranger}rv�
ValueError)r&rTr'r�trrr�getcols�s

r�r#Fc	CsPz|�tt��}Wn|ty�t|�|kr4|YS|t|�8}|dkr`|d|t|��YS|rz|||d�YS|d|�|YS0t|�|kr�|S|t|�8}|dkr�|d|t|��St|�}|r�|��d}t|�D]"\}}|t|�7}||kr��qq�|d|�}|�r&|��d�	|��
tt��}|�rH||S||S)u�Trim string 's' to at most 'width' columns (including 'ellipsis').

    If 'leftside' is True, left side of string 's' is trimmed.
    'ellipsis' is always placed at trimmed side.

    >>> from .node import bin
    >>> def bprint(s):
    ...     print(pycompat.sysstr(s))
    >>> ellipsis = b'+++'
    >>> from . import encoding
    >>> encoding.encoding = b'utf-8'
    >>> t = b'1234567890'
    >>> bprint(trim(t, 12, ellipsis=ellipsis))
    1234567890
    >>> bprint(trim(t, 10, ellipsis=ellipsis))
    1234567890
    >>> bprint(trim(t, 8, ellipsis=ellipsis))
    12345+++
    >>> bprint(trim(t, 8, ellipsis=ellipsis, leftside=True))
    +++67890
    >>> bprint(trim(t, 8))
    12345678
    >>> bprint(trim(t, 8, leftside=True))
    34567890
    >>> bprint(trim(t, 3, ellipsis=ellipsis))
    +++
    >>> bprint(trim(t, 1, ellipsis=ellipsis))
    +
    >>> u = u'あいうえお' # 2 x 5 = 10 columns
    >>> t = u.encode(pycompat.sysstr(encoding.encoding))
    >>> bprint(trim(t, 12, ellipsis=ellipsis))
    あいうえお
    >>> bprint(trim(t, 10, ellipsis=ellipsis))
    あいうえお
    >>> bprint(trim(t, 8, ellipsis=ellipsis))
    あい+++
    >>> bprint(trim(t, 8, ellipsis=ellipsis, leftside=True))
    +++えお
    >>> bprint(trim(t, 5))
    あい
    >>> bprint(trim(t, 5, leftside=True))
    えお
    >>> bprint(trim(t, 4, ellipsis=ellipsis))
    +++
    >>> bprint(trim(t, 4, ellipsis=ellipsis, leftside=True))
    +++
    >>> t = bin(b'112233445566778899aa') # invalid byte sequence
    >>> bprint(trim(t, 12, ellipsis=ellipsis))
    "3DUfwˆ™ª
    >>> bprint(trim(t, 10, ellipsis=ellipsis))
    "3DUfwˆ™ª
    >>> bprint(trim(t, 8, ellipsis=ellipsis))
    "3DU+++
    >>> bprint(trim(t, 8, ellipsis=ellipsis, leftside=True))
    +++fwˆ™ª
    >>> bprint(trim(t, 8))
    "3DUfwˆ
    >>> bprint(trim(t, 8, leftside=True))
    3DUfwˆ™ª
    >>> bprint(trim(t, 3, ellipsis=ellipsis))
    +++
    >>> bprint(trim(t, 1, ellipsis=ellipsis))
    +
    rN�)rFrHrGrIr}ru�list�reverse�	enumerate�joinr)	r&�widthZellipsisZleftsider2�charsZwidth_so_farr!r'rrr�trim�s>Br�c@seZdZdZdZdZdZdS)�
normcasespecsaxwhat a platform's normcase does to ASCII strings

    This is specified per platform, and should be consistent with what normcase
    on that platform actually does.

    lower: normcase lowercases ASCII strings
    upper: normcase uppercases ASCII strings
    other: the fallback function should always be called

    This should be kept in sync with normcase_spec in util.h.���rrN)r;r<r=r>rdrh�otherrrrrr�sr�cCs4t|�}zt||�WSty&Yn0t�||�S)a�returns a string suitable for JSON

    JSON is problematic for us because it doesn't support non-Unicode
    bytes. To deal with this, we take the following approach:

    - localstr/safelocalstr objects are converted back to UTF-8
    - valid UTF-8/ASCII strings are passed as-is
    - other strings are converted to UTF-8b surrogate encoding
    - apply JSON-specified string escaping

    (escapes are doubled in these tests)

    >>> jsonescape(b'this is a test')
    'this is a test'
    >>> jsonescape(b'escape characters: \0 \x0b \x7f')
    'escape characters: \\u0000 \\u000b \\u007f'
    >>> jsonescape(b'escape characters: \b \t \n \f \r \" \\')
    'escape characters: \\b \\t \\n \\f \\r \\" \\\\'
    >>> jsonescape(b'a weird byte: \xdd')
    'a weird byte: \xed\xb3\x9d'
    >>> jsonescape(b'utf-8: caf\xc3\xa9')
    'utf-8: caf\xc3\xa9'
    >>> jsonescape(b'')
    ''

    If paranoid, non-ascii and common troublesome characters are also escaped.
    This is suitable for web output.

    >>> s = b'escape characters: \0 \x0b \x7f'
    >>> assert jsonescape(s) == jsonescape(s, paranoid=True)
    >>> s = b'escape characters: \b \t \n \f \r \" \\'
    >>> assert jsonescape(s) == jsonescape(s, paranoid=True)
    >>> jsonescape(b'escape boundary: \x7e \x7f \xc2\x80', paranoid=True)
    'escape boundary: ~ \\u007f \\u0080'
    >>> jsonescape(b'a weird byte: \xdd', paranoid=True)
    'a weird byte: \\udcdd'
    >>> jsonescape(b'utf-8: caf\xc3\xa9', paranoid=True)
    'utf-8: caf\\u00e9'
    >>> jsonescape(b'non-BMP: \xf0\x9d\x84\x9e', paranoid=True)
    'non-BMP: \\ud834\\udd1e'
    >>> jsonescape(b'<foo@example.org>', paranoid=True)
    '\\u003cfoo@example.org\\u003e'
    )�toutf8b�_jsonescapeu8fastr�charencodepureZjsonescapeu8fallback)r&ZparanoidZu8charsrrr�
jsonescape$s.r��
surrogatepass�strict)rrrrrrrrrrrrrxrx��cCsPtt|||d��d?}|s0|||d�S||||�}|�dt�|S)z�get the next full utf-8 character in the given string, starting at pos

    Raises a UnicodeError if the given location does not start a valid
    utf-8 character.
    rr�r)�_utf8len�ordrF�_utf8strict)r&�posr3r'rrr�getutf8chards	r�cCs t|t�r|jSt|t�r"t|�St|�r.|Sd|vr\z|�dt�|WStyZYn0t	�
|�}d}d}t|�}||k�rzXt||�}d|kr�dkr�nn&t
dt||���dt�}|d7}n|t|�7}Wn8t�yt
dt||���dt�}|d7}Yn0||7}qv|S)	aBconvert a local, possibly-binary string into UTF-8b

    This is intended as a generic method to preserve data when working
    with schemes like JSON and XML that have no provision for
    arbitrary byte strings. As Mercurial often doesn't know
    what encoding data is in, we use so-called UTF-8b.

    If a string is already valid UTF-8 (or ASCII), it passes unmodified.
    Otherwise, unsupported bytes are mapped to UTF-16 surrogate range,
    uDC00-uDCFF.

    Principles of operation:

    - ASCII and UTF-8 data successfully round-trips and is understood
      by Unicode-oriented clients
    - filenames and file contents in arbitrary other encodings can have
      be round-tripped or recovered by clueful clients
    - local strings that have a cached known UTF-8 encoding (aka
      localstr) get sent as UTF-8 so Unicode-oriented clients get the
      Unicode data they want
    - non-lossy local strings (aka safelocalstr) get sent as UTF-8 as well
    - because we must preserve UTF-8 bytestring in places such as
      filenames, metadata can't be roundtripped without help

    (Note: "UTF-8b" often refers to decoding a mix of valid UTF-8 and
    arbitrary bytes into an internal Unicode format that can be
    re-encoded back into the original. Here we are exposing the
    internal surrogate encoding as a UTF-8 string.)
    ��rr#r����i�r)rQrr0rArWrErFr�rIrrMr}r�rr�r�r&rNr�r3r'rrrr�ws8 






r�cCs�t|�r|Sd|vr|St�|�}d}d}t|�}||kr�t||�}|t|�7}d|krddkr�nnt�t|�dt��d@�}||7}q2|S)aWGiven a UTF-8b string, return a local, possibly-binary string.

    return the original binary string. This
    is a round-trip process for strings like filenames, but metadata
    that's was passed through tolocal will remain in UTF-8.

    >>> roundtrip = lambda x: fromutf8b(toutf8b(x)) == x
    >>> m = b"\xc3\xa9\x99abcd"
    >>> toutf8b(m)
    '\xc3\xa9\xed\xb2\x99abcd'
    >>> roundtrip(m)
    True
    >>> roundtrip(b"\xc2\xc2\x80")
    True
    >>> roundtrip(b"\xef\xbf\xbd")
    True
    >>> roundtrip(b"\xef\xef\xbf\xbd")
    True
    >>> roundtrip(b"\xf1\x80\x80\x80\x80")
    True
    r�r#rr�r�r�)	rErrMr}r�Zbytechrr�rFr�r�rrr�	fromutf8b�s


r�)r#F)F)[Z
__future__rr�localern�rer{rrr�rrZpurer	r�r?�typingr
rrr
rrrr�rZ	importmodrErcrfZjsonescapeu8fastr�ZsysstrrHZispy3�chrr�splitr$�allr(�supports_bytes_environZ_nativeenviron�environ�environb�itemsZ_encodingrewritesZ	iswindowsrkrG�getpreferredencodingr�ErrorrRrJr.rrArOrWrXrZr_r`raZ	strmethod�identityrdrhrg�dictrjr)r*�compilerrro�getcwdbryrvrur�r��objectr�r�r�r�r�r�r�rrrr�<module>s�$

���

E 	 

	��	
f
8E

Youez - 2016 - github.com/yon3zu
LinuXploit