%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib64/python2.7/site-packages/zmq/
Upload File :
Create Path :
Current File : //lib64/python2.7/site-packages/zmq/decorators.pyc

�
+�{Wc@s�dZdZddlmZddlZddlmZdefd��YZd	efd
��YZ	defd��YZ
d
�Zd�ZdS(siDecorators 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):
        ...
tcontexttsocketi����(twrapsN(t
basestringt
_DecoratorcBs5eZdZdd�Zd�Zd�Zd�ZRS(sThe mini decorator factorycCs
||_dS(N(t_target(tselfttarget((s4/usr/lib64/python2.7/site-packages/zmq/decorators.pyt__init__#scs7�j���\�������fd�}|S(s�
        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�������fd��}|S(Nc
s��j||�}|����p}�rC�|krC||�<n=�rs�|krstdj�j����n
||f}�||�SWdQXdS(Ns,{0}() got multiple values for argument '{1}'(t
get_targett	TypeErrortformatt__name__(targstkwargsRtobj(tdec_argst
dec_kwargstfunctkw_nameR(s4/usr/lib64/python2.7/site-packages/zmq/decorators.pytwrapper;s

(R(RR(RRRR(Rs4/usr/lib64/python2.7/site-packages/zmq/decorators.pyt	decorator:s'(tprocess_decorator_args(RRRR((RRRRs4/usr/lib64/python2.7/site-packages/zmq/decorators.pyt__call__&scOs|jS(s_Return the target function
        
        Allows modifying args/kwargs to be passed.
        (R(RR
R((s4/usr/lib64/python2.7/site-packages/zmq/decorators.pyR	QscOsyd}t|jd�t�r0|jd�}n<t|�dkrlt|dt�rl|d}|d}n|||fS(s�Process args passed to the decorator.
        
        args not consumed by the decorator will be passed to the target factory
        (Context/Socket constructor).
        tnameiiN(tNonet
isinstancetgetRtpoptlen(RR
RR((s4/usr/lib64/python2.7/site-packages/zmq/decorators.pyRXs%

N(Rt
__module__t__doc__RRRR	R(((s4/usr/lib64/python2.7/site-packages/zmq/decorators.pyR s
	+	t_ContextDecoratorcBseZdZd�ZRS(sDecorator subclass for ContextscCstt|�jtj�dS(N(tsuperR RtzmqtContext(R((s4/usr/lib64/python2.7/site-packages/zmq/decorators.pyRks(RRRR(((s4/usr/lib64/python2.7/site-packages/zmq/decorators.pyR ist_SocketDecoratorcBs)eZdZd�Zd�Zd�ZRS(sNDecorator subclass for sockets
    
    Gets the context from other args.
    cOsFtt|�j||�\}}}|jdd�|_|||fS(s$Also grab context_name out of kwargstcontext_nameR(R!R$RRR%(RR
RR((s4/usr/lib64/python2.7/site-packages/zmq/decorators.pyRus$cOs|j||�}|jS(s$Get context, based on call-time args(t_get_contextR(RR
RR((s4/usr/lib64/python2.7/site-packages/zmq/decorators.pyR	{scOsi|j|kr5||j}t|tj�r5|Snx$|D]}t|tj�r<|Sq<Wtjj�S(s�
        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#tinstance(RR
Rtctxtarg((s4/usr/lib64/python2.7/site-packages/zmq/decorators.pyR&�s

(RRRRR	R&(((s4/usr/lib64/python2.7/site-packages/zmq/decorators.pyR$os		cOst�||�S(s�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 (R
R((s4/usr/lib64/python2.7/site-packages/zmq/decorators.pyR�s
cOst�||�S(s_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$(R
R((s4/usr/lib64/python2.7/site-packages/zmq/decorators.pyR�s(scontextssocket(
Rt__all__t	functoolsRR"tzmq.utils.strtypesRtobjectRR R$RR(((s4/usr/lib64/python2.7/site-packages/zmq/decorators.pyt<module>sI,	

Zerion Mini Shell 1.0