
@^Yc           @   s  d  Z  d d l Z d d l Z d Z d d d d d g Z e j d	 d
 f k Z d f  d     YZ d f  d     YZ d   Z	 d f  d     YZ
 d f  d     YZ d   Z d   Z d f  d     YZ e r d d Un  d f  d     YZ d e f d     YZ d f  d     YZ e d  Z d f  d     YZ d e f d      YZ d! f  d"     YZ d e f d#     YZ d e f d$     YZ e e d%  rd&   Z n	 d'   Z d S((   s9  
PluginManager, basic initialization and tracing.

pluggy is the cristallized core of plugin management as used
by some 150 plugins for pytest.

Pluggy uses semantic versioning. Breaking changes are only foreseen for
Major releases (incremented X in "X.Y.Z").  If you want to use pluggy in
your project you should thus use a dependency restriction like
"pluggy>=0.1.0,<1.0" to avoid surprises.

pluggy is concerned with hook specification, hook implementations and hook
calling.  For any given hook specification a hook call invokes up to N implementations.
A hook implementation can influence its position and type of execution:
if attributed "tryfirst" or "trylast" it will be tried to execute
first or last.  However, if attributed "hookwrapper" an implementation
can wrap all calls to non-hookwrapper implementations.  A hookwrapper
can thus execute some code ahead and after the execution of other hooks.

Hook specification is done by way of a regular python function where
both the function name and the names of all its arguments are significant.
Each hook implementation function is verified against the original specification
function, including the names of all its arguments.  To allow for hook specifications
to evolve over the livetime of a project, hook implementations can
accept less arguments.  One can thus add new arguments and semantics to
a hook specification by adding another argument typically without breaking
existing hook implementations.

The chosen approach is meant to let a hook designer think carefuly about
which objects are needed by an extension writer.  By contrast, subclass-based
extension mechanisms often expose a lot more state and behaviour than needed,
thus restricting future developments.

Pluggy currently consists of functionality for:

- a way to register new hook specifications.  Without a hook
  specification no hook calling can be performed.

- a registry of plugins which contain hook implementation functions.  It
  is possible to register plugins for which a hook specification is not yet
  known and validate all hooks when the system is in a more referentially
  consistent state.  Setting an "optionalhook" attribution to a hook
  implementation will avoid PluginValidationError's if a specification
  is missing.  This allows to have optional integration between plugins.

- a "hook" relay object from which you can launch 1:N calls to
  registered hook implementation functions

- a mechanism for ordering hook implementation functions

- mechanisms for two different type of 1:N calls: "firstresult" for when
  the call should stop when the first implementation returns a non-None result.
  And the other (default) way of guaranteeing that all hook implementations
  will be called and their non-None result collected.

- mechanisms for "historic" extension points such that all newly
  registered functions will receive all hook calls that happened
  before their registration.

- a mechanism for discovering plugin objects which are based on
  setuptools based entry points.

- a simple tracing mechanism, including tracing of plugin calls and
  their arguments.

iNs   0.4.0t   PluginManagert   PluginValidationErrort   HookCallErrort   HookspecMarkert   HookimplMarkeri   i    c           B   s)   e  Z d  Z d   Z d e e d  Z RS(   s   Decorator helper class for marking functions as hook specifications.

    You can instantiate it with a project_name to get a decorator.
    Calling PluginManager.add_hookspecs later will discover all marked functions
    if the PluginManager uses the same project_name.
    c         C   s   | |  _  d  S(   N(   t   project_name(   t   selfR   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   __init__V   s    c            s3       f d   } | d k	 r+ | |  S| Sd S(   sA   if passed a function, directly sets attributes on the function
        which will make it discoverable to add_hookspecs().  If passed no
        function, returns a decorator which can be applied to a function
        later using the attributes supplied.

        If firstresult is True the 1:N hook call (N being the number of registered
        hook implementation functions) will stop at I<=N when the I'th function
        returns a non-None result.

        If historic is True calls to a hook will be memorized and replayed
        on later registered plugins.

        c            sE    r   r t  d   n  t |   j d t d   d    |  S(   Ns'   cannot have a historic firstresult hookt   _spect   firstresultt   historic(   t
   ValueErrort   setattrR   t   dict(   t   func(   R	   R
   R   (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   setattr_hookspec_optsg   s
    N(   t   None(   R   t   functionR	   R
   R   (    (   R	   R
   R   s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   __call__Y   s    
N(   t   __name__t
   __module__t   __doc__R   R   t   FalseR   (    (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR   N   s   	c           B   s/   e  Z d  Z d   Z d e e e e d  Z RS(   s   Decorator helper class for marking functions as hook implementations.

    You can instantiate with a project_name to get a decorator.
    Calling PluginManager.register later will discover all marked functions
    if the PluginManager uses the same project_name.
    c         C   s   | |  _  d  S(   N(   R   (   R   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR   {   s    c            s9         f d   } | d k r+ | S| |  Sd S(   s   if passed a function, directly sets attributes on the function
        which will make it discoverable to register().  If passed no function,
        returns a decorator which can be applied to a function later using
        the attributes supplied.

        If optionalhook is True a missing matching hook specification will not result
        in an error (by default it is an error if no matching spec is found).

        If tryfirst is True this hook implementation will run as early as possible
        in the chain of N hook implementations for a specfication.

        If trylast is True this hook implementation will run as late as possible
        in the chain of N hook implementations.

        If hookwrapper is True the hook implementations needs to execute exactly
        one "yield".  The code before the yield is run early before any non-hookwrapper
        function is run.  The code after the yield is run after all non-hookwrapper
        function have run.  The yield receives an ``_CallOutcome`` object representing
        the exception or result outcome of the inner calls (including other hookwrapper
        calls).

        c            s6   t  |   j d t d   d  d  d    |  S(   Nt   _implt   hookwrappert   optionalhookt   tryfirstt   trylast(   R   R   R   (   R   (   R   R   R   R   R   (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   setattr_hookimpl_opts   s    N(   R   (   R   R   R   R   R   R   R   (    (   R   R   R   R   R   s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR   ~   s    N(   R   R   R   R   R   R   R   (    (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR   t   s   		c         C   sD   |  j  d t  |  j  d t  |  j  d t  |  j  d t  d  S(   NR   R   R   R   (   t
   setdefaultR   (   t   opts(    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   normalize_hookimpl_opts   s    t
   _TagTracerc           B   s>   e  Z d    Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   s   i  |  _  d  |  _ d |  _ d  S(   Ni    (   t	   _tag2procR   t   writert   indent(   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR      s    		c         C   s   t  |  | f  S(   N(   t   _TagTracerSub(   R   t   name(    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   get   s    c   	      C   s   t  | d t  r* | d } | d  } n i  } d j t t |   } d |  j } d | | d j |  f g } x4 | j   D]& \ } } | j d | | | f  q W| S(   Nit    s     s
   %s%s [%s]
t   :s   %s    %s: %s
(   t
   isinstanceR   t   joint   mapt   strR#   t   itemst   append(	   R   t   tagst   argst   extrat   contentR#   t   linesR%   t   value(    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   format_message   s    
c         C   sp   |  j  d  k	 r@ | r@ |  j | |  } |  j  d j |   n  y |  j | | |  Wn t k
 rk n Xd  S(   Nt    (   R"   R   R5   R*   R!   t   KeyError(   R   R/   R0   R3   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   processmessage   s    c         C   s   | |  _  d  S(   N(   R"   (   R   R"   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt	   setwriter   s    c         C   sM   t  | t  r' t | j d   } n t  | t  s< t  | |  j | <d  S(   NR(   (   R)   R,   t   tuplet   splitt   AssertionErrorR!   (   R   R/   t	   processor(    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   setprocessor   s    (   R   R   R   R&   R5   R8   R9   R>   (    (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR       s   						R$   c           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   s   | |  _  | |  _ d  S(   N(   t   rootR/   (   R   R?   R/   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR      s    	c         G   s   |  j  j |  j |  d  S(   N(   R?   R8   R/   (   R   R0   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR      s    c         C   s   |  j  j |  j |  d  S(   N(   R?   R>   R/   (   R   R=   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   setmyprocessor   s    c         C   s   |  j  |  j |  j | f  S(   N(   t	   __class__R?   R/   (   R   R%   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR&      s    (   R   R   R   R   R@   R&   (    (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR$      s   			c         C   s2   |  j  } t d | j | j | j | f   d  S(   Ns   wrap_controller at %r %s:%d %s(   t   gi_codet   RuntimeErrort   co_namet   co_filenamet   co_firstlineno(   t   wrap_controllert   msgt   co(    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   _raise_wrapfail   s    	c         C   sw   y t  |   Wn t k
 r. t |  d  n Xt |  } y |  j |  t |  d  Wn t k
 rl n X| j   S(   s0   Wrap calling to a function with a generator which needs to yield
    exactly once.  The yield point will trigger calling the wrapped function
    and return its _CallOutcome to the yield point.  The generator then needs
    to finish (raise StopIteration) in order for the wrapped call to complete.
    s   did not yields   has second yield(   t   nextt   StopIterationRJ   t   _CallOutcomet   sendt
   get_result(   RG   R   t   call_outcome(    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   _wrapped_call   s    RM   c           B   s/   e  Z d  Z d Z d   Z d   Z d   Z RS(   s    Outcome of a function call, either an exception or a proper result.
    Calling the ``get_result`` method will return the result or reraise
    the exception raised when the function was called. c         C   s7   y |   |  _  Wn  t k
 r2 t j   |  _ n Xd  S(   N(   t   resultt   BaseExceptiont   syst   exc_infot   excinfo(   R   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR     s    c         C   s   | |  _  d  |  _ d  S(   N(   RR   R   RV   (   R   RR   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   force_result  s    	c         C   sM   |  j  d  k r |  j S|  j  } t r? | d j | d   n  t |   d  S(   Ni   i   (   RV   R   RR   t   _py3t   with_tracebackt   _reraise(   R   t   ex(    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyRO     s    	N(   R   R   R   R   RV   R   RW   RO   (    (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyRM     s
   		s4   
def _reraise(cls, val, tb):
    raise cls, val, tb
t   _TracedHookExecutionc           B   s#   e  Z d    Z d   Z d   Z RS(   c         C   sP   | |  _  | |  _ | |  _ | j |  _ t |  j t  s@ t  |  |  j  _ d  S(   N(   t   pluginmanagert   beforet   aftert   _inner_hookexect   oldcallR)   R\   R<   (   R   R]   R^   R_   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR   "  s    			c            sW    j    j    t      f d    }  j |   j    | j   S(   Nc              s    j       S(   N(   Ra   (    (   t   hookt
   hook_implst   kwargsR   (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   <lambda>,  s    (   R^   R%   RM   R_   RO   (   R   Rb   Rc   Rd   t   outcome(    (   Rb   Rc   Rd   R   s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR   *  s    c         C   s   |  j  |  j _ d  S(   N(   Ra   R]   R`   (   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   undo0  s    (   R   R   R   R   Rg   (    (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR\   !  s   		c           B   s   e  Z d  Z d d  Z d   Z d d  Z d   Z d d d  Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s   Core Pluginmanager class which manages registration
    of plugin objects and 1:N hook calling.

    You can register new hooks by calling ``add_hookspec(module_or_class)``.
    You can register plugin objects (which contain hooks) by calling
    ``register(plugin)``.  The Pluginmanager is initialized with a
    prefix that is searched for in the names of the dict of registered
    plugin objects.  An optional excludefunc allows to blacklist names which
    are not considered as hooks despite a matching prefix.

    For debugging purposes you can call ``enable_tracing()``
    which will subsequently send debug information to the trace helper.
    c         C   sp   | |  _  i  |  _ i  |  _ g  |  _ t   j d  |  _ t |  j j j d   |  _	 | |  _
 d   |  _ d S(   sr    if implprefix is given implementation functions
        will be recognized if their name matches the implprefix. t   pluginmanageRb   c         S   s   t  | | |  j  j   S(   N(   t
   _MultiCallt	   spec_optst   execute(   Rb   t   methodsRd   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyRe   M  s    N(   R   t   _name2plugint   _plugin2hookcallerst   _plugin_distinfoR    R&   t   tracet
   _HookRelayR?   Rb   t   _implprefixR`   (   R   R   t
   implprefix(    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR   C  s    					c         C   s   |  j  | | |  S(   N(   R`   (   R   Rb   Rl   Rd   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt	   _hookexecP  s    c   	      C   s  | p |  j  |  } | |  j k s3 | |  j k rq |  j j | d  d k rR d St d | | |  j f   n  | |  j | <g  |  j | <} x t |  D] } |  j | |  } | d k	 r t |  t	 | |  } t
 | | | |  } t	 |  j | d  } | d k r7t | |  j  } t |  j | |  n, | j   rc|  j | |  | j |  n  | j |  | j |  q q W| S(   s    Register a plugin and return its canonical name or None if the name
        is blocked from registering.  Raise a ValueError if the plugin is already
        registered. iNs#   Plugin already registered: %s=%s
%s(   t   get_canonical_nameRm   Rn   R&   R   R   t   dirt   parse_hookimpl_optsR   t   getattrt   HookImplRb   t   _HookCallerRt   R   t   has_spect   _verify_hookt   _maybe_apply_historyt   _add_hookimplR.   (	   R   t   pluginR%   t   plugin_namet   hookcallerst   hookimpl_optst   methodt   hookimplRb   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   registerU  s0    
c         C   s   t  | |  } y t  | |  j d d   } Wn t k
 rE i  } n X| d  k	 rk t | t  rk d  } n0 | d  k r |  j r | j |  j  r i  } n  | S(   NR   (   Rx   R   R   t	   ExceptionR)   R   Rr   t
   startswith(   R   R   R%   R   t   res(    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyRw   x  s    
	'	c         C   s   | d k r6 | d k	 s$ t d   |  j |  } n  | d k rT |  j |  } n  |  j j |  rs |  j | =n  x* |  j j | g   D] } | j |  q W| S(   sn    unregister a plugin object and all its contained hook implementations
        from internal data structures. s+   one of name or plugin needs to be specifiedN(	   R   R<   t   get_namet
   get_pluginRm   R&   Rn   t   popt   _remove_plugin(   R   R   R%   t
   hookcaller(    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt
   unregister  s    c         C   s!   |  j  d |  d |  j | <d S(   sJ    block registrations of the given name, unregister if already registered. R%   N(   R   R   Rm   (   R   R%   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   set_blocked  s    c         C   s    | |  j  k o |  j  | d k S(   sA    return True if the name blogs registering plugins of that name. N(   Rm   R   (   R   R%   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt
   is_blocked  s    c         C   s   g  } x t  |  D] } |  j | |  } | d k	 r t |  j | d  } | d k r t | |  j | |  } t |  j | |  n; | j | |  x( | j	 | j
 D] } |  j | |  q W| j |  q q W| s t d |  j | f   n  d S(   s    add new hook specifications defined in the given module_or_class.
        Functions are recognized if they have been decorated accordingly. s   did not find any %r hooks in %rN(   Rv   t   parse_hookspec_optsR   Rx   Rb   Rz   Rt   R   t   set_specificationt	   _wrapperst   _nonwrappersR|   R.   R   R   (   R   t   module_or_classt   namesR%   Rj   t   hct   hookfunction(    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   add_hookspecs  s    c         C   s&   t  | |  } t  | |  j d d   S(   NR   (   Rx   R   R   (   R   R   R%   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR     s    c         C   s   t  |  j  S(   s'    return the set of registered plugins. (   t   setRn   (   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   get_plugins  s    c         C   s   | |  j  k S(   s2    Return True if the plugin is already registered. (   Rn   (   R   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   is_registered  s    c         C   s"   t  | d d  p! t t |   S(   s	   Return canonical name for a plugin object. Note that a plugin
        may be registered under a different name which was specified
        by the caller of register(plugin, name). To obtain the name
        of an registered plugin use ``get_name(plugin)`` instead.R   N(   Rx   R   R,   t   id(   R   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyRu     s    c         C   s   |  j  j |  S(   s-    Return a plugin or None for the given name. (   Rm   R&   (   R   R%   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR     s    c         C   s   |  j  |  d k	 S(   s<    Return True if a plugin with the given name is registered. N(   R   R   (   R   R%   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt
   has_plugin  s    c         C   s4   x- |  j  j   D] \ } } | | k r | Sq Wd S(   s>    Return name for registered plugin or None if not registered. N(   Rm   R-   (   R   R   R%   t   val(    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR     s    c      	   C   s   | j    r4 | j r4 t d | j | j f   n  x] | j D]R } | | j k r> t d | j | j | t | j  d j | j  f   q> q> Wd  S(   Ns6   Plugin %r
hook %r
historic incompatible to hookwrappersX   Plugin %r
hook %r
argument %r not available
plugin definition: %s
available hookargs: %ss   , (	   t   is_historicR   R   R   R%   t   argnamest
   _formatdefR   R*   (   R   Rb   R   t   arg(    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR|     s    c         C   s   x |  j  j D]z } | d d k r t |  j  |  } | j   s x@ | j | j D]+ } | j sR t d | | j f   qR qR Wq q q Wd S(   s    Verify that all hooks which have not been verified against
        a hook specification are optional, otherwise raise PluginValidationErrori    t   _s   unknown hook %r in plugin %rN(	   Rb   t   __dict__Rx   R{   R   R   R   R   R   (   R   R%   Rb   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   check_pending  s    	c         C   s   d d l  m } m } m } x | |  D] } |  j | j  s) |  j | j  rY q) n  y | j   } Wn? | k
 r q) n, | k
 r } t d | j | f   n X|  j	 | d | j |  j
 j | | j f  q) Wt |  j
  S(   ss    Load modules from querying the specified setuptools entrypoint name.
        Return the number of loaded plugins. i(   t   iter_entry_pointst   DistributionNotFoundt   VersionConflicts"   Plugin %r could not be loaded: %s!R%   (   t   pkg_resourcesR   R   R   R   R%   R   t   loadR   R   Ro   R.   t   distt   len(   R   t   entrypoint_nameR   R   R   t   epR   t   e(    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   load_setuptools_entrypoints  s    $c         C   s   t  |  j  S(   sV    return list of distinfo/plugin tuples for all setuptools registered
        plugins. (   t   listRo   (   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   list_plugin_distinfo  s    c         C   s   t  |  j j    S(   s#    return list of name/plugin pairs. (   R   Rm   R-   (   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   list_name_plugin  s    c         C   s   |  j  j |  S(   s0    get all hook callers for the specified plugin. (   Rn   R&   (   R   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   get_hookcallers  s    c         C   s   t  |  | |  j S(   sG   add before/after tracing functions for all hooks
        and return an undo function which, when called,
        will remove the added tracers.

        ``before(hook_name, hook_impls, kwargs)`` will be called ahead
        of all hook calls and receive a hookcaller instance, a list
        of HookImpl instances and the keyword arguments for the hook call.

        ``after(outcome, hook_name, hook_impls, kwargs)`` receives the
        same arguments as ``before`` but also a :py:class:`_CallOutcome`` object
        which represents the result of the overall hook call.
        (   R\   Rg   (   R   R^   R_   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   add_hookcall_monitoring  s    c            s:   |  j  j     f d   }   f d   } |  j | |  S(   s;    enable tracing of hook calls and return an undo function. c            s#     j  j d 7_   |  |  d  S(   Ni   (   R?   R#   (   t	   hook_nameRl   Rd   (   t	   hooktrace(    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR^   (  s    c            s>   |  j  d  k r(   d | d |  j  n    j j d 8_ d  S(   Nt   finishs   -->i   (   RV   R   RR   R?   R#   (   Rf   R   Rl   Rd   (   R   (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR_   ,  s    (   Rb   t   _traceR   (   R   R^   R_   (    (   R   s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   enable_tracing$  s    c   	      C   s   t  |  j |  } g  | D] } t | |  r | ^ q } | r t | j | j | j | j  } xY | j | j	 D]G } | j
 } | | k rr | j |  |  j j | g   j |  qr qr W| S| S(   s    Return a new _HookCaller instance for the named method
        which manages calls to all registered plugins except the
        ones from remove_plugins. (   Rx   Rb   t   hasattrRz   R%   Rt   t   _specmodule_or_classRj   R   R   R   R~   Rn   R   R.   (	   R   R%   t   remove_pluginst   origt   plugt   plugins_to_removeR   R   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   subset_hook_caller3  s    (	#N(   R   R   R   R   R   Rt   R   Rw   R   R   R   R   R   R   R   Ru   R   R   R   R|   R   R   R   R   R   R   R   R   (    (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR    4  s2   	#																			Ri   c           B   s,   e  Z d  Z i  d  Z d   Z d   Z RS(   s8    execute a call into multiple python functions/methods. c         C   s,   | |  _  | |  _ |  |  j d <| |  _ d  S(   Nt   __multicall__(   Rc   Rd   t   specopts(   R   Rc   Rd   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR   P  s    		c         C   s  |  j  } g  |  _ } |  j j d  } x |  j r|  j j   } y$ g  | j D] } | | ^ qP } WnG t k
 r x7 | j D]( } | | k r t d | f   q q Wn X| j	 r t
 | j |   |  j  S| j |   } | d  k	 r+ | r | S| j |  q+ q+ W| s| Sd  S(   NR	   s"   hook call must provide argument %r(   Rd   t   resultsR   R&   Rc   R   R   R7   R   R   RQ   R   Rk   R   R.   (   R   t
   all_kwargsR   R	   t	   hook_implt   argnameR0   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyRk   V  s*    	$	c         C   sP   d t  |  j  f } t |  d  r? d t  |  j  | } n  d | |  j f S(   Ns   %d methsR   s   %d results, s   <_MultiCall %s, kwargs=%r>(   R   Rc   R   R   Rd   (   R   t   status(    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   __repr__o  s    (   R   R   R   R   Rk   R   (    (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyRi   G  s   	c         C   sz  t  |  d i   } y | d SWn t k
 r1 n Xt j |   rl y |  j }  Wn t k
 rb d SXd } nr t j |   r t j |   r y t  |  d |   }  Wq t k
 r d SXn  | d k r t
 t j |    } n  y |  j } Wn t k
 r d SXy | j | | j !} Wn t k
 r0d	 } n$ X|  j } | rT| t |   } n  y | | d <Wn t k
 run X| S(
   s$   return argument name tuple for a function, method, class or callable.

    In case of a class, its "__init__" method is considered.
    For methods the "self" parameter is not included unless you are passing
    an unbound method with Python3 (which has no supports for unbound methods)
    R   t	   _varnamesi   R   (    (    N(    (    (   Rx   R7   t   inspectt   isclassR   t   AttributeErrort
   isfunctiont   ismethodR   R   t   intt   __code__t   co_varnamest   co_argcountt   __defaults__R   t	   TypeError(   R   t
   startindext   cachet   rawcodet   xt   defaults(    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   varnamesv  sD    	 
	Rq   c           B   s   e  Z d  Z d   Z RS(   sh    hook holder object for performing 1:N hook calls where N is the number
    of registered plugins.

    c         C   s   | |  _  d  S(   N(   R   (   R   Rp   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR     s    (   R   R   R   R   (    (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyRq     s   Rz   c           B   sw   e  Z d d d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d d d  Z d	   Z d
   Z RS(   c         C   sY   | |  _  g  |  _ g  |  _ | |  _ | d  k	 rU | d  k	 sB t  |  j | |  n  d  S(   N(   R%   R   R   Rt   R   R<   R   (   R   R%   t   hook_executet   specmodule_or_classRj   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR     s    				c         C   s   t  |  d  S(   NR   (   R   (   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR{     s    c         C   s   |  j    s t  | |  _ t | |  j  } t | d t j |  } d | k s[ t  d g t |  |  _	 | |  _
 | j d  r g  |  _ n  d  S(   NR   R   R   R
   (   R{   R<   R   Rx   R%   R   R   R   R   R   Rj   R&   t   _call_history(   R   R   Rj   t   specfuncR   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR     s    		c         C   s   t  |  d  S(   NR   (   R   (   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR     s    c            sV     f d   } | |  j   d  k rR | |  j  d  k rR t d   f   qR n  d  S(   Nc            s;   x4 t  |   D]& \ } } | j   k r |  | =t Sq Wd  S(   N(   t	   enumerateR   t   True(   t   wrapperst   iR   (   R   (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   remove  s    s   plugin %r not found(   R   R   R   R   (   R   R   R   (    (   R   s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR     s    c         C   s   | j  r |  j } n	 |  j } | j r: | j d |  ng | j rS | j |  nN t |  d } x' | d k r | | j r | d 8} qf W| j | d |  d  S(   Ni    i   (   R   R   R   R   t   insertR   R.   R   (   R   R   Rl   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR~     s    				c         C   s   d |  j  f S(   Ns   <_HookCaller %r>(   R%   (   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR     s    c         K   s0   |  j    s t  |  j |  |  j |  j |  S(   N(   R   R<   Rt   R   R   (   R   Rd   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR     s    c         C   s=   |  j  j | p i  | f  |  j |  |  j |  j |  d  S(   N(   R   R.   Rt   R   R   (   R   t   procRd   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   call_historic  s    c         C   s   t  |  j  t  |  j  f } xK | D]C } t d t d t d t  } t d d | |  } |  j |  q% Wz |  |   SWd | \ |  _ |  _ Xd S(   s}    Call the hook with some additional temporarily participating
        methods using the specified kwargs as call parameters. R   R   R   s   <temp>N(   R   R   R   R   R   Ry   R   R~   (   R   Rl   Rd   t   oldR   R   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt
   call_extra  s    c         C   sh   |  j    rd xU |  j D]G \ } } |  j |  | g |  } | r | d  k	 r | | d  q q Wn  d  S(   Ni    (   R   R   Rt   R   (   R   R   Rd   R   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR}     s
    N(   R   R   R   R   R{   R   R   R   R~   R   R   R   R   R}   (    (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyRz     s   					
				Ry   c           B   s   e  Z d    Z RS(   c         C   sJ   | |  _  t |  j   |  _ | |  _ | |  _ | |  _ |  j j |  d  S(   N(   R   R   R   R   R   R   R   t   update(   R   R   R   R   t   hook_impl_opts(    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR     s    				(   R   R   R   (    (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyRy     s   c           B   s   e  Z d  Z RS(   s    plugin failed validation. (   R   R   R   (    (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR     s   c           B   s   e  Z d  Z RS(   s    Hook was called wrongly. (   R   R   R   (    (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR     s   t	   signaturec         C   s    d |  j  t t j |    f S(   Ns   %s%s(   R   R,   R   R   (   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR     s    c         C   s#   d |  j  t j t j |     f S(   Ns   %s%s(   R   R   t   formatargspect
   getargspec(   R   (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyR     s    (   R   RT   R   t   __version__t   __all__t   version_infoRX   R   R   R   R    R$   RJ   RQ   RM   R\   t   objectR    Ri   R   R   Rq   Rz   Ry   R   R   R   R   R   (    (    (    s&   /tmp/pip-build-UnxK1c/pluggy/pluggy.pyt   <module>B   s:   	&/	/		 /.
W
