
    Ph<<                        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ddlmZ dZd Z	 ej                  dd      Zd Z ej                  d	      Z G d
 d      Zd ZddZ	 ddlmZ  G d de      Z eej.                        Z eej4                        Zedk(  rej8                  sd Zee_        n!edk(  rej8                  rnedk(  r
d Zee_         ee      Zd Zd Zy# e$ r	 ddlmZ Y w xY w)zU
Decorator module, see https://pypi.python.org/pypi/decorator
for the documentation.
    N)getfullargspecz4.0.5c                     | j                   S N)__init__)clss    _C:\Users\daisl\Desktop\realtime-object-detection\venv\Lib\site-packages\scipy/_lib/decorator.pyget_initr	   .   s    <<    ArgSpeczargs varargs varkw defaultsc                     t        |       }t        |j                  |j                  |j                  |j
                        S )z$A replacement for inspect.getargspec)r   r   argsvarargsvarkwdefaults)fspecs     r   
getargspecr   7   s-    !D499dllDJJFFr
   z\s*def\s*([_\w][_\w\d]*)\s*\(c                   b    e Zd ZdZ ej
                         Z	 	 ddZd ZddZ	e
	 	 d	d       Zy)
FunctionMakerz
    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.
    Nc           	         || _         |r%|j                  | _        | j                  dk(  rd| _        |j                  | _        |j
                  | _        t        j                  |      rt        |      }t        |di       | _        dD ]  }	t        | |	t        ||	              t        | j                        D ]  \  }
}t        | d|
z  |        t        | j                        }t        | j                        }| j                   r=|j#                  d| j                   z          |j#                  d| j                   z          n| j$                  r|j#                  d       | j$                  D ],  }	|j#                  |	 d       |j#                  |	 d|	        . | j&                  r<|j#                  d	| j&                  z          |j#                  d	| j&                  z          d
j)                  |      | _        d
j)                  |      | _         |j,                  j/                         | _        |r|| _        ||| _        |r|| _        |r|| _        |r|| _        |r|| _        t5        | d      sJ t5        | d      st7        d|       y )N<lambda>_lambda___annotations__)r   r   r   r   
kwonlyargskwonlydefaultszarg%d*z=None=z**, name	signaturez#You are decorating a non-function: )shortsignature__name__r   __doc__doc
__module__moduleinspect
isfunctionr   getattrannotationssetattr	enumerater   listr   appendr   r   joinr    __dict__copydictr   hasattr	TypeError)selffuncr   r    r   r$   r&   funcdictargspecaiargallargsallshortargss                 r   r   zFunctionMaker.__init__K   s&   'DIyyJ&&	||DH//DK!!$'(.#*41BB#G ,AD!WWa%89, (		2FAsD'A+s3 3tyy/#DII<<NN3#56 ''dll(:;__NN3'ANNaS;/ ''1#Qqc
3 ) ::NN4$**#45 ''tzz(9:!%7!3&*ii&=# MM..0	DI &DN$DMDH DK DItV$$$t[)A$HII *r
   c                    | 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                  |       y# t        $ r d
}Y ;w xY w)z2Update the signature of func with the data in selfr$   Nr2   r    r   r*      r"   ?r&   )r   r"   r)   r#   r0   __defaults____kwdefaults__r   sys	_getframe	f_globalsgetAttributeErrorr%   update)r5   r6   kwframecallermodules        r   rI   zFunctionMaker.update   s    		tUD1fb1#D*b9%d,<dC&t]DA	@MM!$E !??..z3?L!$,?R   	L	s   -C CCc           	         |t        |       z  }|xs i }t        j                  |      }|t        d|       |j	                  d      }t        |g| j                  j                  d      D cg c]  }|j                  d       c}z         }	|	D ]  }
|
dv st        |
 d|        |j                  d      s|dz  }dt        | j                        fz  }	 t        ||d	      }t        ||       ||   }|r||d<    | j$                  |fi | |S c c}w #  t        d
t         j"                         t        |t         j"                          xY w)zBMake a new function from a given template and update the signatureznot a valid function template
   ,z *)_func__call_z is overridden in

z<decorator-gen-%d>singlezError in generated code:)file
__source__)varsDEFmatchSyntaxErrorgroupsetr!   splitstrip	NameErrorendswithnext_compile_countcompileexecprintrD   stderrrI   )r5   	src_templevaldict	addsourceattrssrcmor   r;   namesnfilenamecoder6   s                 r   makezFunctionMaker.make   sf   $t*$>rYYs^: ?uEFFxx{TF"1177<>< 36ciio<> > ?A((1#%8 >??  ||D!4KC
 (40C0C+D*FF	3(3Dx 
 ~"%E,D"E"/>	,3::>#CJJ's   /D
D 9Ec                    t        |t              r+|j                         j                  dd      \  }	}
|
dd }d}nd}	d}|} | ||	||||      }dj	                  d |j                         D              } |j                  d|z   ||fi |S )z
        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.
        (rN   NrR   c              3   &   K   | ]	  }d |z     yw)z    Nr?   ).0lines     r   	<genexpr>z'FunctionMaker.create.<locals>.<genexpr>   s     F4ED&4-4Es   zdef %(name)s(%(signature)s):
)
isinstancestrr]   r\   r/   
splitlinesrp   )r   objbodyrg   r   r$   r&   rh   ri   r   restr    r6   r5   ibodys                  r   createzFunctionMaker.create   s     c3**32JD$Sb	IDDID4y(C@		FDOO4EFFtyy9EA!97057 	7r
   )NNNNNNN)NF)NNNT)r"   r%   __qualname__r#   	itertoolscountra   r   rI   rp   classmethodr   r?   r
   r   r   r   A   sI     %Y__&N7;@D2Jh!"B 26047 7r
   r   c                     | j                   j                         }||d<   | |d<   t        j                  | d||       }t	        | d      r| j
                  |_        |S )zE
    decorate(func, caller) decorates a function using a caller.
    rQ   rP   z)return _call_(_func_, %(shortsignature)s)__wrapped__r   )__globals__r1   r   r   r3   r   )r6   callerrg   funs       r   decorater      sk     $$&HHXHX


9d  $C t^$,,Jr
   c                    |t        ||       S t        j                  |       rC| j                  j	                         }t        |       }d| j                   d| j                   d}nt        j                  |       r-| j                  dk(  rd}n| j                  }| }| j                  }nP| j                  j                  j	                         }| j                  j                  }| j                  j                  }|j                  j                         }| |d<   t         |d<   t        j                  | dd	||| j                  | 
      S )z=decorator(caller) converts a caller function into a decoratorz
decorator(z2) converts functions/generators into factories of z objectsr   r   rQ   
_decorate_z(func)zreturn _decorate_(func, _call_))r$   r&   r   )r   r'   isclassr"   lowerr	   r(   r#   	__class____call____func__r   r1   r   r   r%   )r   _funcr   
callerfuncr$   rg   s         r   	decoratorr      s+   v&&v$$&f%
FOO, -%/x9			F	#??j(D??D
nn((..0__--
oo%%%%**,HHX%H\&:c&"3"3    r
   )_GeneratorContextManager)GeneratorContextManagerc                       e Zd Zd Zy)ContextManagerc                 J    t         j                  |dt        | |      |      S )zContext manager decoratorz.with _self_: return _func_(%(shortsignature)s))_self_rP   r   )r   r   r2   )r5   r6   s     r   r   zContextManager.__call__   s,    ##BT* $ > 	>r
   N)r"   r%   r   r   r?   r
   r   r   r      s    >r
   r      c                 :    t        j                  |  ||i |      S r   r   r   r5   gr9   ks       r   r   r   	  s    '00q!zqzBBr
      c                 2    t        j                  | |||      S r   r   r   s       r   r   r     s    '00q!Q??r
   c                     d}t        |      D ])  \  }}t        ||       rd} nt        | |      s#| ||<   d}+ |r|j                  |        yy)z_
    Append ``a`` to the list of the virtual ancestors, unless it is already
    included.
    TFN)r,   
issubclassr.   )r9   
vancestorsaddjvas        r   r.   r.     s^    
 C:&2b!CaJqMC ' ! r
   c                        sJ d       ddj                          dt        j                  df fd	 fd}dz   |_        |S )	zr
    Factory of decorators turning a function into a generic function
    dispatching on the given arguments.
    zNo dispatch args passedrr   r   z,) c                 l     |t        |       t                    rt        dt               d      y)z5Make sure one passes the expected number of argumentsz	Expected z% arguments, got {len(arguments)}{msg}N)lenr4   )	argumentswrongmsgdispatch_argss      r   checkzdispatch_on.<locals>.check2  s>    Y]!34iM(:'; <8 8 9 9 5r
   c                     t        t               j                        }t        	      |k  st        d
       i 	fdfdfd}fd} fd}t        j                   d
 dt        |	      | | 

      S )z4Decorator turning a function into a generic functionzUnknown dispatch arguments c                  &    |        t        t                    D cg c]  }g  }}	D ]@  }t        | ||      D ].  \  }}}t        ||      s||j                  vs#t        ||       0 B |D cg c]  }t        |       c}S c c}w c c}w )zU
            Get a list of sets of virtual ancestors for the given types
            )ranger   zipr   __mro__r.   r[   )
types_rastypes_ttype_rar   r   typemaps
          r   r   z5dispatch_on.<locals>.gen_func_dec.<locals>.vancestorsB  s     %L$S%7898!28C9!$'vs$;LAub!!U+QYY0Fub) %< " '**cCGc** :
 +s   	B	4Bc                      |        g }t        |  |        D ]l  \  }}t        |      }|dkD  rt        d| d|       |dk(  r!|\  }t        d||fi       j                  dd }n|j                  }|j                  |dd        n |S )zG
            Get a list of virtual MROs, one for each type
            rN   zAmbiguous dispatch for z: r   Nrs   )r   r   RuntimeErrortyper   r.   )	r   listsr   vasn_vasr   mror   r   s	          r   	ancestorsz4dispatch_on.<locals>.gen_func_dec.<locals>.ancestorsN  s     %LEeZ%783C19&1!Bse<> >aZCBsQGR088<C))CS"X& 9 Lr
   c                  (               fd}|S )zU
            Decorator to register an implementation for the given types
            c                      t        |       j                  t        j                  d| j                  z          | <   | S )Nz in )r   r   operatorltr"   )r   r   r   r   s    r   decz@dispatch_on.<locals>.gen_func_dec.<locals>.register.<locals>.decg  s5    nQ',,hkk6AJJ;NO!"r
   r?   )r   r   r   r   s   ` r   registerz3dispatch_on.<locals>.gen_func_dec.<locals>.registera  s     %L Jr
   c                       |        t        j                   |   D cg c]  }t        d |D               }}|S c c}w )zI
            An utility to introspect the dispatch algorithm
            c              3   4   K   | ]  }|j                     y wr   )r"   )ru   r9   s     r   rw   zKdispatch_on.<locals>.gen_func_dec.<locals>.dispatch_info.<locals>.<genexpr>r  s     1SSs   )r   producttuple)r   anclstr   r   s      r   dispatch_infoz8dispatch_on.<locals>.gen_func_dec.<locals>.dispatch_infom  sT     %L'//E1BCECs 1S11C  EJEs   >c                     t        d | D              }	 	|   } ||i |S # t        $ r Y nw xY wt        j                   |  }t	        |       |D ]  }	j                  |      }| ||i |c S   |i |S )Nc              3   2   K   | ]  }t        |        y wr   )r   )ru   r;   s     r   rw   zGdispatch_on.<locals>.gen_func_dec.<locals>._dispatch.<locals>.<genexpr>w  s     =}$s)}s   )r   KeyErrorr   r   r`   rG   )
r   r   rJ   r   r   combinationsr   r   r6   r   s
          r   	_dispatchz4dispatch_on.<locals>.gen_func_dec.<locals>._dispatchv  s    =}==E&EN $~"~%   %,,i.?@L&KK'=d>b>) ' $$$s   " 	..zreturn _f_(z, %%(shortsignature)s))_f_)r   defaultr   r   r   r   r   )r[   r   r   r^   r   r   r2   )r6   argsetr   r   r   r   r   r   r   r   dispatch_strs   `    @@@r   gen_func_decz!dispatch_on.<locals>.gen_func_dec8  s     ^D)../=!V+9,HII
	+	&
			%$ ##K~-CDY(D
i'T	 $ ; 	;r
   dispatch_on)r/   r   ner"   )r   r   r   r   s   ` @@r   r   r   *  sU    
 333=tyy/03L'{{ 9T;l *L8Lr
   r   ) r#   rerD   r'   r   r   collectionsr   __version__r	   
namedtupler   r   rb   rW   r   r   r   
contextlibr   ImportErrorr   r   r   initr   r   n_argsr   contextmanagerr.   r   r?   r
   r   <module>r      s  < 
 
     "
 !+
 
 ,.G bjj12D7 D7NBO3
>- > .778	TYY	Q;t||C&Nq[T\\q[@&N>*
$ea  ONOs    C! !C/.C/