Yohohohohohooho | Sanrei Aya
Sanrei Aya


Server : LiteSpeed
System : Linux barito.iixcp.rumahweb.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : elvh3918 ( 1528)
PHP Version : 8.2.31
Disable Function : mail
Directory :  /usr/local/lib/python3.9/site-packages/prompt_toolkit/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/local/lib/python3.9/site-packages/prompt_toolkit/__pycache__/utils.cpython-39.pyc
a

��Sh�!�@s�ddlmZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZmZm
Z
mZmZddlmZgd�ZdejvZedd	d
�ZGdd�de
e�ZGd
d�de
d�ZGdd�deeef�Ze�Zddd�dd�Zdd�dd�Zdd�dd�Zdd�dd�Zdd�dd�Zdd�d d!�Z dd�d"d#�Z!dd�d$d%�Z"ed&�Z#d'd(d)d*�d+d,�Z$d-dd.�d/d0�Z%d1dd.�d2d3�Z&ee	ge'fe'fZ(d4d5d.�d6d7�Z)d<d8dd9�d:d;�Z*dS)=�)�annotationsN)�deque)�Callable�ContextManager�Dict�	Generator�Generic�TypeVar�Union)�wcwidth)�Event�DummyContext�
get_cwidth�suspend_to_background_supported�is_conemu_ansi�
is_windows�in_main_thread�get_bell_environment_variable�get_term_environment_variable�take_using_weights�to_str�to_int�AnyFloat�to_float�is_dumb_terminalzsphinx.ext.autodoc�_SenderT)�	covariantc@s�eZdZdZddddd�dd�Zdd	�d
d�Zdd	�dd
�Zddd�dd�Zddd�dd�Zddd�dd�Z	ddd�dd�Z
dS)ra�
    Simple event to which event handlers can be attached. For instance::

        class Cls:
            def __init__(self):
                # Define event. The first parameter is the sender.
                self.event = Event(self)

        obj = Cls()

        def handler(sender):
            pass

        # Add event handler by using the += operator.
        obj.event += handler

        # Fire event.
        obj.event()
    Nrz Callable[[_Sender], None] | None�None)�sender�handler�returncCs ||_g|_|dur||7}dS�N)r�	_handlers)�selfrr�r$�>/usr/local/lib/python3.9/site-packages/prompt_toolkit/utils.py�__init__BszEvent.__init__�r cCs|jD]}||j�qdS)zFire event.N)r"r�r#rr$r$r%�__call__Ks
zEvent.__call__cCs
|�dS)z!Alias for just calling the event.Nr$�r#r$r$r%�firePsz
Event.firezCallable[[_Sender], None])rr cCs|j�|�dS)z�
        Add another handler to this callback.
        (Handler should be a callable that takes exactly one parameter: the
        sender object.)
        N)r"�appendr(r$r$r%�add_handlerTszEvent.add_handlercCs||jvr|j�|�dS)z6
        Remove a handler from this callback.
        N)r"�remover(r$r$r%�remove_handler]s
zEvent.remove_handlerzEvent[_Sender]cCs|�|�|S)zC
        `event += handler` notation for adding a handler.
        )r-r(r$r$r%�__iadd__ds
zEvent.__iadd__cCs|�|�|S)zE
        `event -= handler` notation for removing a handler.
        )r/r(r$r$r%�__isub__ks
zEvent.__isub__)N)�__name__�
__module__�__qualname__�__doc__r&r)r+r-r/r0r1r$r$r$r%r-s�		rc@s.eZdZdZdd�dd�Zddd�dd	�Zd
S)r
z5
    (contextlib.nested is not available on Py3)
    rr'cCsdSr!r$r*r$r$r%�	__enter__xszDummyContext.__enter__�object)�ar cGsdSr!r$)r#r8r$r$r%�__exit__{szDummyContext.__exit__N)r2r3r4r5r6r9r$r$r$r%r
ssr
cs>eZdZdZdZdZdd��fdd�Zdd	d
�dd�Z�ZS)
�_CharSizesCachez"
    Cache for wcwidth sizes.
    �@�rr'cst���t�|_dSr!)�superr&r�
_long_stringsr*��	__class__r$r%r&�s
z_CharSizesCache.__init__�str�int��stringr cs�t|�dkrtdt|��}nt�fdd�|D��}|�|<t|��jkr|�j}|�|�t|��jkr||��}|�vr|�|=|S)N�rc3s|]}�|VqdSr!r$)�.0�cr*r$r%�	<genexpr>��z._CharSizesCache.__missing__.<locals>.<genexpr>)	�len�maxr�sum�LONG_STRING_MIN_LENr>r,�MAX_LONG_STRINGS�popleft)r#rD�resultZlong_stringsZ
key_to_remover$r*r%�__missing__�s
z_CharSizesCache.__missing__)	r2r3r4r5rMrNr&rQ�
__classcell__r$r$r?r%r:s
r:rArBrCcCst|S)z?
    Return width of a string. Wrapper around ``wcwidth``.
    )�_CHAR_SIZES_CACHE)rDr$r$r%r�sr�boolr'cCs
ttd�S)z�
    Returns `True` when the Python implementation supports
    suspend-to-background. This is typically `False' on Windows systems.
    �SIGTSTP)�hasattr�signalr$r$r$r%r�srcCs
tjdkS)z)
    True when we are using Windows.
    �win32)�sys�platformr$r$r$r%r�srcCs tjdkrddlm}|�SdS)zS
    True when we are using Windows, but VT100 escape sequences are supported.
    rXr��is_win_vt100_enabledF)rYrZZprompt_toolkit.output.windows10r\r[r$r$r%�is_windows_vt100_supported�s
r]cCstjdkotj�dd�dkS)z7
    True when the ConEmu Windows console is used.
    rXZ
ConEmuANSIZOFF�ON)rYrZ�os�environ�getr$r$r$r%r�srcCst��jjdkS)z:
    True when the current thread is the main thread.
    �_MainThread)�	threading�current_threadr@r2r$r$r$r%r�srcCstj�dd�}|��dvS)zD
    True if env variable is set to true (true, TRUE, True, 1).
    ZPROMPT_TOOLKIT_BELL�true)�1re)r_r`ra�lower��valuer$r$r%r�srcCstj�dd�S)z&Return the $TERM environment variable.�TERM�)r_r`rar$r$r$r%r�sr�_Tzlist[_T]z	list[int]zGenerator[_T, None, None])�items�weightsr c
cs�t|�t|�ksJ�t|�dks$J�g}g}t||�D]$\}}|dkr6|�|�|�|�q6|}|}|sptd��dd�|D�}t|�}t|�}d}	d}
|
r�d}
tt|�||�D]<\}}}|||	|t|�kr�|V||d7<d}
q�q�|	d7}	q�dS)	a�
    Generator that keeps yielding items from the items list, in proportion to
    their weight. For instance::

        # Getting the first 70 items from this generator should have yielded 10
        # times A, 20 times B and 40 times C, all distributed equally..
        take_using_weights(['A', 'B', 'C'], [5, 10, 20])

    :param items: List of items to take from.
    :param weights: Integers representing the weight. (Numbers have to be
                    integers, not floats.)
    rz+Did't got any items with a positive weight.cSsg|]}d�qS)rr$)rF�ir$r$r%�
<listcomp>rIz&take_using_weights.<locals>.<listcomp>TFrEN)rJ�zipr,�
ValueErrorrK�range�float)
rmrnZitems2Zweights2�item�wZ
already_takenZ
item_countZ
max_weightroZaddingZitem_iZweightr$r$r%r�s2
rzCallable[[], str] | str)rir cCst|�rt|��St|�SdS)z$Turn callable or string into string.N)�callablerrArhr$r$r%r"s
rzCallable[[], int] | intcCst|�rt|��St|�SdS)zTurn callable or int into int.N)rwrrBrhr$r$r%r*s
rrrtcCst|�rt|��St|�SdS)z"Turn callable or float into float.N)rwrrtrhr$r$r%r5s
rz
str | None)�termr cCs&|durttj�dd��S|��dvS)z�
    True if this terminal type is considered "dumb".

    If so, we should fall back to the simplest possible form of line editing,
    without cursor positioning and color support.
    Nrjrk)Zdumb�unknown)rr_r`rarg)rxr$r$r%r=sr)N)+�
__future__rr_rWrYrc�collectionsr�typingrrrrrr	r
r�__all__�modulesZSPHINX_AUTODOC_RUNNINGrrr
rArBr:rSrrrr]rrrrrlrrrrtrrrr$r$r$r%�<module>s:$

F)
6

Yohohohohohooho | Sanrei Aya