ó
‰ÂPc           @   sV  d  Z  d Z d d d g Z d d l Z d d l Z d d l Z e j d k rj d d l m Z d	 „  Z n d
 e	 f d „  ƒ  YZ d „  Z e j
 d ƒ Z d e	 f d „  ƒ  YZ d d „ Z d „  Z y2 d d l m Z e d e f e d e ƒ ƒ Z WnN e k
 rEd d l m Z d „  Z e d e f e d e d e ƒ ƒ Z n Xe e ƒ Z d S(   sT   
Decorator module, see http://pypi.python.org/pypi/decorator
for the documentation.
s   3.4.0t	   decoratort   FunctionMakert   contextmanageriÿÿÿÿNt   3(   t   getfullargspecc         C   s   |  j  S(   N(   t   __init__(   t   cls(    (    s-   /usr/lib/python2.7/site-packages/decorator.pyt   get_init*   s    R   c           B   s    e  Z d  Z d „  Z d „  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(    (    s-   /usr/lib/python2.7/site-packages/decorator.pyR   /   s    '	c         c   s$   |  j  V|  j V|  j V|  j Vd  S(   N(   R
   R   R   R   (   R   (    (    s-   /usr/lib/python2.7/site-packages/decorator.pyt   __iter__4   s    (   t   __name__t
   __module__t   __doc__R   R   (    (    (    s-   /usr/lib/python2.7/site-packages/decorator.pyR   -   s   	c         C   s
   |  j  j S(   N(   R   t   im_func(   R   (    (    s-   /usr/lib/python2.7/site-packages/decorator.pyR   9   s    s   \s*def\s*([_\w][_\w\d]*)\s*\(c           B   s_   e  Z d  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(    (    s-   /usr/lib/python2.7/site-packages/decorator.pyt   <lambda>Z   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(    (    s-   /usr/lib/python2.7/site-packages/decorator.pyR   E   sb    	
	#			c         K   s¼   |  j  | _ t |  d d
 ƒ | _ t |  d i  ƒ | _ t |  d d ƒ | _ t |  d d
 ƒ | _ t |  d d
 ƒ | _ t	 j
 d ƒ j j d d ƒ } t |  d	 | ƒ | _ | j j | ƒ d
 S(   s2   Update the signature of func with the data in selfR"   R1   R   R   R&   i   R   t   ?R#   N(    (   R   R   R%   R   R   R/   t   func_defaultst   __kwdefaults__R   R)   t	   _getframet	   f_globalst   getR   t   update(   R   R5   t   kwt   callermodule(    (    s-   /usr/lib/python2.7/site-packages/decorator.pyRC   ~   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  y e | d	 d
 ƒ } | | UWn$ e j d IJe j | IJ‚  n X| | } | rH| | 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   <string>t   singles   Error in generated code:t
   __source__N(   s   _func_RH   (   t   varst   DEFt   matchR   t   SyntaxErrort   groupt   setR!   t   splitt   stript	   NameErrort   endswitht   compileR)   t   stderrRC   (   R   t	   src_templt   evaldictt	   addsourcet   attrst   srct   moR   R:   t   namest   nt   codeR5   (    (    s-   /usr/lib/python2.7/site-packages/decorator.pyt   makeŠ   s2    /
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(    (    s-   /usr/lib/python2.7/site-packages/decorator.pys	   <genexpr>¹   s    s   def %(name)s(%(signature)s):
N(   t
   isinstancet   strRR   RQ   R   R.   t
   splitlinesR`   (   R   t   objt   bodyRX   R   R"   R#   RY   RZ   R   t   restR    R5   R   t   ibody(    (    s-   /usr/lib/python2.7/site-packages/decorator.pyt   create§   s    	
	N(   R   R   R   R   R   RC   t   FalseR`   t   classmethodt   TrueRk   (    (    (    s-   /usr/lib/python2.7/site-packages/decorator.pyR   ?   s   	8	c         C   s–  | d k	 rN | j j ƒ  } |  | d <| | d <t j | d | d | d | ƒSt j |  ƒ r¤ |  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 | d |  j ƒSd S(   s‰   
    decorator(caller) converts a caller function into a decorator;
    decorator(caller, func) decorates a function using a caller.
    RH   RG   s)   return _call_(_func_, %(shortsignature)s)t   undecoratedt   __wrapped__sH   decorator(%s) converts functions/generators into factories of %s objectsi   s   <lambda>R   i    R    s   %s(%s)s   return decorator(_call_, %s)R"   R#   N(   R   t   func_globalsR0   R   Rk   R   t   isclassR   t   lowerR   R   R
   R$   R   t	   __class__t   __call__R   R    R   (   t   callerR5   RX   R   t
   callerfuncR"   t   fun(    (    s-   /usr/lib/python2.7/site-packages/decorator.pyR    ½   s>    

		

c         C   s(   t  j | d t d |  d | ƒ d | ƒS(   s   Context manager decorators.   with _self_: return _func_(%(shortsignature)s)t   _self_RG   Rp   (   R   Rk   R1   (   R   R5   (    (    s-   /usr/lib/python2.7/site-packages/decorator.pyRu   æ   s    (   t   _GeneratorContextManagert   ContextManagerRu   (   t   GeneratorContextManagerc         O   s   t  j |  | | | Ž  ƒ S(   N(   R|   R   (   R   R   R8   t   k(    (    s-   /usr/lib/python2.7/site-packages/decorator.pyR   õ   s    R   (   R   t   __version__t   __all__R)   t   reR   R*   R   R   t   objectRU   RL   R   R   R    Ru   t
   contextlibRz   t   typeR1   R{   t   ImportErrorR|   R   R   (    (    (    s-   /usr/lib/python2.7/site-packages/decorator.pyt   <module>!   s.   $	~)			