%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__/util.cpython-312.pyc

�

Ϫ�fqk���ddlmZddlZddlZddlZddlZddlmZ	ddlZ	ddl
Ze	ZeZ
	ddlm
ZmZeZeZ
ddlmZddlmZmZmZmZmZmZmZmZmZddlmZddlmZeed	d
dd�dd
d�ed�Z Gd�dee!e f�Z"d�Z#d5d�Z$d�Z%d�Z&						d6d�Z'd�Z(					d7d�Z)d�Z*d�Z+d8d�Z,d�Z-ggfd�Z.Gd�d�Z/d �Z0Gd!�d"�Z1Gd#�d$�Z2Gd%�d&�Z3Gd'�d(�Z4	dd)lm5Z6e6Z7e7�d*�Z5nd+�Z5d9d,�Z8d-�Z9d.�Z:d/�Z;d0�Z<d1�Z=d2�Z>d3�Z?gd4�Z@y#e$rdZ
dZY��wxYw#e$rdZdZ
Y��wxYw#e$rdZ7Y�PwxYw):�)�annotationsN)�AnyStr)�	getgroups�	setgroups)�OrderedDict)	�Any�Callable�ClassVar�Mapping�MutableMapping�Sequence�Tuple�TypeVar�Union)�Version)�deprecatedModuleAttribute�Twisted��z$Use collections.OrderedDict instead.ztwisted.python.utilr�_Tc����eZdZdZ	d�fd�	Zd�Zd�Zd�Zd�Zd�Z	e	Z
d�Zd	�Zd
�Z
d�Zdd�Zd
�Zd�Zdd�Zd�ZeZd�Zd�Ze�Zefd�Zd�Zd�Zd�Zd�Zdd�Z�xZS)�InsensitiveDicta
    Dictionary, that has case-insensitive keys.

    Normally keys are retained in their original form when queried with
    .keys() or .items().  If initialized with preserveCase=0, keys are both
    looked up in lowercase and returned in lowercase by .keys() and .items().
    c�f��t�|��i|_||_|r|j	|�yy)zD
        Create an empty dictionary, or update from 'dict'.
        N)�super�__init__�data�preserve�update)�self�dictr�	__class__s   ��5/usr/lib/python3/dist-packages/twisted/python/util.pyrzInsensitiveDict.__init__Is2���	������	� ��
���K�K����c�@�|j|�}|j|=y�N��_lowerOrReturnr�r�key�ks   r"�__delitem__zInsensitiveDict.__delitem__Ss������$���I�I�a�Lr#c�f�t|t�st|t�r|j�S|Sr%)�
isinstance�bytes�str�lower�rr)s  r"r'zInsensitiveDict._lowerOrReturnWs&���c�5�!�Z��S�%9��9�9�;���Jr#c�H�|j|�}|j|dS)zI
        Retrieve the value associated with 'key' (in any case).
        �r&r(s   r"�__getitem__zInsensitiveDict.__getitem__]s&��
����$���y�y��|�A��r#c�H�|j|�}||f|j|<y)z|
        Associate 'value' with 'key'. If 'key' already exists, but
        in different case, it will be replaced.
        Nr&)rr)�valuer*s    r"�__setitem__zInsensitiveDict.__setitem__ds%��

����$���U�|��	�	�!�r#c�@�|j|�}||jvS)z=
        Case insensitive test whether 'key' exists.
        r&r(s   r"�has_keyzInsensitiveDict.has_keyls"��
����$���D�I�I�~�r#c�~�|js0t|t�st|t�r|j	�S|Sr%)rr-r.r/r0r1s  r"�_doPreservezInsensitiveDict._doPreserveus,���}�}�*�S�%�"8�J�s�C�<P��9�9�;���Jr#c�4�t|j��S)z6
        List of keys in their original case.
        )�list�iterkeys�rs r"�keyszInsensitiveDict.keys{s���D�M�M�O�$�$r#c�4�t|j��S)z!
        List of values.
        )r=�
itervaluesr?s r"�valueszInsensitiveDict.values�s���D�O�O�%�&�&r#c�4�t|j��S)z,
        List of (key,value) pairs.
        )r=�	iteritemsr?s r"�itemszInsensitiveDict.items�s���D�N�N�$�%�%r#c�0�	||S#t$r|cYSwxYw)zn
        Retrieve value associated with 'key' or return default value
        if 'key' doesn't exist.
        )�KeyError�rr)�defaults   r"�getzInsensitiveDict.get�s%��
	���9����	��N�	�s���c�8�|j|�s|||<||S)z|
        If 'key' doesn't exist, associate it with the 'default' value.
        Return value associated with 'key'.
        )r9rIs   r"�
setdefaultzInsensitiveDict.setdefault�s#��
�|�|�C� ��D��I��C�y�r#c�>�|j�D]
\}}|||<�y)z5
        Copy (key,value) pairs from 'dict'.
        N�rF)rr r*�vs    r"rzInsensitiveDict.update�s&���J�J�L�	�D�A�q��D��G�	r#c	��dj|j�D��cgc]\}}|�d|����c}}�}d|zScc}}w)z:
        String representation of the dictionary.
        z, z: zInsensitiveDict({%s}))�joinrF)rr*rPrFs    r"�__repr__zInsensitiveDict.__repr__�sB���	�	�����F���A�q�e�2�a�U�O�F�G��&��.�.��Gs�=
c#�vK�|jj�D]}|j|d����y�w�Nr�rrCr;�rrPs  r"r>zInsensitiveDict.iterkeys�s7�������!�!�#�	)�A��"�"�1�Q�4�(�(�	)�s�79c#�XK�|jj�D]	}|d���y�w�Nr3)rrCrWs  r"rBzInsensitiveDict.itervalues�s+�������!�!�#�	�A��A�$�J�	�s�(*c#�zK�|jj�D]\}}|j|�|f���y�wr%rV)rr*rPs   r"rEzInsensitiveDict.iteritems�s<�����I�I�$�$�&�	)�D�A�q��"�"�1�%�q�(�(�	)�s�9;c��	|jj|j|��dS#t$r||jur�|cYSwxYw)zB
        @see: L{dict.pop}
        @since: Twisted 21.2.0
        r3)r�popr'rH�	_notFoundrIs   r"r\zInsensitiveDict.pop�sM��
	��9�9�=�=��!4�!4�S�!9�:�1�=�=���	��$�.�.�(���N�	�s�,/�A�Ac�8�|j�d}||d=|SrUrO)r�is  r"�popitemzInsensitiveDict.popitem�s!���J�J�L��O����1��J��r#c�4�|j�D]}||=�yr%)r@)rr*s  r"�clearzInsensitiveDict.clear�s������	�A��Q��	r#c�.�t||j�Sr%)rrr?s r"�copyzInsensitiveDict.copy�s���t�T�]�]�3�3r#c�,�t|j�Sr%)�lenrr?s r"�__len__zInsensitiveDict.__len__�s���4�9�9�~�r#c��t|t�r=|j�D]\}}||vs	|||k7s�yt|�t|�k(StS)NF)r-rrFrf�NotImplemented)r�otherr*rPs    r"�__eq__zInsensitiveDict.__eq__�sT���e�W�%��
�
��
!���1��E�>�U�1�X��]� �
!��t�9��E�
�*�*�!�!r#rYr%��returnr/�rj�objectrm�bool) �__name__�
__module__�__qualname__�__doc__rr+r'r4r7r9�__contains__r;r@rCrFrKrMrrSr>�__iter__rBrEror]r\r`rbrdrgrk�
__classcell__)r!s@r"rr;s������
����$���L��%�'�&����/�)��H��)���I�(�
��
�4��"r#rc�x�t�}g}|D](}||vr|j|�|j|��*|S)z�
    Make the elements of a list unique by inserting them into a dictionary.
    This must not change the order of the input lst.
    )�set�append�add)�lst�seen�resultr*s    r"�uniquifyr�sD��
�5�D�
�F�
����D�=��M�M�!���������Mr#c��t|�|kDrtdt|�|fz��|g|z}t|�|dt|�|S)aT
    Pads a sequence out to n elements,

    filling in with a default value if it is not long enough.

    If the input sequence is longer than n, raises ValueError.

    Details, details:
    This returns a new list; it does not extend the original sequence.
    The new list contains the values of the original sequence, not copies.
    z%d elements is more than %d.N)rf�
ValueErrorr=)�n�seqrJ�blanks    r"�padTor��sL���3�x�!�|��7�3�s�8�Q�-�G�H�H�
�I��M�E��S�	�E�*�C��H���Lr#c	��tjdtd��ddl}tj
j
tj
jtj
jtj
j|j���d�}tj
jd�}tj
jd�}ttj
j|||g�}|S)NzCtwisted.python.util.getPluginDirs is deprecated since Twisted 12.2.���
stacklevelr�pluginsz~/TwistedPluginsz
~/.twisted)
�warnings�warn�DeprecationWarning�twisted�os�pathrR�dirname�abspath�__file__�
expanduser�filter�isdir)r��
systemPlugins�userPlugins�confPlugins�
allPluginss     r"�
getPluginDirsr�s����M�M�M����
��G�G�L�L�
����������������8H�8H�(I�J�K�Y��M��'�'�$�$�%7�8�K��'�'�$�$�\�2�K�����
�
�
�{�K�'P�Q�J��r#c��tjdtd��tjjt
��y)NzBtwisted.python.util.addPluginDir is deprecated since Twisted 12.2.r�r�)r�r�r��sysr��extendr��r#r"�addPluginDirr�s+���M�M�L����
�H�H�O�O�M�O�$r#c��tjjtjjtjj	|��|�S)z�
    Return the path to a sibling of a file in the filesystem.

    This is useful in conjunction with the special C{__file__} attribute
    that Python provides for modules, so modules can load associated
    resource files.
    )r�r�rRr�r�)r��siblings  r"�sibpathr�"s3���7�7�<�<������������(=�>��H�Hr#c��ddl}	|j|�S#t$r)}|jtjk(rt��d}~wt
$rt�wxYw)z:
    Helper to turn IOErrors into KeyboardInterrupts.
    rN)�getpass�OSError�errno�EINTR�KeyboardInterrupt�EOFError)�promptr��es   r"�_getpassr�/sR��� ����v�&�&�����7�7�e�k�k�!�#�#�
��� ��� �s��	A�$A�Ac���ttjd�xrtjj�}d}	|s�|rB	tjtjf}tdd�xt_t_netjj�}|ddk(r|dd}||r6tjj�|\t_t_SS	t|�}|s:||r6tjj�|\t_t_SSt|�}	||	k(r:||r6tjj�|\t_t_SStjj|dz���#t$rtd��wxYw#|r6tjj�|\t_t_wwxYw)a+
    Obtain a password by prompting or from stdin.

    If stdin is a terminal, prompt for a new password, and confirm (if
    C{confirm} is true) by asking again to make sure the user typed the same
    thing, as keystrokes will not be echoed.

    If stdin is not a terminal, and C{forceTTY} is not true, read in a line
    and use it as the password, less the trailing newline, if any.  If
    C{forceTTY} is true, attempt to open a tty and prompt for the password
    using it.  Raise a RuntimeError if this is not possible.

    @returns: C{str}
    �isattyNz/dev/ttyzr+zCannot obtain a TTY����
)
�hasattrr��stdinr��stdout�open�
BaseException�RuntimeError�readline�closer��stderr�write)
r��confirm�forceTTY�
confirmPrompt�mismatchMessage�isaTTY�old�password�try1�try2s
          r"�getPasswordr�?s���*�S�Y�Y��
)�
@�c�i�i�.>�.>�.@�F�
�C�(���>��)�)�S�Z�Z�/�C�-1�*�d�-C�C�C�I��
��9�9�-�-�/���B�<�4�'�'���}�H����I�I�O�O��$'�!�C�I�s�z����F�#�D�����I�I�O�O��$'�!�C�I�s�z��
�M�*�D��t�|����I�I�O�O��$'�!�C�I�s�z���
�
� � ��4�!7�8���%�>�&�'<�=�=�>��$��I�I�O�O��$'�!�C�I�s�z��s6�F6�AF�-F6�)F6�1F6�;#F6�F3�3F6�6:G0c��tjjdjt	t
|��dz�y)N� r�)r�r�r�rR�mapr/)�as r"�printlnr�ts(���J�J���S�X�X�c�#�q�k�*�T�1�2r#c
�t�dj|D�cgc]}tt|�|z���c}�Scc}w)N�)rR�chr�ord)�s�b�cs   r"�str_xorr�}s+��
�7�7�Q�/��C��A���
�O�/�0�0��/s�5c�r�������t|�z�ddgf�����fd�	}d�dz��dz�|�fz|_|S)zS
    Creates a function that will return a string representing a progress bar.
    rr�c���t|�dk(sJd��t�|z�}�
|z
dz
}d�|z����	|z�d�}|r||d<|S||dk(ry||d<|S)Nr3z#Don't mess with the last parameter.r��[�]rr�)rf�int)�position�force�last�done�toDor~�aValue�currentChar�doneChar�
undoneChar�widths      �����r"�statBarzmakeStatBar.<locals>.statBar�s�����4�y�A�~�D�D�D�~��6�H�$�%���t�|�a����X��_�%�k�]�:��3D�2E�Q�G����D��G��M��T�!�W�����Q���
r#aRstatBar(position, force = 0) -> '[%s%s%s]'-style progress bar

    returned string is %d characters long, and the range goes from 0..%d.
    The 'position' argument is where the '%s' will be drawn.  If force is false,
    '' will be returned instead if the resulting progress bar is identical to the
    previously returned progress bar.
�)�floatrt)r��maxPositionr�r�r�r�r�s` ``` @r"�makeStatBarr��s[����U�;�'�
'�F� !������	�1����Q��
���
�

�G�O��Nr#c
��ddlm}d|jvr�|jd}t|d�r|j	|j
�}n|j	t
|��}td|jj�d|�dt|����ytd|jj�d	|jj�d
|j���y)zV
    A trace function for sys.settrace that prints every function or method call.
    r)�reflectrr!zmethod z of z at z	function z in z, line N)
�twisted.pythonr��f_localsr��qualr!�type�print�f_code�co_name�id�co_filename�f_lineno)�framer��ignoredr��ser*s      r"�spewerr��s���'�
�����
�^�^�F�
#���2�{�#����R�\�\�*�A����T�"�X�&�A�
�����,�,�-�T�!��D��B���A�B�
��|�|�#�#�U�\�\�%=�%=�u�~�~�
O�	
r#c�
�tjj|�}|jtj�}tjj
}tjj}tjj}t|�rl||�tjz}d}|D]}	||�|	���r�d}n|r|D]}
||�|
���r�d}n|r|S|jd�t|�r�ly)z�
    Walk upwards from start, looking for a directory containing
    all files and directories given as arguments::
    >>> searchupwards('.', ['foo.txt'], ['bar', 'bam'])

    If not found, return None
    r3rr�N)
r�r�r��split�sep�existsrRr�rfr\)�start�files�dirs�parentsr�rRr��	candidate�
allpresent�f�ds           r"�
searchupwardsr�s���
�G�G�O�O�E�"�E��k�k�"�&�&�!�G�
�W�W�^�^�F�
�6�6�;�;�D��G�G�M�M�E�

�g�,���M�B�F�F�*�	��
��	�A��Y�K��s�+�,��
��	���
���	�{�1�#�.�/�!"�J��
�������B���g�,�r#c�6�eZdZdZd	d�Zd�Zd�Zd�Zd�Zd�Z	y)
�LineLogz�
    A limited-size line-based log, useful for logging line-based
    protocols such as SMTP.

    When the log fills up, old entries drop off the end.
    c�6�|dkrd}dg|z|_||_y)z�
        Create a new log, with size lines of storage (default 10).
        A log size of 0 (or less) means an infinite log.
        rN)�log�size)rrs  r"rzLineLog.__init__�s$��
�!�8��D��6�D�=�����	r#c��|jr,|jdd|jdd||jd<y|jj|�y)Nr3r�)rrrz)r�lines  r"rzzLineLog.append�s?���9�9� �H�H�Q�R�L�D�H�H�S�b�M��D�H�H�R�L��H�H�O�O�D�!r#c��t|�Sr%)r.r?s r"r/zLineLog.str�s���T�{�r#c�L�djtd|j��S)N�
)rRr�rr?s r"�	__bytes__zLineLog.__bytes__�s���z�z�&��t�x�x�0�1�1r#c�4�td|j�|Sr%)r�r)r�items  r"r4zLineLog.__getitem__�s���d�D�H�H�%�d�+�+r#c�.�dg|jz|_y)z 
        Empty the log.
        N)rrr?s r"rbz
LineLog.clear�s���6�D�I�I�%��r#N)�
)
rqrrrsrtrrzr/rr4rbr�r#r"rr�s%����"��2�,�&r#rc�,�	||i|��y#|$rYywxYw)zF
    Determine whether the given call raises the given exception.
    r3rr�)�	exceptionr�args�kwargss    r"�raisesrs-���	�4��6��
������s���c��eZdZdZdd�Zd�Zy)�IntervalDifferentiala�
    Given a list of intervals, generate the amount of time to sleep between
    "instants".

    For example, given 7, 11 and 13, the three (infinite) sequences::

        7 14 21 28 35 ...
        11 22 33 44 ...
        13 26 39 52 ...

    will be generated, merged, and used to produce::

        (7, 0) (4, 1) (2, 2) (1, 0) (7, 0) (1, 1) (4, 2) (2, 0) (5, 1) (2, 0)

    New intervals may be added or removed as iteration proceeds using the
    proper methods.
    c�&�|dd|_||_y)a
        @type intervals: C{list} of C{int}, C{long}, or C{float} param
        @param intervals: The intervals between instants.

        @type default: C{int}, C{long}, or C{float}
        @param default: The duration to generate if the intervals list
        becomes empty.
        N)�	intervalsrJ)rrrJs   r"rzIntervalDifferential.__init__s��#�1������r#c�B�t|j|j�Sr%)�_IntervalDifferentialIteratorrrJr?s r"rvzIntervalDifferential.__iter__+s��,�T�^�^�T�\�\�J�Jr#N)�<)rqrrrsrtrrvr�r#r"rrs���$
�Kr#rc�(�eZdZd�Zd�ZeZd�Zd�Zy)rc��t|tt|���D��cgc]
\}}|||g��c}}|_||_d|_ycc}}wrU)�zip�rangerfrrJr�)rr_rr�r�s     r"rz&_IntervalDifferentialIterator.__init__0sA��25�a��s�1�v��2G�H���A�1�a��)�H��������	��Is�A	c�:�|js|jdfS|jdd|jdd}}|jddxx|jddz
cc<|jj�||jz
}||_||fS)Nrr�r3)rrJ�sortr�)rr��indexr~s    r"�__next__z&_IntervalDifferentialIterator.__next__5s����~�~��L�L�$�'�'��n�n�Q�'��*�D�N�N�1�,=�a�,@�e�����q��!�����q� 1�!� 4�4����������	�	�!����	��u�}�r#c�@�|jrt|jdd|jddz
}|jj||z|t|j�g�|jj�y|jj||dg�y)Nrr3)rrzrfr$)rr_�delays   r"�addIntervalz)_IntervalDifferentialIterator.addIntervalBs}���>�>��N�N�1�%�a�(�4�>�>�!�+<�Q�+?�?�E��N�N�!�!�5�1�9�a��T�^�^�1D�"E�F��N�N���!��N�N�!�!�1�a��)�,r#c��tt|j��D]_}|j|d|k(s�|j|d}|j|=|jD]}|d|kDs�|dxxdzcc<�ytd��)Nr3r�z.Specified interval not in IntervalDifferential)r"rfrr�)r�intervalr_r%s    r"�removeIntervalz,_IntervalDifferentialIterator.removeIntervalJs����s�4�>�>�*�+�	�A��~�~�a� ��#�x�/����q�)�!�,���N�N�1�%����"�A���t�e�|��!���	��"��	��I�J�Jr#N)rqrrrsrr&�nextr)r,r�r#r"rr/s���
��D�-�	Kr#rc�,�eZdZUdZdZded<dd�ZeZy)�
FancyStrMixinaO
    Mixin providing a flexible implementation of C{__str__}.

    C{__str__} output will begin with the name of the class, or the contents
    of the attribute C{fancybasename} if it is set.

    The body of C{__str__} can be controlled by overriding C{showAttributes} in
    a subclass.  Set C{showAttributes} to a sequence of strings naming
    attributes, or sequences of C{(attributeName, callable)}, or sequences of
    C{(attributeName, displayName, formatCharacter)}. In the second case, the
    callable is passed the value of the attribute and its return value used in
    the output of C{__str__}.  In the final case, the attribute is looked up
    using C{attributeName}, but the output uses C{displayName} instead, and
    renders the value of the attribute using C{formatCharacter}, e.g. C{"%.3f"}
    might be used for a float.
    r�zLSequence[Union[str, Tuple[str, str, str], Tuple[str, Callable[[Any], str]]]]�showAttributesc���dt|d|jj�g}|jD]�}t	|t
�r"|j
d|�dt||�����5t|�dk(r2|j
d|d�d�|dt||d��z��u|j
d|dz|dt||d�fz���|j
d	�d
j|�S)N�<�
fancybasenamer��=r�rr3z %s=�>r�)	�getattrr!rqr0r-r/rzrfrR)r�r�attrs   r"�__str__zFancyStrMixin.__str__ms���
�'�$�����1H�1H�I�J���'�'�	Q�D��$��$����1�T�F�!�G�D�$�$7�#:�;�<��T��a�����A�d�1�g�Y�a�.�G�D��G�G�D�$�q�'�4J�,K�K�L����&�4��7�*�t�A�w���d�1�g�8N�.O�O�P�
	Q�	
����
��w�w�q�z�r#Nrl)rqrrrsrtr0�__annotations__r9rSr�r#r"r/r/Vs'���(	����
��Hr#r/c�0�eZdZUdZdZded<dd�Zdd�Zy)	�FancyEqMixinz�
    Mixin that implements C{__eq__} and C{__ne__}.

    Comparison is done using the list of attributes defined in
    C{compareAttributes}.
    r�zClassVar[Sequence[str]]�compareAttributesc�����js��uSt��j�rt��fd��jD��StS)Nc3�P�K�|]}t�|�t�|�k(���y�wr%)r6)�.0�namerjrs  ��r"�	<genexpr>z&FancyEqMixin.__eq__.<locals>.<genexpr>�s,���������d�#�w�u�d�';�;��s�#&)r=r-r!�allri)rrjs``r"rkzFancyEqMixin.__eq__�sL����%�%��5�=� ��d�E�O�O�,��� �2�2���
��r#c�>�|j|�}|tur|S|Sr%)rkri)rrjr~s   r"�__ne__zFancyEqMixin.__ne__�s%�����U�#���^�#��M��z�r#Nrn)rqrrrsrtr=r:rkrEr�r#r"r<r<s���24��.�3��r#r<)�
initgroupsc��y)zk
        Do nothing.

        Underlying platform support require to manipulate groups is missing.
        Nr���uid�
primaryGids  r"rFrF�s�r#c�T�ttj|�j|�S)a�
        Initializes the group access list.

        This uses the stdlib support which calls initgroups(3) under the hood.

        If the given user is a member of more than C{NGROUPS}, arbitrary
        groups will be silently discarded to bring the number below that
        limit.

        @type uid: C{int}
        @param uid: The UID for which to look up group information.

        @type primaryGid: C{int}
        @param primaryGid: The GID to include when setting the groups.
        )�_initgroups�pwd�getpwuid�pw_namerHs  r"rFrF�s �� �3�<�<��,�4�4�j�A�Ar#c��|r1tj}tj}tj}n0tj}tj
}tj}|�||�|�c||�k(rD|xrdxsd}d|�d|��}|�d|���}tjdj||��yt||�||�yy)a�
    Attempts to switch the uid/euid and gid/egid for the current process.

    If C{uid} is the same value as L{os.getuid} (or L{os.geteuid}),
    this function will issue a L{UserWarning} and not raise an exception.

    @type uid: C{int} or L{None}
    @param uid: the UID (or EUID) to switch the current process to. This
                parameter will be ignored if the value is L{None}.

    @type gid: C{int} or L{None}
    @param gid: the GID (or EGID) to switch the current process to. This
                parameter will be ignored if the value is L{None}.

    @type euid: C{bool}
    @param euid: if True, set only effective user-id rather than real user-id.
                 (This option has no effect unless the process is running
                 as root, in which case it means not to shed all
                 privileges, retaining the option to regain privileges
                 in cases such as spawning processes. Use with caution.)
    N�euidrIz tried to drop privileges and setr�z is already z){} but {}; should we be root? Continuing.)r��seteuid�setegid�geteuid�setuid�setgid�getuidr�r��formatrF)	rI�gidrQrUrVrW�uidText�
actionText�problemTexts	         r"�	switchUIDr]�s���,�������������������������
���s��
���&�(�?��o�v�.��G�;�G�9�A�c�U�K�J�$�I�\�&�(��<�K��M�M�;�B�B����
�
�s�C� ��3�K�r#c��		||i|��S#t$r+}|jdtjk(rYd}~�8�d}~wwxYw)af
    Call C{f} with the given arguments, handling C{EINTR} by retrying.

    @param f: A function to call.

    @param a: Positional arguments to pass to C{f}.

    @param kw: Keyword arguments to pass to C{f}.

    @return: Whatever C{f} returns.

    @raise Exception: Whatever C{f} raises, except for C{OSError} with
        C{errno} set to C{EINTR}.
    rN)r�rr�r�)rr��kwr�s    r"�untilConcludesr`�sD���	��a�;�2�;����	��v�v�a�y�E�K�K�'����	�s��	?� :�:�?c�P�	|j|_	|j|_	|jj|j�	|j|_|S#t$rY�WwxYw#ttf$rY�ZwxYw#ttf$rY�IwxYw#t$rY|SwxYw)z�
    Overwrite C{g}'s name and docstring with values from C{f}.  Update
    C{g}'s instance dictionary with C{f}'s.

    @return: A function that has C{g}'s behavior and metadata merged from
        C{f}.
    )rq�	TypeErrorrt�AttributeError�__dict__rrr)r�gs  r"�mergeFunctionMetadatarfs���
��Z�Z��
�
��I�I��	�
�	�
�
���!�*�*�%�
��|�|���
�H���
��
��
�~�&�
��
��
�~�&�
��
���
���H�
�sE�A�A.�%B�B�	A+�*A+�.B�?B�B�B�	B%�$B%c��g}d}d}|D]u}|j�|k(r||z
}nJ|r5t|�dk(r||z
}n4|dd}|d}|j|�||z}n|j|�|}|j�}�w|r|dj�|d<n|j�S|j|�dj	|�S)ay
    Convert a string like a variable name into a slightly more human-friendly
    string with spaces and capitalized letters.

    @type mname: C{str}
    @param mname: The name to convert to a label.  This must be a string
    which could be used as a Python identifier.  Strings which do not take
    this form will result in unpredictable behavior.

    @rtype: C{str}
    r�Fr3Nr�rr�)�isupperrfrz�
capitalizerR)�mname�	labelList�word�lastWasUpper�letter�lastWord�firstLetters       r"�nameToLabelrq#s����I�
�D��L��(���>�>��|�+��F�N�D���t�9��>��F�N�D� $�C�R�y�H�"&�r�(�K��$�$�X�.�&��/�D�� � ��&����~�~�'��-(�.� ��|�.�.�0�	�!�����!�!�
���T���8�8�I��r#c�v�	t|�S#t$r"t��tj|�dcYSwxYw)a�
    Convert a user identifier, as a string, into an integer UID.

    @type uidString: C{str}
    @param uidString: A string giving the base-ten representation of a UID or
        the name of a user which can be converted to a UID via L{pwd.getpwnam}.

    @rtype: C{int}
    @return: The integer UID corresponding to the given string.

    @raise ValueError: If the user name is supplied and L{pwd} is not
        available.
    r�)r�r�rM�getpwnam)�	uidStrings r"�
uidFromStringruQ�<��*��9�~����*��;���|�|�I�&�q�)�)�*���

�(8�8c�v�	t|�S#t$r"t��tj|�dcYSwxYw)a�
    Convert a group identifier, as a string, into an integer GID.

    @type gidString: C{str}
    @param gidString: A string giving the base-ten representation of a GID or
        the name of a group which can be converted to a GID via L{grp.getgrnam}.

    @rtype: C{int}
    @return: The integer GID corresponding to the given string.

    @raise ValueError: If the group name is supplied and L{grp} is not
        available.
    r�)r�r��grp�getgrnam)�	gidStrings r"�
gidFromStringr|grvrwc���tj�tj�}}||k(r
||k(r||i|��S|dk7r||k7s||k7rtjd�||k7rtj|�|dk7r||k7s||k7rtj|�	||i|��|dk7r||k7s||k7rtjd�||k7rtj|�|dk7r!||k7s||k7rtj|�SSS#|dk7r||k7s||k7rtjd�||k7rtj|�|dk7r!||k7s||k7rtj|�wwwxYw)a,
    Run the given function wrapped with seteuid/setegid calls.

    This will try to minimize the number of seteuid/setegid calls, comparing
    current and wanted permissions

    @param euid: effective UID used to call the function.
    @type euid: C{int}

    @type egid: effective GID used to call the function.
    @param egid: C{int}

    @param function: the function run with the specific permission.
    @type function: any callable

    @param args: arguments passed to C{function}
    @param kwargs: keyword arguments passed to C{function}
    r)r�rT�getegidrRrS)rQ�egid�functionrrrIrYs       r"�runAsEffectiveUserr�}sF��&�z�z�|�R�Z�Z�\��C�
�d�{�s�d�{���(��(�(��!�8�����t���J�J�q�M��$�;��J�J�t���1�9�$�#�+�����J�J�t��	 ��T�,�V�,��q�y�c�T�k�S�D�[��
�
�1�
��d�{��
�
�3���a�x�S�D�[�C�4�K��
�
�3��-8�x��	�q�y�c�T�k�S�D�[��
�
�1�
��d�{��
�
�3���a�x�S�D�[�C�4�K��
�
�3��-8�x�s
�D
�
A&E0c��tj�5|D]\}}tj|i|���||i|��cddd�S#1swYyxYw)a
    Run C{f(*args, **kwargs)}, but with some warnings suppressed.

    Unlike L{twisted.internet.utils.runWithWarningsSuppressed}, it has no
    special support for L{twisted.internet.defer.Deferred}.

    @param suppressedWarnings: A list of arguments to pass to
        L{warnings.filterwarnings}.  Must be a sequence of 2-tuples (args,
        kwargs).

    @param f: A callable.

    @param args: Arguments for C{f}.

    @param kwargs: Keyword arguments for C{f}

    @return: The result of C{f(*args, **kwargs)}.
    N)r��catch_warnings�filterwarnings)�suppressedWarningsrrrr�r_s      r"�runWithWarningsSuppressedr��sX��&
�	 �	 �	"�"�'�	.�E�A�r��#�#�Q�-�"�-�	.��$�!�&�!�"�"�"�s�'A�A)rr�r�r�r�r�r�r�rrr�rrrrr/r<r]rfrqrur|r�r`r�r%)r��os.PathLike[AnyStr] | AnyStrr�r�rmr)z
Password: rrzConfirm password: zPasswords don't match.)r4�-r5)F)A�
__future__rr�r�r�r��typingrry�_grprM�_pwd�ImportErrorr�
_getgroupsr�
_setgroups�collectionsrrr	r
rrr
rrr�incrementalr�twisted.python.deprecaterrr/rrr�r�r�r�r�r�r�r�r�r�rrrrrr/r<rF�__initgroupsrLr]r`rfrqrur|r�r��__all__r�r#r"�<module>r�s���#��	�
������
�C�
�C��C�
�I��I�$�
�
�
� �>���I�r�1�a� �*���	�
�T�]��e"�n�S�"�W�-�e"�P��.�"%�
I�
&�
I�1M�
I��
I�
 �"�
�
�&�,�2(�j3�1�!�H
�( "���>&&�&&�R
� K� K�F$K�$K�N&�&�R��6�-��K����B�&,�^�0
�6+�\*�,*�,% �P"�2���_��
�C�
�C������I��I���J���K��s4�D&�D6�7E�&	D3�2D3�6	E�E�E�E

Zerion Mini Shell 1.0