AlkantarClanX12

Your IP : 3.16.70.218


Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/wcwidth/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/wcwidth/__pycache__/wcwidth.cpython-311.pyc

�

�܋f^:��R�dZddlmZddlZddlZddlZddlmZddlm	Z	ddl
mZ	ddlm
Z
n#e$r	ddlm
Z
YnwxYwdZejdd	kZegd
���Zd�Ze
d�
��dd���Zdd�Ze
d�
��d���Ze
d�
��d���ZdS)a�
This is a python implementation of wcwidth() and wcswidth().

https://github.com/jquast/wcwidth

from Markus Kuhn's C code, retrieved from:

    http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c

This is an implementation of wcwidth() and wcswidth() (defined in
IEEE Std 1002.1-2001) for Unicode.

http://www.opengroup.org/onlinepubs/007904975/functions/wcwidth.html
http://www.opengroup.org/onlinepubs/007904975/functions/wcswidth.html

In fixed-width output devices, Latin characters all occupy a single
"cell" position of equal width, whereas ideographic CJK characters
occupy two such cells. Interoperability between terminal-line
applications and (teletype-style) character terminals using the
UTF-8 encoding requires agreement on which character should advance
the cursor by how many cell positions. No established formal
standards exist at present on which Unicode character shall occupy
how many cell positions on character terminals. These routines are
a first attempt of defining such behavior based on simple rules
applied to data provided by the Unicode Consortium.

For some graphical characters, the Unicode standard explicitly
defines a character-cell width via the definition of the East Asian
FullWidth (F), Wide (W), Half-width (H), and Narrow (Na) classes.
In all these cases, there is no ambiguity about which width a
terminal shall use. For characters in the East Asian Ambiguous (A)
class, the width choice depends purely on a preference of backward
compatibility with either historic CJK or Western practice.
Choosing single-width for these characters is easy to justify as
the appropriate long-term solution, as the CJK practice of
displaying these characters as double-width comes from historic
implementation simplicity (8-bit encoded characters were displayed
single-width and 16-bit ones double-width, even for Greek,
Cyrillic, etc.) and not any typographic considerations.

Much less clear is the choice of width for the Not East Asian
(Neutral) class. Existing practice does not dictate a width for any
of these characters. It would nevertheless make sense
typographically to allocate two character cells to characters such
as for instance EM SPACE or VOLUME INTEGRAL, which cannot be
represented adequately with a single-width glyph. The following
routines at present merely assign a single-cell width to all
neutral characters, in the interest of simplicity. This is not
entirely satisfactory and should be reconsidered before
establishing a formal standard in this area. At the moment, the
decision which Not East Asian (Neutral) characters should be
represented by double-width glyphs cannot yet be answered by
applying a simple rule from the Unicode database content. Setting
up a proper standard for the behavior of UTF-8 character terminals
will require a careful analysis not only of each Unicode character,
but also of each presentation form, something the author of these
routines has avoided to do so far.

http://www.unicode.org/unicode/reports/tr11/

Latest version: http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
�)�divisionN�)�WIDE_EASTASIAN)�
ZERO_WIDTH)�
list_versions)�	lru_cache�)riOi i i
 i i i( i) i* i+ i, i- i. i` ia ib ic c��d}t|��dz
}||ddks|||dkrdS||kr@||zdz}|||dkr|dz}n|||dkr|dz
}ndS||k�@dS)aJ
    Auxiliary function for binary search in interval table.

    :arg int ucs: Ordinal value of unicode character.
    :arg list table: List of starting and ending ranges of ordinal values,
        in form of ``[(start, end), ...]``.
    :rtype: int
    :returns: 1 if ordinal value ucs is found within lookup table, else 0.
    rr�)�len)�ucs�table�lbound�ubound�mids     �F/opt/cloudlinux/venv/lib64/python3.11/site-packages/wcwidth/wcwidth.py�	_bisearchrrs����F�
��Z�Z�!�^�F�
�U�1�X�a�[���C�%��-��"2�2�2��q�
�F�
�
����1�$����s��A�����1�W�F�F�
�5��:�a�=�
 �
 ��1�W�F�F��1��F�
�
�
�1�i�)�maxsize�autoc��t|��}|tvrdS|dksd|cxkrdkrnndSt|��}t|t|��rdSdt|t
|��zS)a�
    Given one Unicode character, return its printable length on a terminal.

    :param str wc: A single Unicode character.
    :param str unicode_version: A Unicode version number, such as
        ``'6.0.0'``, the list of available version levels may be
        listed by pairing function :func:`list_versions`.

        Any version string may be specified without error -- the nearest
        matching version is selected.  When ``latest`` (default), the
        highest Unicode version level is used.
    :return: The width, in cells, necessary to display the character of
        Unicode string character, ``wc``.  Returns 0 if the ``wc`` argument has
        no printable effect on a terminal (such as NUL '\0'), -1 if ``wc`` is
        not printable, or has an indeterminate effect on the terminal, such as
        a control character.  Otherwise, the number of column positions the
        character occupies on a graphic terminal (1 or 2) is returned.
    :rtype: int

    The following have a column width of -1:

        - C0 control characters (U+001 through U+01F).

        - C1 control characters and DEL (U+07F through U+0A0).

    The following have a column width of 0:

    - Non-spacing and enclosing combining characters (general
      category code Mn or Me in the Unicode database).

    - NULL (``U+0000``).

    - COMBINING GRAPHEME JOINER (``U+034F``).

    - ZERO WIDTH SPACE (``U+200B``) *through*
      RIGHT-TO-LEFT MARK (``U+200F``).

    - LINE SEPARATOR (``U+2028``) *and*
      PARAGRAPH SEPARATOR (``U+2029``).

    - LEFT-TO-RIGHT EMBEDDING (``U+202A``) *through*
      RIGHT-TO-LEFT OVERRIDE (``U+202E``).

    - WORD JOINER (``U+2060``) *through*
      INVISIBLE SEPARATOR (``U+2063``).

    The following have a column width of 1:

    - SOFT HYPHEN (``U+00AD``).

    - All remaining characters, including all printable ISO 8859-1
      and WGL4 characters, Unicode control characters, etc.

    The following have a column width of 2:

        - Spacing characters in the East Asian Wide (W) or East Asian
          Full-width (F) category as defined in Unicode Technical
          Report #11 have a column width of 2.

         - Some kinds of Emoji or symbols.
    r� �����r)�ord�
ZERO_WIDTH_CF�_wcmatch_versionrrr)�wc�unicode_versionr
�_unicode_versions    r�wcwidthr"�s���D�b�'�'�C�
�m����q��R�x�x�5�C�'�'�'�'�%�'�'�'�'�'��r�'��8�8����j�!1�2�3�3���q�
�y��n�-=�>�?�?�?�?rc��|�t|��n|}td|��}d}||D] }t||��}|dkrdS||z
}�!|S)a	
    Given a unicode string, return its printable length on a terminal.

    :param str pwcs: Measure width of given unicode string.
    :param int n: When ``n`` is None (default), return the length of the
        entire string, otherwise width the first ``n`` characters specified.
    :param str unicode_version: An explicit definition of the unicode version
        level to use for determination, may be ``auto`` (default), which uses
        the Environment Variable, ``UNICODE_VERSION`` if defined, or the latest
        available unicode version, otherwise.
    :rtype: int
    :returns: The width, in cells, necessary to display the first ``n``
        characters of the unicode string ``pwcs``.  Returns ``-1`` if
        a non-printable character is encountered.
    Nrr)r�slicer")�pwcs�nr �end�idx�width�char�wcws        r�wcswidthr,�sk��&�y�#�d�)�)�)�a�C�
��3�-�-�C�
�E��S�	�����d�O�,�,����7�7��2�2�
������Lr�c�p�ttt|�d������}|S)z�
    Integer-mapped value of given dotted version string.

    :param str ver_string: Unicode version string, of form ``n.n.n``.
    :rtype: tuple(int)
    :returns: tuple of digit tuples, ``tuple(int, [...])``.
    �.)�tuple�map�int�split)�
ver_string�retvals  r�_wcversion_valuer6�s.���3�s�Z�-�-�c�2�2�4�4�
5�
5�F��Mr�c�2�tot|t��}|rd�t��D��}nt��}|d}|dvr6tj�d|sdn|�����}|dvr|s|n|���S||vr|s|n|���S	t|��}nQ#t$rDtjd�||�����|s|n|���cYSwxYw|d	}t|��}||krAtjd
�||�����|s|n|���St|��D]{\}}	t||dz��}	n*#t$r|s|n|���cYcSwxYw||	d
t|���kr
||dzcS|	|kr|cS�|Jd||f���)aT
    Return nearest matching supported Unicode version level.

    If an exact match is not determined, the nearest lowest version level is
    returned after a warning is emitted.  For example, given supported levels
    ``4.1.0`` and ``5.0.0``, and a version string of ``4.9.9``, then ``4.1.0``
    is selected and returned:

    >>> _wcmatch_version('4.9.9')
    '4.1.0'
    >>> _wcmatch_version('8.0')
    '8.0.0'
    >>> _wcmatch_version('1')
    '4.1.0'

    :param str given_version: given version for compare, may be ``auto``
        (default), to select Unicode Version from Environment Variable,
        ``UNICODE_VERSION``. If the environment variable is not set, then the
        latest is used.
    :rtype: str
    :returns: unicode string, or non-unicode ``str`` type for python 2
        when given ``version`` is also type ``str``.
    c�6�g|]}|�����S�)�encode)�.0r
s  r�
<listcomp>z$_wcmatch_version.<locals>.<listcomp>.s ��D�D�D�S�C�J�J�L�L�D�D�Drr)rr�UNICODE_VERSION�latest)r?r?z�UNICODE_VERSION value, {given_version!r}, is invalid. Value should be in form of `integer[.]+', the latest supported unicode version {latest_version!r} has been inferred.)�
given_version�latest_versionrz�UNICODE_VERSION value, {given_version!r}, is lower than any available unicode version. Returning lowest version level, {earliest_version!r})r@�earliest_versionrNFzCode path unreachable)�_PY3�
isinstance�strr�os�environ�getr;r6�
ValueError�warnings�warn�format�	enumerate�
IndexErrorr)
r@�_return_str�unicode_versionsrA�	cmp_givenrB�cmp_earliest_versionr(r �cmp_next_versions
          rrrs���>�(�=�z�-��=�=�K��+�D�D�M�O�O�D�D�D���(�?�?��%�b�)�N��)�)�)��
����'�D�H�H�^�-B�-B�-D�-D�F�F�
��-�-�-�&1�M�~�~�n�6K�6K�6M�6M�M��(�(�(�%0�K�}�}�]�5I�5I�5K�5K�K�
N�$�]�3�3�	�	���N�N�N��
�"�#)�&�}�8F�#)�#H�#H�	I�	I�	I�
&1�M�~�~�n�6K�6K�6M�6M�M�M�M�N����(��*��+�,<�=�=���(�(�(�	�
�<�<B�F�(5�+;�=C�==�==�	>�	>�	>�
(3�Q���8H�8O�8O�8Q�8Q�Q�!*�*:� ;� ;�#�#���_�	R�/�0@��q��0I�J�J�����	R�	R�	R�)4�Q�>�>�.�:O�:O�:Q�:Q�Q�Q�Q�Q�Q�	R�����(��#�i�.�.��9�9�9�#�C�!�G�,�,�,�,��i�'�'�"�"�"�"�(�L�*�M�;K�L�L�L�5s%�C�AD �D �F/�/"G�G)r)Nr)�__doc__�
__future__rrF�sysrJ�
table_wider�
table_zerorrPr�	functoolsr�ImportError�backports.functools_lru_cache�_UNICODE_CMPTABLE�version_inforC�setrrr"r,r6rr:rr�<module>r_s���=�=�| ������
�	�	�	�
�
�
�
�����'�&�&�&�&�&�"�"�"�"�"�"�+�+�+�+�+�+�8�#�#�#�#�#�#�#���8�8�8�8�7�7�7�7�7�7�7�8����������q� ���������
�,
�
�
�6��4����P@�P@�P@���P@�f����<��3����	�	���	���1����mM�mM���mM�mM�mMs�/�=�=