ó
þåNXc           @  sõ  d  Z  d d l m Z d Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l	 Z	 e j
 d k r d d l m Z d „  Z n d e f d	 „  ƒ  YZ d
 „  Z e	 j d d ƒ Z d „  Z e j d ƒ Z d e f d „  ƒ  YZ d „  Z d d „ Z y d d l m Z Wn! e k
 r:d d l m Z n Xd e f d „  ƒ  YZ e e j ƒ Z e e j ƒ Z  e  d k rše j! ršd „  Z e e _ n9 e  d k r²e j! r²n! e  d k rÓd „  Z e e _ n  e e ƒ Z" d „  Z# d „  Z$ d S(   sT   
Decorator module, see http://pypi.python.org/pypi/decorator
for the documentation.
iÿÿÿÿ(   t   print_functions   4.0.4Nt   3(   t   getfullargspecc         C  s   |  j  S(   N(   t   __init__(   t   cls(    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyt   get_init0   s    R   c           B  s)   e  Z d  Z d „  Z d „  Z e j Z RS(   s?   A quick and dirty replacement for getfullargspec for Python 2.Xc         C  s=   t  j | ƒ \ |  _ |  _ |  _ |  _ g  |  _ d  |  _ d  S(   N(	   t   inspectt
   getargspect   argst   varargst   varkwt   defaultst
   kwonlyargst   Nonet   kwonlydefaults(   t   selft   f(    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyR   5   s    '	c         c  s$   |  j  V|  j V|  j V|  j Vd  S(   N(   R   R	   R
   R   (   R   (    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyt   __iter__;   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   (    (    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyR   3   s   		c         C  s
   |  j  j S(   N(   R   t   __func__(   R   (    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyR   C   s    t   ArgSpecs   args varargs varkw defaultsc         C  s+   t  |  ƒ } t | j | j | j | j ƒ S(   s$   A replacement for inspect.getargspec(   R   R   R   R	   R
   R   (   R   t   spec(    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyR   K   s    s   \s*def\s*([_\w][_\w\d]*)\s*\(t   FunctionMakerc           B  sk   e  Z d  Z e j ƒ  Z d d d d d d d d „ Z d „  Z d e	 d „ Z
 e d d d e d „ ƒ Z RS(   s´   
    An object with the ability to create functions with a given signature.
    It has attributes name, doc, module, signature, defaults, dict and
    methods update and make.
    c         C  sÛ  | |  _  | r.| j |  _ |  j d k r6 d |  _ n  | j |  _ | j |  _ t j | ƒ r.t	 | ƒ } t
 | d i  ƒ |  _ x' d D] }	 t |  |	 t
 | |	 ƒ ƒ q… Wx1 t |  j ƒ D]  \ }
 } t |  d
 |
 | ƒ q¸ Wt j d k  rt j d d „  | Œ d d !|  _  |  _ nÿ t |  j ƒ } t |  j ƒ } |  j ri| j d |  j ƒ | j d |  j ƒ n |  j r‚| j d ƒ n  x9 |  j D]. }	 | j d |	 ƒ | j d |	 |	 f ƒ qŒW|  j rò| j d |  j ƒ | j d |  j ƒ n  d j | ƒ |  _ d j | ƒ |  _  | j j ƒ  |  _ q.n  | r@| |  _ n  | d  k	 rX| |  _ n  | rj| |  _ n  | r|| |  _ n  | rŽ| |  _ n  | r | |  _ n  t |  d ƒ sµt ‚ t |  d ƒ s×t  d | ƒ ‚ n  d  S(   Ns   <lambda>t   _lambda_t   __annotations__R   R	   R
   R   R   R   s   arg%dR   t   formatvaluec         S  s   d S(   Nt    (    (   t   val(    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyt   <lambda>s   s    i   iÿÿÿÿt   *s   %s=Nones   %s=%ss   **s   , t   namet	   signatures%   You are decorating a non function: %s(   s   argss   varargss   varkws   defaultss
   kwonlyargss   kwonlydefaults(!   t   shortsignatureR   R    R   t   docR   t   moduleR   t
   isfunctionR   t   getattrt   annotationst   setattrt	   enumerateR   t   syst   versiont   formatargspecR!   t   listR	   t   appendR   R
   t   joint   __dict__t   copyt   dictR   R   t   hasattrt   AssertionErrort	   TypeError(   R   t   funcR    R!   R   R#   R$   t   funcdictt   argspect   at   it   argt   allargst   allshortargs(    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyR   ^   sb    	
	#			c         K  sà   |  j  | _ t |  d d
 ƒ | _ t |  d i  ƒ | _ t |  d d ƒ | _ t |  d d
 ƒ | _ t |  d d
 ƒ | _ y t	 j
 d ƒ } Wn t k
 r¡ d } n X| j j d d ƒ } t |  d	 | ƒ | _ | j j | ƒ d
 S(   s2   Update the signature of func with the data in selfR#   R2   R   R   R'   i   t   ?R   R$   N(    (   R    R   R&   R   R   R0   t   __defaults__t   __kwdefaults__R   R*   t	   _getframet   AttributeErrort	   f_globalst   getR   t   update(   R   R6   t   kwt   framet   callermodule(    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyRE   —   s    
c         J  s„  | e  |  ƒ } | p i  } e j | ƒ } | d k rJ e d | ƒ ‚ n  | j d ƒ } e | g g  |  j j d ƒ D] } | j	 d ƒ ^ qu ƒ }	 x3 |	 D]+ }
 |
 d k r› e
 d |
 | f ƒ ‚ q› q› W| j d ƒ sæ | d 7} n  d	 e |  j ƒ f } y$ e | | d
 ƒ } | | f d UWn0 e d d e j ƒe | d e j ƒ‚  n X| | } | rp| | d <n  |  j | |  | S(   sB   Make a new function from a given template and update the signatures    not a valid function template
%si   t   ,s    *t   _func_t   _call_s   %s is overridden in
%ss   
s   <decorator-gen-%d>t   singleNs   Error in generated code:t   filet
   __source__(   s   _func_s   _call_(   t   varst   DEFt   matchR   t   SyntaxErrort   groupt   setR"   t   splitt   stript	   NameErrort   endswitht   nextt   _compile_countt   compilet   printR*   t   stderrRE   (   R   t	   src_templt   evaldictt	   addsourcet   attrst   srct   moR    R;   t   namest   nt   filenamet   codeR6   (    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyt   make¨   s4    /
c         K  s¦   t  | t ƒ r@ | j ƒ  j d d ƒ \ }	 }
 |
 d  } d } n d }	 d } | } |  | |	 | | | | ƒ } d j d „  | j ƒ  Dƒ ƒ } | j d | | | |  S(   sú   
        Create a function from the strings name, signature and body.
        evaldict is the evaluation dictionary. If addsource is true an
        attribute __source__ is added to the result. The attributes attrs
        are added, if any.
        t   (i   iÿÿÿÿs   
c         s  s   |  ] } d  | Vq d S(   s       N(    (   t   .0t   line(    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pys	   <genexpr>Û   s    s   def %(name)s(%(signature)s):
N(   t
   isinstancet   strRV   RU   R   R/   t
   splitlinesRh   (   R   t   objt   bodyR_   R   R#   R$   R`   Ra   R    t   restR!   R6   R   t   ibody(    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyt   createÉ   s    	
	N(   R   R   R   t	   itertoolst   countRZ   R   R   RE   t   FalseRh   t   classmethodt   TrueRs   (    (    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyR   T   s   	8	!c         C  s`   |  j  j ƒ  } | | d <|  | d <t j |  d | d |  ƒ} t |  d ƒ r\ |  j | _ n  | S(   sE   
    decorate(func, caller) decorates a function using a caller.
    RK   RJ   s)   return _call_(_func_, %(shortsignature)s)t   __wrapped__t   __qualname__(   t   __globals__R1   R   Rs   R3   Rz   (   R6   t   callerR_   t   fun(    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyt   decorateà   s    

c         C  s`  | d k	 r t | |  ƒ St j |  ƒ ro |  j j ƒ  } t |  ƒ } d |  j |  j f } t | ƒ j d } n’ t j	 |  ƒ rÄ |  j d k r– d } n	 |  j } |  } |  j
 } t | ƒ j d } n= |  j j j ƒ  } |  j j } |  j j
 } t | ƒ j d } | j j ƒ  } |  | d <t | d <t j d | | f d	 | | d
 |  d | d |  j d |  ƒS(   s=   decorator(caller) converts a caller function into a decoratorsH   decorator(%s) converts functions/generators into factories of %s objectsi   s   <lambda>R   i    RK   t
   _decorate_s   %s(%s)s   return _decorate_(%s, _call_)t   callR#   R$   Ry   N(   R   R~   R   t   isclassR   t   lowerR   R   R   R%   R   t	   __class__t   __call__R   R{   R1   R   Rs   R   (   R|   t   _funcR    t
   callerfuncR#   R}   R_   (    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyt	   decoratorï   s6    			

(   t   _GeneratorContextManager(   t   GeneratorContextManagert   ContextManagerc           B  s   e  Z d  „  Z RS(   c         C  s(   t  j | d t d |  d | ƒ d | ƒS(   s   Context manager decorators.   with _self_: return _func_(%(shortsignature)s)t   _self_RJ   Ry   (   R   Rs   R2   (   R   R6   (    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyR„     s    (   R   R   R„   (    (    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyRŠ     s   i   c         O  s   t  j |  | | | Ž  ƒ S(   N(   Rˆ   R   (   R   t   gR9   t   k(    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyR   $  s    i   c         O  s   t  j |  | | | ƒ S(   N(   Rˆ   R   (   R   RŒ   R9   R   (    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyR   *  s    c         C  sx   t  } xU t | ƒ D]G \ } } t | |  ƒ r8 t } Pn  t |  | ƒ r |  | | <t } q q W| rt | j |  ƒ n  d S(   s_   
    Append ``a`` to the list of the virtual ancestors, unless it is already
    included.
    N(   Rx   R)   t
   issubclassRv   R.   (   R9   t
   vancestorst   addt   jt   va(    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyR.   3  s    
c            sc   ˆ  s t  d ƒ ‚ d d j ˆ  ƒ ‰ t j d ‡  f d † ‰ ‡ ‡ ‡  f d †  } d ˆ | _ | S(   sr   
    Factory of decorators turning a function into a generic function
    dispatching on the given arguments.
    s   No dispatch args passeds   (%s,)s   , R   c           sG   | t  |  ƒ t  ˆ  ƒ ƒ rC t d t  ˆ  ƒ t  |  ƒ | f ƒ ‚ n  d S(   s5   Make sure one passes the expected number of argumentss   Expected %d arguments, got %d%sN(   t   lenR5   (   t	   argumentst   wrongt   msg(   t   dispatch_args(    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyt   checkM  s    c           sê   t  t ˆ ƒ j ƒ } t  ˆ ƒ | k s: t d ˆ ƒ ‚ n  i  ‰ ‡ ‡ ‡ f d †  ‰  ‡  ‡ f d †  ‰ ‡ ‡ f d †  } ‡ ‡ f d †  } ‡ ‡ ‡ f d †  } t j ˆ d ˆ t d | ƒ d	 | d
 ˆ d ˆ d ˆ  d ˆ d | d ˆ ƒS(   s4   Decorator turning a function into a generic functions   Unknown dispatch arguments %sc            s±   ˆ |  ƒ g  t  t ˆ  ƒ ƒ D] } g  ^ q } xb ˆ D]Z } xQ t |  | | ƒ D]= \ } } } t | | ƒ rO | | j k rO t | | ƒ qO qO Wq6 Wg  | D] } t | ƒ ^ q› S(   sU   
            Get a list of sets of virtual ancestors for the given types
            (   t   rangeR“   t   zipRŽ   t   __mro__R.   RT   (   t   typest   _t   rast   types_t   tt   type_t   ra(   R—   t   typemapR˜   (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyR   ]  s    
%"c            s¼   ˆ |  ƒ g  } x¥ t  |  ˆ  |  Œ  ƒ D]Ž \ } } t | ƒ } | d k rc t d | | f ƒ ‚ n@ | d k rš | \ } t d | | f i  ƒ j d } n	 | j } | j | d  ƒ q& W| S(   sG   
            Get a list of virtual MROs, one for each type
            i   s   Ambiguous dispatch for %s: %sR    iÿÿÿÿ(   Rš   R“   t   RuntimeErrort   typeR›   R.   (   Rœ   t   listsR    t   vast   n_vasR’   t   mro(   R   R˜   (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyt	   ancestorsi  s    
"	"	c            s#   ˆ ˆ  ƒ ‡ ‡ ‡  f d †  } | S(   sU   
            Decorator to register an implementation for the given types
            c           s1   ˆ  t  |  ƒ j t j d |  j ƒ |  ˆ ˆ <|  S(   Ns    in (   R   R   t   operatort   ltR   (   R   (   R˜   R£   Rœ   (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyt   dec  s    #
(    (   Rœ   R­   (   R˜   R£   (   Rœ   sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyt   register|  s    
c            sQ   ˆ |  ƒ g  } x: t  j ˆ  |  Œ  Œ  D]# } | j t d „  | Dƒ ƒ ƒ q& W| S(   sI   
            An utility to introspect the dispatch algorithm
            c         s  s   |  ] } | j  Vq d  S(   N(   R   (   Rj   R9   (    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pys	   <genexpr>Ž  s    (   Rt   t   productR.   t   tuple(   Rœ   t   lstt   anc(   Rª   R˜   (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyt   dispatch_info‡  s
    
!c           sª   t  d „  |  Dƒ ƒ } y ˆ | } Wn t k
 r7 n X| | | Ž  St j ˆ  | Œ  Œ  } t | ƒ x6 | D]. } ˆ j | ƒ } | d  k	 rk | | | Ž  Sqk Wˆ | | Ž  S(   Nc         s  s   |  ] } t  | ƒ Vq d  S(   N(   R¥   (   Rj   R;   (    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pys	   <genexpr>’  s    (   R°   t   KeyErrorRt   R¯   RY   RD   R   (   R—   R   RF   Rœ   R   t   combinationsRŸ   (   Rª   R6   R£   (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyt	   _dispatch‘  s    
s#   return _f_(%s, %%(shortsignature)s)t   _f_R®   t   defaultR£   R   Rª   R³   Ry   (   RT   R   R   RW   R   Rs   R2   (   R6   t   argsetR®   R³   R¶   (   t   dispatch_strR˜   R—   (   R   Rª   R6   R£   sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyt   gen_func_decS  s    

t   dispatch_on(   R4   R/   R«   t   neR   (   R—   R»   (    (   R—   R˜   Rº   sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyR¼   E  s    V(%   R   t
   __future__R    t   __version__t   reR*   R   R«   Rt   t   collectionsR+   R   R   t   objectt
   namedtupleR   R   R[   RP   R   R~   R   R‡   t
   contextlibRˆ   t   ImportErrorR‰   RŠ   R   t   initR“   R   t   n_argsR	   t   contextmanagerR.   R¼   (    (    (    sA   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/decorator.pyt   <module>!   sL   		Œ	%			