HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib64/python3.6/site-packages/zmq/__pycache__/decorators.cpython-36.pyc
3

VS�_z�@sldZdZddlmZddlZddlmZGdd�de�ZGd	d
�d
e�Z	Gdd�de�Z
d
d�Zdd�ZdS)aiDecorators for running functions with context/sockets.

.. versionadded:: 15.3

Like using Contexts and Sockets as context managers, but with decorator syntax.
Context and sockets are closed at the end of the function.

For example::

    from zmq.decorators import context, socket
    
    @context()
    @socket(zmq.PUSH)
    def work(ctx, push):
        ...
�context�socket�)�wrapsN)�
basestringc@s2eZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)�
_DecoratorzThe mini decorator factoryNcCs
||_dS)N)�_target)�self�target�r
�"/usr/lib64/python3.6/decorators.py�__init__#sz_Decorator.__init__cs(�j���\�������fdd�}|S)a�
        The main logic of decorator

        Here is how those arguments works::

            @out_decorator(*dec_args, *dec_kwargs)
            def func(*wrap_args, **wrap_kwargs):
                ...

        And in the ``wrapper``, we simply create ``self.target`` instance via
        ``with``::
            
            target = self.get_target(*args, **kwargs)
            with target(*dec_args, **dec_kwargs) as obj:
                ...

        cs t�������fdd��}|S)Ncsl�j||�}|����L}�r.�|kr.||�<n*�rN�|krNtdj�j����n
||f}�||�SQRXdS)Nz,{0}() got multiple values for argument '{1}')�
get_target�	TypeError�format�__name__)�args�kwargsr	�obj)�dec_args�
dec_kwargs�func�kw_namerr
r�wrapper;s

z7_Decorator.__call__.<locals>.decorator.<locals>.wrapper)r)rr)rrrr)rr�	decorator:sz&_Decorator.__call__.<locals>.decorator)�process_decorator_args)rrrrr
)rrrrr�__call__&sz_Decorator.__call__cOs|jS)z_Return the target function
        
        Allows modifying args/kwargs to be passed.
        )r)rrrr
r
rr
Qsz_Decorator.get_targetcOsXd}t|jd�t�r |jd�}n.t|�dkrNt|dt�rN|d}|dd�}|||fS)z�Process args passed to the decorator.
        
        args not consumed by the decorator will be passed to the target factory
        (Context/Socket constructor).
        N�name�r)�
isinstance�getr�pop�len)rrrrr
r
rrXsz!_Decorator.process_decorator_args)N)r�
__module__�__qualname__�__doc__rrr
rr
r
r
rr s

+rcs eZdZdZ�fdd�Z�ZS)�_ContextDecoratorzDecorator subclass for Contextscstt|�jtj�dS)N)�superr%r�zmq�Context)r)�	__class__r
rrksz_ContextDecorator.__init__)rr"r#r$r�
__classcell__r
r
)r)rr%isr%cs0eZdZdZ�fdd�Zdd�Zdd�Z�ZS)�_SocketDecoratorzNDecorator subclass for sockets
    
    Gets the context from other args.
    cs0tt|�j||�\}}}|jdd�|_|||fS)z$Also grab context_name out of kwargs�context_namer)r&r+rr r,)rrrr)r)r
rrusz'_SocketDecorator.process_decorator_argscOs|j||�}|jS)z$Get context, based on call-time args)�_get_contextr)rrrrr
r
rr
{sz_SocketDecorator.get_targetcOsL|j|kr$||j}t|tj�r$|Sx|D]}t|tj�r*|Sq*Wtjj�S)a�
        Find the ``zmq.Context`` from ``args`` and ``kwargs`` at call time.

        First, if there is an keyword argument named ``context`` and it is a
        ``zmq.Context`` instance , we will take it.

        Second, we check all the ``args``, take the first ``zmq.Context``
        instance.

        Finally, we will provide default Context -- ``zmq.Context.instance``

        :return: a ``zmq.Context`` instance
        )r,rr'r(�instance)rrrZctx�argr
r
rr-�s


z_SocketDecorator._get_context)rr"r#r$rr
r-r*r
r
)r)rr+osr+cOst�||�S)z�Decorator for adding a Context to a function.
    
    Usage::
    
        @context()
        def foo(ctx):
            ...

    .. versionadded:: 15.3

    :param str name: the keyword argument passed to decorated function
    )r%)rrr
r
rr�s
cOst�||�S)a_Decorator for adding a socket to a function.
    
    Usage::
    
        @socket(zmq.PUSH)
        def foo(push):
            ...
    
    .. versionadded:: 15.3

    :param str name: the keyword argument passed to decorated function
    :param str context_name: the keyword only argument to identify context
                             object
    )r+)rrr
r
rr�s)rr)
r$�__all__�	functoolsrr'Zzmq.utils.strtypesr�objectrr%r+rrr
r
r
r�<module>sI,