
    ,h-                    \   d Z ddlm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dl
mZ ddlmZ ddlZerddlmZmZ ddlmZ ddlZd	Zd
ZdZej0                   G d d             ZddZddZ	 	 	 	 d dZd!dZd"dZd"dZd#dZ d$dZ!d%dZ"d&dZ#d'dZ$dZ%dZ&dZ'dZ(dZ)e*dk(  r e$        yy)(zG
Code generation script for class methods
to be exported as public API
    )annotationsN)Path)indent)TYPE_CHECKING)IterableIterator)	TypeGuard
_generateda9  # ***********************************************************
# ******* WARNING: AUTOGENERATED! ALL EDITS WILL BE LOST ******
# *************************************************************
from __future__ import annotations

import sys

from ._ki import enable_ki_protection
from ._run import GLOBAL_RUN_CONTEXT
ztry:
    return{}GLOBAL_RUN_CONTEXT.{}.{}
except AttributeError:
    raise RuntimeError("must be called from async context") from None
c                      e Zd ZU ded<   ded<    ej
                  dd      Zded<    ej
                  dd      Zded	<   y
)Filer   pathstrmodname T)defaultkw_onlyplatformimportsN)__name__
__module____qualname____annotations__attrsfieldr   r        Y/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/trio/_tools/gen_exports.pyr   r   0   s:    
JLEKKD9Hc95;;r48GS8r   r   c                V    t        | t        j                  t        j                  f      S )zHCheck if the AST node is either a function
    or an async function
    )
isinstanceastFunctionDefAsyncFunctionDef)nodes    r   is_functionr$   8   s      dS__c.B.BCDDr   c                    t        |       r=| j                  D ].  }t        |t        j                        s|j
                  dk(  s. y y)z-Check if the AST node has a _public decorator_publicTF)r$   decorator_listr   r    Nameid)r#   	decorators     r   	is_publicr+   ?   s@    4,, 	I)SXX.9<<93L	 r   c              #  `   K   t        j                  |       D ]  }t        |      s|  yw)zReturn a list of methods marked as public.
    The function walks the given tree and extracts
    all objects that are functions which are marked
    public.
    N)r    walkr+   )treer#   s     r   get_public_methodsr/   H   s+       T?Js   $..c                R   | j                   j                   D cg c]  }|j                   }}| j                   j                  r2|j                  d| j                   j                  j                  z          | j                   j                  D ]-  }|j                  |j                  dz   |j                  z          / | j                   j
                  r2|j                  d| j                   j
                  j                  z          dj                  dj                  |            S c c}w )a  Given a function definition, create a string that represents taking all
    the arguments from the function, and passing them through to another
    invocation of the same function.

    Example input: ast.parse("def f(a, *, b): ...")
    Example output: "(a, b=b)"
    *=z**z({})z, )argsargvarargappend
kwonlyargskwargformatjoin)funcdefr4   	call_argss      r   create_passthrough_argsr=   U   s     %,LL$5$56S6I6||w||226667||&& 23012|| 2 2 6 667==9-.. 7s   D$c                    ddl }t        j                  t        j                  ddd| j
                  dg|dd	      }|j                  dk7  rd
d|j                   fS d|j                  fS )a	  Run black on the specified file.

    Returns:
      Tuple of success and result string.
      ex.:
        (False, "Failed to run black!
error: cannot format ...")
        (True, "<formatted source>")

    Raises:
      ImportError: If black is not installed.
    r   N-mblack--stdin-filename-Tutf8inputcapture_outputencodingFzFailed to run black!
)	r@   
subprocessrunsys
executabler   
returncodestderrstdout)filesourcer@   results       r   	run_blackrR   g   so     
 ^^	w(:DIIsKF A.v}}o>>>r   c                    ddl }t        j                  t        j                  dddddd| j
                  d	g	|d
d      }|j                  dk7  rdd|j                   fS d
|j                  fS )a  Run ruff on the specified file.

    Returns:
      Tuple of success and result string.
      ex.:
        (False, "Failed to run ruff!
error: Failed to parse ...")
        (True, "<formatted source>")

    Raises:
      ImportError: If ruff is not installed.
    r   Nr?   ruffcheckz--fixz--unsafe-fixesrA   rB   TrC   rD   FzFailed to run ruff!
)	rT   rH   rI   rJ   rK   r   rL   rM   rN   )rO   rP   rT   rQ   s       r   run_ruffrV      s     ^^ NNII
	
 F$ A-fmm_===r   c                    t         t        fD ]1  } || |      \  }}|rt        |       t        j                  d       3 |S )zFormat the specified file using black and ruff.

    Returns:
      Formatted source code.

    Raises:
      ImportError: If either is not installed.
      SystemExit: If either failed.
       )rR   rV   printrJ   exit)rO   rP   fnsuccesss       r   run_lintersr]      sD     (# T6*&MHHQK	 Mr   c                6   t         g}|j                  | j                         | j                  r]d| j                  vr|j                  d       d| j                  vr|j                  d       |j                  d| j                   d       dj	                  |      g}t
        j                  j                  | j                        }g }t        |      D ]  }|j                  j                  d   j                  d	k(  sJ |j                  j                  d= |j                  |j                         |j                  D ]0  }t        |t        j                         s|j"                  d
k(  s.d} n d}t        j                   d      g|_        t%        |      }t        j&                  |      |j(                  dd= n|j(                  dd= t        j*                  |d      }	|r|	j-                  dd      }	t.        j1                  t        |t        j2                        rdnd| j4                  |j                  |z         }
|	t7        |
d      z   }|j                  |        |j9                          |j;                  dd|       dj	                  |      S )zZScan the given .py file for @_public decorators, and generate wrapper
    functions.

    r   z!from typing import TYPE_CHECKING
z
import syszimport sys
z,
assert not TYPE_CHECKING or sys.platform=="z"
r   r   selfcontextmanagerTFenable_ki_protectionNrX   z    )indent_withz
->Iteratorz->AbstractContextManagerz await  z
__all__ = z

)HEADERr6   r   r   r:   astorcode_to_ast
parse_filer   r/   r3   r4   namer'   r   r    r(   r)   r=   get_docstringbody	to_sourcereplaceTEMPLATEr9   r"   r   r   sortinsert)rO   header	generatedrP   method_namesmethoddecis_cmnew_argsfunctemplatesnippets               r   gen_public_wrappers_sourcerz      s?   
 XF
MM$,,}} $,,.MM>?t||+MM.);DMM?#N	
 !I))$))4FL$V, +"{{"&&&00KKQFKK((( 	C#sxx(SVV7G-G	
 E "%*@!A B +62 V$,A AB v7;<<.HID ??#FC,@,@AIsLLKK("
 '22 	!W+"Z Q*\$456;;y!!r   c                    | j                         D ]H  \  }}t        j                  j                  |      s yt	        |      j                  d      }||k7  sH y y)NFutf-8)rG   T)itemsosr   existsr   	read_text)	new_filesnew_path
new_source
old_sources       r   matches_disk_filesr   	  sW     ) 1 *ww~~h'(^--w-?
# r   c               x   i }| D ]  }t        d|j                         t        |      }t        ||      }t        j                  j                  |j                        \  }}t        j                  j                  |t        |z         }|||<    t        |      }|r/|s!t        d       t        j                  d       y t        d       y |j                         D ].  \  }}t        |ddd      5 }	|	j                  |       d d d        0 t        d	       |st        j                  d       y y # 1 sw Y   ^xY w)
Nz	Scanning:z2Generated sources are outdated. Please regenerate.rX   z!Generated sources are up to date.wr|   
)rG   newlinez!Regenerated sources successfully.)rY   r   rz   r]   r~   splitr:   PREFIXr   rJ   rZ   r}   openwrite)
filesdo_testr   rO   r   dirnamebasenamer   matches_diskfps
             r   processr     s   I )k499%/5
 z2
GGMM$))477<<():;(	() &i0LFGHHQK56$-OO$5 	% HjhgtD %$% %	% 	12HHQK % %s   0D00D9	c            
        t        j                  d      } | j                  dddd       | j                         }t	        j
                         }|dz  j                         sJ |d	z  }t        |d
z  dt              t        |dz  dt              t        |dz  ddt              t        |dz  ddt              t        |dz  ddt              g}t        ||j                         y )Nz,Generate python code for public api wrappers)descriptionz--testz-t
store_truez test if code is still up to date)actionhelpLICENSEzsrc/trio/_corez_run.pyrunner)r   z_instrumentation.pyzrunner.instrumentsz_io_windows.pyzrunner.io_managerwin32)r   r   z_io_epoll.pylinuxz_io_kqueue.pydarwin)r   )argparseArgumentParseradd_argument
parse_argsr   cwdr   r   IMPORTS_RUNIMPORTS_INSTRUMENTIMPORTS_WINDOWSIMPORTS_EPOLLIMPORTS_KQUEUEr   test)parserparsed_argssource_rootcoreto_wraps        r   mainr   /  s   $$BF /	   ##%K((*K)#++--))DTIx=(( &	

 	###		
 	>!!		
 	?""		
'G6 G[--.r   aN  from collections.abc import Awaitable, Callable
from typing import Any, TYPE_CHECKING

from outcome import Outcome
import contextvars

from ._run import _NO_SEND, RunStatistics, Task
from ._entry_queue import TrioToken
from .._abc import Clock

if TYPE_CHECKING:
    from typing_extensions import Unpack
    from ._run import PosArgT
z)from ._instrumentation import Instrument
zZfrom typing import TYPE_CHECKING

if TYPE_CHECKING:
    from .._file_io import _HasFileNo
a  from typing import TYPE_CHECKING

if TYPE_CHECKING:
    import select
    from collections.abc import Callable
    from contextlib import AbstractContextManager

    from .. import _core
    from .._file_io import _HasFileNo
    from ._traps import Abort, RaiseCancelT
a  from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from contextlib import AbstractContextManager

    from typing_extensions import Buffer

    from .._file_io import _HasFileNo
    from ._unbounded_queue import UnboundedQueue
    from ._windows_cffi import Handle, CData
__main__)r#   ast.ASTreturnz1TypeGuard[ast.FunctionDef | ast.AsyncFunctionDef])r.   r   r   z0Iterator[ast.FunctionDef | ast.AsyncFunctionDef])r;   z&ast.FunctionDef | ast.AsyncFunctionDefr   r   )rO   r   rP   r   r   ztuple[bool, str])rO   r   rP   r   r   r   )rO   r   r   r   )r   zdict[str, str]r   bool)r   zIterable[File]r   r   r   None)r   r   )+__doc__
__future__r   r   r    r~   rH   rJ   pathlibr   textwrapr   typingr   r   collections.abcr   r   typing_extensionsr	   re   r   rd   rm   definer   r$   r+   r/   r=   rR   rV   r]   rz   r   r   r   r   r   r   r   r   r   r   r   r   <module>r      s    #  
 	  
     2+ 		
 9 9 9E


5
/$>#L(F"R8+/\  zF r   