%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/python/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/python/__pycache__/compat.cpython-312.pyc

�

Ϫ�f�A��X�dZddlZddlZddlZddlZddlmZddlZddl	m
Z
ddlmZddl
mZddlmZddlmZmZmZddlmZdd	lmZmZdd
lmZmZm Z ddlm!Z"m#Z$ddl%m&Z&dd
l'm(Z(m)Z)ejT�dk(rdZ+ndZ+eZ,e)e&dddd�de-d�e.Z.e)e&dddd�de-d�e/Z0e)e&dddd�de-d�e1Z2e)e&dddd�de-d�e3Z4e)e&dddd�de-d�e5Z5e)e&dddd�de-d�e6Z7e)e&dddd�d e-d!�e8Z8e)e&dddd�d"e-d#�e9Z:e)e&dddd�d$e-d%�e;Z<e)e&dddd�d&e-d'�e9Z=e)e&dddd�d$e-d(�e5Z>e)e&dddd�de-d)�e(e&dddd�d*�+�d,��Z?e(e&dddd�d-�+�d.��Z@e(e&dddd�d/�+�d0��ZAd]d1e3d2efd3�ZBd^d4�ZCd5e/d6e/d2e3fd7�ZDd8�ZEe9fd9�ZFd:ed2e9fd;�ZGd<�ZHe(e&dddd�d=�+�d>��ZId?�ZJe(e&dddd�d@�+�dAe3d2eKfdB��ZLd_dC�ZMd:e9d2eKfdD�ZNe(e&dddd�dE�+�dF��ZOdG�ZPd^dH�ZQdI�ZReR�e)e&dddd�dJe-dK�e)e&dddd�dLe-dM�e)e&dddd�dNe-dO�e)e&dddd�dPe-dQ�e)e&dddd�dRe-dS�e)e&dddd�dTe-dU�e)e&dddd�dVe-dW�e)e&dddd�dXe-dY�e)e&dddd�dZe-d[�gd\�ZSy)`a)
Compatibility module to provide backwards compatibility for useful Python
features.

This is mainly for use of internal Twisted code. We encourage you to use
the latest version of Python directly from your code, if possible.

@var unicode: The type of Unicode strings, C{unicode} on Python 2 and C{str}
    on Python 3.

@var NativeStringIO: An in-memory file-like object that operates on the native
    string type (bytes in Python 2, unicode in Python 3).

@var urllib_parse: a URL-parsing module (urlparse on Python 2, urllib.parse on
    Python 3)
�N)�Sequence)�reduce)�escape)�	cookiejar)�IOBase�StringIO�
TextIOBase)�intern)�	FrameType�
MethodType)�Any�AnyStr�cast)�quote�unquote)�Version)�
deprecated�deprecatedModuleAttribute�PyPyTF�Twisted��zObsolete alias for io.IOBase�FileTypez)Obsolete alias for frozenset builtin type�	frozensetz)Old-style classes don't exist in Python 3�InstanceTypez Obsolete alias for zip() builtin�izipz#Obsolete alias for int builtin type�longz"Obsolete alias for range() builtin�rangez"Obsolete alias for input() builtin�	raw_inputz#Obsolete alias for set builtin type�setz#Obsolete alias for str builtin type�
StringTypez Obsolete alias for chr() builtin�unichr�unicode�xrangez	d.items())�replacementc�"�|j�S)z]
    Return an iterable of the items of C{d}.

    @type d: L{dict}
    @rtype: iterable
    )�items��ds �7/usr/lib/python3/dist-packages/twisted/python/compat.py�	iteritemsr+�s��
�7�7�9��z
d.values()c�"�|j�S)z^
    Return an iterable of the values of C{d}.

    @type d: L{dict}
    @rtype: iterable
    )�valuesr(s r*�
itervaluesr/�s��
�8�8�:�r,zlist(d.items())c�4�t|j��S)zW
    Return a list of the items of C{d}.

    @type d: L{dict}
    @rtype: L{list}
    )�listr'r(s r*r'r'�s������	�?�r,�n�returnc�|�tj�}t|dz�D]}|�J�|j}�|�J�|S)a`
    In Python 3, L{inspect.currentframe} does not take a stack-level argument.
    Restore that functionality from Python 2 so we don't have to re-implement
    the C{f_back}-walking loop in places where it's called.

    @param n: The number of stack levels above the caller to walk.

    @return: a frame, n levels up the stack from the caller.
    �)�inspect�currentframer�f_back)r2�f�xs   r*r7r7�sM��	����A�
�1�q�5�\����}��}�
�H�H���
�=��=��Hr,c��|�|}t|d�5}|j�}ddd�t|d�}t|||�y#1swY�$xYw)az
    Execute a Python script in the given namespaces.

    Similar to the execfile builtin, but a namespace is mandatory, partly
    because that's a sensible thing to require, and because otherwise we'd
    have to do some frame hacking.

    This is a compatibility implementation for Python 3 porting, to avoid the
    use of the deprecated builtin C{execfile} function.
    N�rb�exec)�open�read�compiler=)�filename�globals�locals�fin�source�codes      r*�execfilerG�sT���~���	
�h��	����������6�8�V�,�D���w�����s�A�A�a�bc��||kry||k(ryy)z�
    Compare two objects.

    Returns a negative number if C{a < b}, zero if they are equal, and a
    positive number if C{a > b}.
    ���rr5�)rHrIs  r*�cmprM�s��	�1�u��	
�a���r,c�b�dtdtdtfd�}dtdtdtfd�}dtdtdtfd�}dtdtdtfd�}dtdtdtfd�}dtdtdtfd	�}||_||_||_||_||_||_|S)
z�
    Class decorator that ensures support for the special C{__cmp__} method.

    C{__eq__}, C{__lt__}, etc. methods are added to the class, relying on
    C{__cmp__} to implement their comparisons.
    �self�otherr3c�^�tt|j|��}|tur|S|dk(S�Nr�r�bool�__cmp__�NotImplemented�rOrP�cs   r*�__eq__zcomparable.<locals>.__eq__��-����t�|�|�E�*�+������H��A�v�
r,c�^�tt|j|��}|tur|S|dk7SrRrSrWs   r*�__ne__zcomparable.<locals>.__ne__�rZr,c�^�tt|j|��}|tur|S|dkSrRrSrWs   r*�__lt__zcomparable.<locals>.__lt__��-����t�|�|�E�*�+������H��1�u�r,c�^�tt|j|��}|tur|S|dkSrRrSrWs   r*�__le__zcomparable.<locals>.__le__rZr,c�^�tt|j|��}|tur|S|dkDSrRrSrWs   r*�__gt__zcomparable.<locals>.__gt__
r_r,c�^�tt|j|��}|tur|S|dk\SrRrSrWs   r*�__ge__zcomparable.<locals>.__ge__rZr,)	r
�objectrTr^rcrarerYr\)�klassrYr\r^rarcres       r*�
comparablerh�s����S����D���S����D���S����D���S����D���S����D���S����D���E�L��E�L��E�L��E�L��E�L��E�L��Lr,c���t|t�rtSt|t�rtSt|dd�}ddl}t||j|jf�r|rtStS|S)a
    Determine the type which will be returned from the given file object's
    read() and accepted by its write() method as an argument.

    In other words, determine whether the given file is 'opened in text mode'.

    @param fileIshObject: Any object, but ideally one which resembles a file.
    @type fileIshObject: L{object}

    @param default: A default value to return when the type of C{fileIshObject}
        cannot be determined.
    @type default: L{type}

    @return: There are 3 possible return values:

            1. L{str}, if the file is unambiguously opened in text mode.

            2. L{bytes}, if the file is unambiguously opened in binary mode.

            3. The C{default} parameter, if the given type is not understood.

    @rtype: L{type}
    �encodingNr)	�
isinstancer	�strr�bytes�getattr�codecs�StreamReader�StreamWriter)�
fileIshObject�defaultrjros    r*�ioTypertsb��0�-��,��
��-��(����}�j�$�7�H���-�&�"5�"5�v�7J�7J�!K�L���J��L��Nr,�sc��t|ttf�std|z��t|t�r|j	d�S|jd�|S)z�
    Convert C{bytes} or C{str} to C{str} type, using ASCII encoding if
    conversion is necessary.

    @raise UnicodeError: The input string is not ASCII encodable/decodable.
    @raise TypeError: The input is neither C{bytes} nor C{str}.
    z%r is neither bytes nor str�ascii)rkrmrl�	TypeError�decode�encode�rus r*�nativeStringr|JsO���a�%���&��5��9�:�:��!�U���x�x�� � �	
������Hr,c��t|t�r|jd�}n|jd�}t	|�t	|�k(r|S|S)a�
    Some functions, such as C{os.path.join}, operate on string arguments which
    may be bytes or text, and wish to return a value of the same type.  In
    those cases you may wish to have a string constant (in the case of
    C{os.path.join}, that constant would be C{os.path.sep}) involved in the
    parsing or processing, that must be of a matching type in order to use
    string operations on it.  L{_matchingString} will take a constant string
    (either L{bytes} or L{str}) and convert it to the same type as the
    input string.  C{constantString} should contain only characters from ASCII;
    to ensure this, it will be encoded or decoded regardless.

    @param constantString: A string literal used in processing.
    @type constantString: L{str} or L{bytes}

    @param inputString: A byte string or text string provided by the user.
    @type inputString: L{str} or L{bytes}

    @return: C{constantString} converted into the same type as C{inputString}
    @rtype: the type of C{inputString}
    rw)rkrmryrz�type)�constantString�inputString�	otherTypes   r*�_matchingStringr�\sL��*�.�%�(�"�)�)�'�2�	�"�)�)�'�2�	��N��t�K�0�0����r,z)raise exception.with_traceback(traceback)c�$�|j|��)a"
    Re-raise an exception, with an optional traceback.

    Re-raised exceptions will be mutated, with their C{__traceback__} attribute
    being set.

    @param exception: The exception instance.
    @param traceback: The traceback to use, or L{None} indicating a new
    traceback.
    )�with_traceback)�	exception�	tracebacks  r*�reraiser�{s���
"�
"�9�
-�-r,c#�RK�tt|��D]}|||dz���y�w)a5
    Return an iterable wrapper for a C{bytes} object that provides the behavior
    of iterating over C{bytes} on Python 2.

    In particular, the results of iteration are the individual bytes (rather
    than integers as on Python 3).

    @param originalBytes: A C{bytes} object that will be wrapped.
    r5N)r�len)�
originalBytes�is  r*�	iterbytesr��s2�����3�}�%�
&�'���A��A��&�&�'�s�%'zb'%d'r�c��d|fzS)z�
    Convert the given integer into C{bytes}, as ASCII-encoded Arab numeral.

    @param i: The C{int} to convert to C{bytes}.
    @rtype: C{bytes}
    s%drL)r�s r*�
intToBytesr��s���A�4�<�r,c�6�t|�}|�||dS||||zS)aq
    Return a copy of the given bytes-like object.

    If an offset is given, the copy starts at that offset. If a size is
    given, the copy will only be of that length.

    @param object: C{bytes} to be copied.

    @param offset: C{int}, starting index of copy.

    @param size: Optional, if an C{int} is given limit the length of copy
        to this size.
    N)�
memoryview)rf�offset�size�views    r*�
lazyByteSlicer��s0���f��D��|��F�G�}���F�f�t�m�-�-r,c�Z�t|t�std��|jd�S)a�
    Convert a string to L{bytes} using ASCII encoding.

    This is useful for sending text-like bytes that are constructed using
    string interpolation.  For example::

        networkString("Hello %d" % (n,))

    @param s: A string to convert to bytes.
    @type s: L{str}

    @raise UnicodeError: The input string is not ASCII encodable.
    @raise TypeError: The input is not L{str}.

    @rtype: L{bytes}
    z!Can only convert strings to bytesrw)rkrlrxrzr{s r*�
networkStringr��s)��"�a����;�<�<��8�8�G��r,zos.environbc���tjj}tjj}tjj	�D��cic]\}}||�||���c}}Scc}}w)z�
    Return a L{dict} of L{os.environ} where all text-strings are encoded into
    L{bytes}.

    This function is POSIX only; environment variables are always text strings
    on Windows.
    )�os�environ�	encodekey�encodevaluer')r�r�r:�ys    r*�bytesEnvironr��sT���
�
�$�$�I��*�*�(�(�K�57�Z�Z�5E�5E�5G�H�T�Q��I�a�L�+�a�.�(�H�H��Hs�A3c�8�|j|}t||�S)aN
    Construct a bound method.

    @param cls: The class that the method should be bound to.
    @type cls: L{type}

    @param name: The name of the method.
    @type name: native L{str}

    @param self: The object that the method is bound to.
    @type self: any object

    @return: a bound method
    @rtype: L{_MethodType}
    )�__dict__�_MethodType)�cls�namerO�funcs    r*�_constructMethodr��s�� �<�<���D��t�T�"�"r,c��d|vrtjdtd��|�d|vr|jd�}|rt�t|�S)a�
    Provide a backwards-compatible way to get async param value that does not
    cause a syntax error under Python 3.7.

    @param isAsync: isAsync param value (should default to None)
    @type isAsync: L{bool}

    @param kwargs: keyword arguments of the caller (only async is allowed)
    @type kwargs: L{dict}

    @raise TypeError: Both isAsync and async specified.

    @return: Final isAsync param value
    @rtype: L{bool}
    �asyncz:'async' keyword argument is deprecated, please use isAsyncr)�
stacklevel)�warnings�warn�DeprecationWarning�poprxrT)�isAsync�kwargss  r*�_get_async_paramr��sO�� �&���
�
�H���	
�
��7�f�,��*�*�W�%��
�����=�r,c�������	ddlm�m�m�tsyd����fd�	}t
j��j|jk(ry|t
_y#t$rYywxYw)z�
    Work around U{https://foss.heptapod.net/pypy/pypy/-/issues/3051}
    by replacing C{socket.fromfd} with a more conservative version.
    r)�F_GETFL�F_SETFL�fcntlNc�p��|g|duz}�|��}	�	|||g|����|�|�S#�|�|�wxYw�NrL)
�fd�familyr~�proto�	passproto�flagsr�r�r��
realFromFDs
      ����r*�fromFDWithoutModifyingFlagsz7_pypy3BlockingHack.<locals>.fromFDWithoutModifyingFlagssO����G�u�D�0�1�	��b�'�"��	&��b�&�$�;��;��"�g�u�%��E�"�g�u�%�s�
)�5r�)r�r�r��ImportError�_PYPY�socket�fromfd�__name__)r�r�r�r�r�s @@@@r*�_pypy3BlockingHackr�s^���
�1�1���&�&����J����9�B�B�B��/�F�M��!����s�
A�	A"�!A"zUse functools.reduce() directlyrzUse io.StringIO directly�NativeStringIOzImport urllib.parse directly�urllib_parsezUse html.escape directlyrz!Use urllib.parse.quote() directly�urlquotez#Use urllib.parse.unquote() directly�
urlunquotezUse http.cookiejar directly�	cookielibzUse sys.intern() directlyr
z%Use collections.abc.Sequence directlyr)!r�rGrrr rMrhr|r�r�r#r�r�r�r!rrr'r+r/rr$r�r�rr�r�r�r
r"rr�r)rr�)rN)T�__doc__r6r��platformr��urllib.parse�parser�r��collections.abcr�	functoolsr�htmlr�httprr��iorrr�r	�sysr
�typesrrr��typingr
rrrr�rr��incrementalr�twisted.python.deprecaterr�python_implementationr�rr�rrfr�zipr�intrr�inputrr rlr!�chrr"r#r$r+r/r'r7rGrMrhrtr|r�r�r�rmr�r�r�r�r�r�r��__all__rLr,r*�<module>r�s����$�	��
�#��$���'�=�=��6�$�$�A��J�!�8�!�!�#�v�-��E��E�����I�r�1�a� �"���	�
�	���I�r�1�a� �/���	�����I�r�1�a� �/���	�����I�r�1�a� �&��
�	�����I�r�1�a� �)��
�	�	����I�r�1�a� �(���	�
�	���I�r�1�a� �(���	�
����I�r�1�a� �)��	�	��
���I�r�1�a� �)���	�

����I�r�1�a� �&���	�����I�r�1�a� �)��
�	�
����I�r�1�a� �(���	��G�I�r�1�a�(�k�B��C���G�I�r�1�a�(�l�C��D���G�I�r�1�a�(�6G�H��I��
�C�
�	�
�$ �*�6��f����2�j#&�(�V
�F�
�s�
�$�>��I�r�1�a� �;��.�	�.�'��G�I�r�1�a�(�g�>��#��%��?��.�*�S��U��,�G�I�r�1�a�(�m�D�I�E�I�#�(�:0�4����I�r�1�a� �%���	���I�r�1�a� ����	���I�r�1�a� �"���	���I�r�1�a� �"<�h�����I�r�1�a� �'���	���I�r�1�a� �)���	���I�r�1�a� �!���	���I�r�1�a� �"=�x�����I�r�1�a� �+���	�"�r,

Zerion Mini Shell 1.0