
    ,hy:                       d dl mZ d dlZd dlZd dlZd dlmZ d dlmZm	Z	m
Z
 d dlmZ d dlmZmZmZmZmZmZ d dlmZ d dlZ ede	d	ef   
      Z ed      Z ed      Zer=d dlZd dlmZmZ d dl m!Z!m"Z"m#Z#m$Z$ ejJ                  dk  rd dl&m'Z'  e!d      Z( e#d      Z)d(dZ*	 	 	 	 	 	 d)dZ+ G d d      Z,	 	 	 	 	 	 	 	 d*dZ-	 	 	 	 	 	 d+dZ. G d dee         Z/d,dZ0d-dZ1erd dlmZ ne1Ze G d de             Z2d.d Z3er ed!e	d	e4f   
      Z5	 	 d/	 	 	 	 	 	 	 d0d"Z6nd d#lm6Z6 d1d$Z7 G d% d&e8      Z9	 	 	 	 d2d'Z:y)3    )annotationsN)ABCMeta)	AwaitableCallableSequence)update_wrapper)TYPE_CHECKINGAnyGenericNoReturnTypeVarfinal)thread_localCallT.)boundTRetT)AsyncGeneratorTypeTracebackType)	ParamSpecSelfTypeVarTupleUnpack)      )BaseExceptionGroupArgsTPosArgsTc                     	 t        j                   t         j                  t        j                  t         j                               y# t        t        f$ r Y yw xY w)z7Attempt to reliably check if we are in the main thread.TF)signalSIGINT	getsignal	TypeError
ValueError     L/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/trio/_util.pyis_main_threadr(   1   sB    fmmV%5%5fmm%DEz" s   AA AAc                   dd}t         j                  dc}t         _        	  | | }	 |t         _        t        |t        j
                  j                        s_ ||      rt        d|d
      t        j                  |      rt        d|      t        dj                  t        | d|                   |S # t        $ r t        | t        j
                  j                        rT| j                          t        d| d| j                   d| j                   d| j                   d| j                   d      d  ||       rt        d	| d
      d  w xY w# |t         _        w xY w)Nc                    t        | t        j                  j                        ryt	        | dd       y| j
                  j                  dv S )NT_asyncio_future_blocking)FutureDeferred)
isinstancecollectionsabc	Generatorgetattr	__class____name__)values    r'   &_return_value_looks_like_wrong_libraryzBcoroutine_or_error.<locals>._return_value_looks_like_wrong_libraryB   sF     e[__66754d;G ''+AAAr&   triozLTrio was expecting an async function, but instead it got a coroutine object z/

Probably you did something like:

  trio.run(z4(...))            # incorrect!
  nursery.start_soon(zO(...))  # incorrect!

Instead, you want (notice the parentheses!):

  trio.run(z2, ...)            # correct!
  nursery.start_soon(z, ...)  # correct!z9Trio was expecting an async function, but instead it got u    – are you trying to use a library written for asyncio/twisted/tornado or similar? That won't work without some sort of compatibility shim.zTrio got unexpected zAstart_soon expected an async function but got an async generator zCTrio expected an async function, but {!r} appears to be synchronous__qualname__)r5   objectreturnbool)sniffio_loopnamer#   r.   r/   r0   	Coroutinecloser4   inspect
isasyncgenformatr2   )async_fnargsr6   	prev_loopcoros        r'   coroutine_or_errorrG   >   s   B $0#4#4f I| $&F & dKOO5561$7&th /K K  d#!H&   &>8!LM
 	

 K}  h 9 9:NN&&.\ 2 '//0 1((0(9(9': ; '//0 1((0(9(9'::LN   2(;K, ;;
  	=B &s   B8 8BEE E#c                  8    e Zd ZdZddZddZ	 	 	 	 	 	 	 	 ddZy)	ConflictDetectora  Detect when two tasks are about to perform operations that would
    conflict.

    Use as a synchronous context manager; if two tasks enter it at the same
    time then the second one raises an error. You can use it when there are
    two pieces of code that *would* collide and need a lock if they ever were
    called at the same time, but that should never happen.

    We use this in particular for things like, making sure that two different
    tasks don't call sendall simultaneously on the same stream.

    c                     || _         d| _        y NF)_msg_held)selfmsgs     r'   __init__zConflictDetector.__init__   s    	
r&   c                h    | j                   rt        j                  | j                        d| _         y )NT)rM   r7   BusyResourceErrorrL   )rN   s    r'   	__enter__zConflictDetector.__enter__   s%    ::((33DJr&   c                    d| _         y rK   )rM   )rN   exc_type	exc_value	tracebacks       r'   __exit__zConflictDetector.__exit__   s     
r&   N)rO   strr:   None)r:   rZ   )rU   ztype[BaseException] | NonerV   zBaseException | NonerW   zTracebackType | Noner:   rZ   )r4   
__module__r8   __doc__rP   rS   rX   r%   r&   r'   rI   rI      s<    , ( (	
 
r&   rI   c                     d fd}|S )z@Similar to wraps, but for async wrappers of non-async functions.c                    | _         j                   d | _        dj                   dj                   d d| _        | S )N.zLike :meth:`~z`, but async.)r4   r8   r[   r\   )func	attr_nameclswrapped_clss    r'   	decoratorzasync_wraps.<locals>.decorator   sW    !"//0)=&{'='=&>a@X@X?YYZ[dZeersr&   )r`   r   r:   r   r%   )rb   rc   ra   rd   s   ``` r'   async_wrapsre      s     r&   c                     t               d fd|j                         D ]!  \  }j                  d      r |       # y )Nc                   t        |      	v ry 	j                  t        |             t        |dd       }||j                  d      r|_        t        |d      r(d|j                  vr||_        t        |d      r| |_        t        |t              r3|j                  j                         D ]  \  }} dz   |z   ||        y y y y )Nr[   ztrio.r4   r_   r8   )idaddr2   
startswithr[   hasattrr4   r8   r.   type__dict__items)
qualnamer=   objmodra   
attr_valuefix_onemodule_nameobjnameseen_idss
         r'   rs   z&fixup_module_metadata.<locals>.fix_one   s     c7hRWc<.?s~~g6(CN sJ'Cs||,C#3/'/C$#t$-0\\-?-?-A N)IzGcMI5y*MN %  7?r&   _)ro   rY   r=   rY   rp   r9   r:   rZ   )setrn   rj   )rt   	namespacerp   rs   ru   rv   s   `  @@@r'   fixup_module_metadatarz      sN     HN N* ") +!!#&GWc*+r&   c                  0    e Zd ZdZ	 	 	 	 ddZddZddZy)	generic_functiona:  Decorator that makes a function indexable, to communicate
    non-inferable generic type parameters to a static type checker.

    If you write::

        @generic_function
        def open_memory_channel(max_buffer_size: int) -> Tuple[
            SendChannel[T], ReceiveChannel[T]
        ]: ...

    it is valid at runtime to say ``open_memory_channel[bytes](5)``.
    This behaves identically to ``open_memory_channel(5)`` at runtime,
    and currently won't type-check without a mypy plugin or clever stubs,
    but at least it becomes possible to write those.
    c                *    t        | |       || _        y N)r   _fn)rN   fns     r'   rP   zgeneric_function.__init__   s     	tR r&   c                &     | j                   |i |S r~   )r   )rN   rD   kwargss      r'   __call__zgeneric_function.__call__  s    txx(((r&   c                    | S r~   r%   )rN   	subscripts     r'   __getitem__zgeneric_function.__getitem__  s    r&   N)r   zCallable[..., RetT]r:   rZ   )rD   r9   r   r9   r:   r   )r   r9   r:   r   )r4   r[   r8   r\   rP   r   r   r%   r&   r'   r|   r|      s(      
)r&   r|   c                L    t        | j                   d| j                   d      )z5Raises an exception when a final class is subclassed.r_   z does not support subclassingr#   r[   r8   )rb   s    r'   _init_final_clsr     s'    
s~~&a(8(8'99VW
XXr&   c                @    t        t              | _        t        |       S )a8  Decorator that enforces a class to be final (i.e., subclass not allowed).

    If a class uses this metaclass like this::

        @final
        class SomeClass:
            pass

    The metaclass will ensure that no subclass can be created.

    Raises
    ------
    - TypeError if a subclass is created
    )classmethodr   __init_subclass__	std_final)	decorateds    r'   _final_implr     s    " #.o">IYr&   )r   c                  ,     e Zd ZdZddZd fdZ xZS )NoPublicConstructora  Metaclass that ensures a private constructor.

    If a class uses this metaclass like this::

        @final
        class SomeClass(metaclass=NoPublicConstructor):
            pass

    The metaclass will ensure that no instance can be initialized. This should always be
    used with @final.

    If you try to instantiate your class (SomeClass()), a TypeError will be thrown. Use
    _create() instead in the class's implementation.

    Raises
    ------
    - TypeError if an instance is created.
    c                L    t        | j                   d| j                   d      )Nr_   z has no public constructorr   )rb   rD   r   s      r'   r   zNoPublicConstructor.__call__B  s,    ~~a 0 011KL
 	
r&   c                "    t        |   |i |S r~   )superr   )rb   rD   r   r3   s      r'   _createzNoPublicConstructor._createG  s    w000r&   )rD   r9   r   r9   r:   rZ   )rb   type[T]rD   r9   r   r9   r:   r   )r4   r[   r8   r\   r   r   __classcell__)r3   s   @r'   r   r   -  s    &

1 1r&   r   c                4   t        | d      st        |       S 	 | j                  j                  d   }	 | j                  }| d| S # t        t
        f$ r d| j                  j                   d}Y ?w xY w# t        $ r | j                  j                  }Y Ww xY w)z{Return the fully-qualified name of the async generator function
    that produced the async generator iterator *agen*.
    ag_coder4   <>r_   )
rk   reprag_frame	f_globalsAttributeErrorKeyErrorr   co_filenamer8   co_name)agenmodulero   s      r'   name_asyncgenr   K  s     4#Dz1((4($$ XQxj!! H% 1T\\--.a01  (<<''(s"   A A5 )A21A25BBFnc                     y r~   r%   )wrappedassignedupdateds      r'   wrapsr   `  s     !r&   )r   c                @    d}| j                   }	 | # || _         ~ ~w xY w)zIThis helper allows re-raising an exception without __context__ being set.T)__context__)exc__tracebackhide__contexts      r'   raise_saving_contextr   j  s+     ooG	!s    c                      e Zd ZdZy)MultipleExceptionErrorzbRaised by raise_single_exception_from_group if encountering multiple
    non-cancelled exceptions.N)r4   r[   r8   r\   r%   r&   r'   r   r   w  s    !r&   r   c                6   | j                   D ]$  }t        |t        t        f      st	        |      |  d}d}| j                   D ]2  }t        |t
        j                        r| |}#||}(t        d      |  |t        |       |J d       t        |       y)a  This function takes an exception group that is assumed to have at most
    one non-cancelled exception, which it reraises as a standalone exception.

    This exception may be an exceptiongroup itself, in which case it will not be unwrapped.

    If a :exc:`KeyboardInterrupt` is encountered, a new KeyboardInterrupt is immediately
    raised with the entire group as cause.

    If the group only contains :exc:`Cancelled` it reraises the first one encountered.

    It will retain context and cause of the contained exception, and entirely discard
    the cause/context of the group(s).

    If multiple non-cancelled exceptions are encountered, it raises
    :exc:`AssertionError`.
    NzwAttempted to unwrap exceptiongroup with multiple non-cancelled exceptions. This is often caused by a bug in the caller.zgroup can't be empty)	
exceptionsr.   KeyboardInterrupt
SystemExitrl   r7   	Cancelledr   r   )egecancelled_exceptionnoncancelled_exceptions       r'   !raise_single_exception_from_groupr   |  s    ( ]] "a+Z89q'r!" 2637]] 	a("*&'##+%&"( J	 )34*B,BB,-r&   )r:   r;   )rC   z-Callable[[Unpack[PosArgsT]], Awaitable[RetT]]rD   zUnpack[PosArgsT]r:   z1collections.abc.Coroutine[object, NoReturn, RetT])rb   type[object]rc   r   ra   rY   r:   zCallable[[CallT], CallT])rt   rY   ry   z$collections.abc.Mapping[str, object]r:   rZ   )rb   r   r:   r   )r   r   r:   r   )r   z$AsyncGeneratorType[object, NoReturn]r:   rY   )..)r   zCallable[..., object]r   Sequence[str]r   r   r:   zCallable[[Fn], Fn])r   BaseExceptionr:   r   )r   z!BaseExceptionGroup[BaseException]r:   r   );
__future__r   collections.abcr/   r@   r    r0   r   r   r   r   	functoolsr   typingr	   r
   r   r   r   r   r   sniffior   r<   r7   r   r   r   systypesr   r   typing_extensionsr   r   r   r   version_infoexceptiongroupr   r   r   r(   rG   rI   re   rz   r|   r   r   r   r   r9   r   r   r   	Exceptionr   r   r%   r&   r'   <module>r      s   "     9 9 $  1  	xS12CLv7GG
'!5gEJ'HV;VV 7Vr B	  	$++3+ 
+Fwt} >Y
 , E 1' 1 1:"$ 	Xc6k2	3B #&!$!&!! ! 
	!  
!Y !
*.)*.*.r&   