ó
j4Vdc           @€  sº   d  Z  d d l m Z d d l Z d d l m Z d d l m Z d d l m	 Z	 d d l
 m Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d d „ Z d „  Z d S(   s-   
Convenience decorators for use in fabfiles.
iÿÿÿÿ(   t   with_statementN(   t   wraps(   t   Random(   t   tasksi   (   t   settingsc          €  sk   t  ˆ  p ˆ ƒ } ˆ j d t j ƒ ‰ | sB ˆ  d d } ‰  n  ‡  ‡ ‡ f d †  } | ra | S| | ƒ S(   s«  
    Decorator declaring the wrapped function to be a new-style task.

    May be invoked as a simple, argument-less decorator (i.e. ``@task``) or
    with arguments customizing its behavior (e.g. ``@task(alias='myalias')``).

    Please see the :ref:`new-style task <task-decorator>` documentation for
    details on how to use this decorator.

    .. versionchanged:: 1.2
        Added the ``alias``, ``aliases``, ``task_class`` and ``default``
        keyword arguments. See :ref:`task-decorator-arguments` for details.
    .. versionchanged:: 1.5
        Added the ``name`` keyword argument.

    .. seealso:: `~fabric.docs.unwrap_tasks`, `~fabric.tasks.WrappedCallableTask`
    t
   task_classi    c         €  s   ˆ |  ˆ  ˆ Ž S(   N(    (   t   func(   t   argst   kwargsR   (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/fabric/decorators.pyt   wrapper&   s    (    (   t   boolt   popR   t   WrappedCallableTask(   R   R   t   invokedR   R	   (    (   R   R   R   s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/fabric/decorators.pyt   task   s    c         C€  s#   t  |  t j ƒ r t j | ƒ S| S(   N(   t
   isinstanceR   t   TaskR   (   t   originalt   new(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/fabric/decorators.pyt   _wrap_as_new+   s    c         €  s   ‡  ‡ f d †  } | S(   Nc         €  s}   t  ˆ  ƒ ‡  f d †  ƒ } ˆ } t | ƒ d k rT t | d t ƒ rT | d } n  t | ˆ t | ƒ ƒ t ˆ  | ƒ } | S(   Nc          €  s   ˆ  |  | Ž  S(   N(    (   R   R   (   R   (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/fabric/decorators.pyt   inner_decorator3   s    i   i    (   R   t   lenR   t
   basestringt   setattrt   listR   (   R   R   t   _values(   t	   attributet   values(   R   s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/fabric/decorators.pyt   attach_list2   s    &(    (   R   R   R   (    (   R   R   s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/fabric/decorators.pyt   _list_annotating_decorator1   s    c          G€  s   t  d |  Œ S(   s€  
    Decorator defining which host or hosts to execute the wrapped function on.

    For example, the following will ensure that, barring an override on the
    command line, ``my_func`` will be run on ``host1``, ``host2`` and
    ``host3``, and with specific users on ``host1`` and ``host3``::

        @hosts('user1@host1', 'host2', 'user2@host3')
        def my_func():
            pass

    `~fabric.decorators.hosts` may be invoked with either an argument list
    (``@hosts('host1')``, ``@hosts('host1', 'host2')``) or a single, iterable
    argument (``@hosts(['host1', 'host2'])``).

    Note that this decorator actually just sets the function's ``.hosts``
    attribute, which is then read prior to executing the function.

    .. versionchanged:: 0.9.2
        Allow a single, iterable argument (``@hosts(iterable)``) to be used
        instead of requiring ``@hosts(*iterable)``.
    t   hosts(   R   (   t	   host_list(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/fabric/decorators.pyR   B   s    c          G€  s   t  d |  Œ S(   sÜ  
    Decorator defining a list of role names, used to look up host lists.

    A role is simply defined as a key in `env` whose value is a list of one or
    more host connection strings. For example, the following will ensure that,
    barring an override on the command line, ``my_func`` will be executed
    against the hosts listed in the ``webserver`` and ``dbserver`` roles::

        env.roledefs.update({
            'webserver': ['www1', 'www2'],
            'dbserver': ['db1']
        })

        @roles('webserver', 'dbserver')
        def my_func():
            pass

    As with `~fabric.decorators.hosts`, `~fabric.decorators.roles` may be
    invoked with either an argument list or a single, iterable argument.
    Similarly, this decorator uses the same mechanism as
    `~fabric.decorators.hosts` and simply sets ``<function>.roles``.

    .. versionchanged:: 0.9.2
        Allow a single, iterable argument to be used (same as
        `~fabric.decorators.hosts`).
    t   roles(   R   (   t	   role_list(    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/fabric/decorators.pyR    \   s    c         €  s7   t  ˆ ƒ ‡  ‡ f d †  ƒ ‰  t ˆ ˆ  ƒ ‰  t ˆ  ƒ S(   s$  
    Decorator preventing wrapped function from running more than once.

    By keeping internal state, this decorator allows you to mark a function
    such that it will only run once per Python interpreter session, which in
    typical use means "once per invocation of the ``fab`` program".

    Any function wrapped with this decorator will silently fail to execute the
    2nd, 3rd, ..., Nth time it is called, and will return the value of the
    original run.
    
    .. note:: ``runs_once`` does not work with parallel task execution.
    c          €  s+   t  ˆ  d ƒ s$ ˆ |  | Ž  ˆ  _ n  ˆ  j S(   Nt   return_value(   t   hasattrR"   (   R   R   (   t	   decoratedR   (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/fabric/decorators.pyR$   ˆ   s    (   R   R   t   serial(   R   (    (   R$   R   s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/fabric/decorators.pyt	   runs_oncez   s    c         C€  s+   t  |  d t ƒ s t |  _ n  t |  |  ƒ S(   sl  
    Forces the wrapped function to always run sequentially, never in parallel.

    This decorator takes precedence over the global value of :ref:`env.parallel
    <env-parallel>`. However, if a task is decorated with both
    `~fabric.decorators.serial` *and* `~fabric.decorators.parallel`,
    `~fabric.decorators.parallel` wins.

    .. versionadded:: 1.3
    t   parallel(   t   getattrt   Falset   TrueR%   R   (   R   (    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/fabric/decorators.pyR%   ’   s    c         €  s;   t  ˆ ƒ t j k ‰  ‡  ‡ f d †  } ˆ  r7 | ˆ ƒ S| S(   s3  
    Forces the wrapped function to run in parallel, instead of sequentially.

    This decorator takes precedence over the global value of :ref:`env.parallel
    <env-parallel>`. It also takes precedence over `~fabric.decorators.serial`
    if a task is decorated with both.

    .. versionadded:: 1.3
    c         €  sO   t  ˆ  ƒ ‡  f d †  ƒ } t | _ t | _ ˆ r9 d  n ˆ | _ t ˆ  | ƒ S(   Nc          €  s   t  j ƒ  ˆ  |  | Ž  S(   N(   R   t   atfork(   R   R   (   R   (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/fabric/decorators.pyt   inner¯   s    
(   R   R*   R'   R)   R%   t   Nonet	   pool_sizeR   (   R   R,   (   t   called_without_argsR.   (   R   s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/fabric/decorators.pyt   real_decorator®   s
    		(   t   typet   typest   FunctionType(   R.   R0   (    (   R/   R.   s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/fabric/decorators.pyR'   ¢   s
    

c          €  s   ‡  ‡ f d †  } | S(   sG  
    Decorator equivalent of ``fabric.context_managers.settings``.

    Allows you to wrap an entire function as if it was called inside a block
    with the ``settings`` context manager. This may be useful if you know you
    want a given setting applied to an entire function body, or wish to
    retrofit old code without indenting everything.

    For example, to turn aborts into warnings for an entire task function::

        @with_settings(warn_only=True)
        def foo():
            ...

    .. seealso:: `~fabric.context_managers.settings`
    .. versionadded:: 1.1
    c         €  s.   t  ˆ  ƒ ‡ ‡  ‡ f d †  ƒ } t ˆ  | ƒ S(   Nc          €  s'   t  ˆ  ˆ Ž   ˆ |  | Ž  SWd  QXd  S(   N(   R   (   R   R   (   t   arg_settingsR   t   kw_settings(    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/fabric/decorators.pyR,   Õ   s    (   R   R   (   R   R,   (   R4   R5   (   R   s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/fabric/decorators.pyt   outerÔ   s    !(    (   R4   R5   R6   (    (   R4   R5   s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/fabric/decorators.pyt   with_settingsÂ   s    (   t   __doc__t
   __future__R    R2   t	   functoolsR   t   CryptoR   t   fabricR   t   context_managersR   R   R   R   R   R    R&   R%   R-   R'   R7   (    (    (    s_   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/fabric/decorators.pyt   <module>   s   							 