
    +g-                    ~   S r SSKJr  SSKrSSKrSSKrSSKrSSKrSSKJ	r	  SSK
Jr  SSKJr  SSKr\(       a  SSKJrJr  SSKJr  SSKrS	rS
rSr\R0                   " S S5      5       rSS jrSS jr    S S jrS!S jrS"S jrS"S jrS#S jr S$S jr!S%S jr"S&S jr#S'S jr$Sr%Sr&Sr'Sr(Sr)\*S:X  a  \$" 5         gg)(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                      \ rS rSr% S\S'   S\S'   \R                  " SSS9rS\S	'   \R                  " SSS9rS\S
'   Sr	g)File0   r   pathstrmodname T)defaultkw_onlyplatformimports N)
__name__
__module____qualname____firstlineno____annotations__attrsfieldr   r   __static_attributes__r       _/Users/Alptekin/Desktop/izin_takip/venv/lib/python3.13/site-packages/trio/_tools/gen_exports.pyr   r   0   s6    
JLKKD9Hc9;;r48GS8r   r   c                V    [        U [        R                  [        R                  45      $ )z@Check 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                    [        U 5      (       aF  U R                   H6  n[        U[        R                  5      (       d  M$  UR
                  S:X  d  M6    g   g)z-Check if the AST node has a _public decorator_publicTF)r'   decorator_listr"   r#   Nameid)r&   	decorators     r    	is_publicr.   ?   sA    4,,I)SXX..9<<93L - r   c              #  r   #    [         R                  " U 5       H  n[        U5      (       d  M  Uv   M     g7f)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_methodsr2   H   s'      T??J s   (7	7c                n   U R                   R                    Vs/ s H  oR                  PM     nnU R                   R                  (       a2  UR                  SU R                   R                  R                  -   5        U R                   R                   H.  nUR                  UR                  S-   UR                  -   5        M0     U R                   R
                  (       a2  UR                  SU R                   R
                  R                  -   5        SR                  SR                  U5      5      $ s  snf )zGiven 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)funcdefr7   	call_argss      r    create_passthrough_argsr@   U   s     %,LL$5$56$5S$5I6||w||226667||&&301 '|| 2 2 6 667==9-.. 7s   D2c                    SSK n[        R                  " [        R                  SSSU R
                  S/USSS	9nUR                  S:w  a  S
SUR                   34$ SUR                  4$ )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!
)	rC   
subprocessrunsys
executabler   
returncodestderrstdout)filesourcerC   results       r    	run_blackrU   g   so     
 ^^	w(:DIIsKF A.v}}o>>>r   c                    SSK n[        R                  " [        R                  SSSSSSU R
                  S	/	US
SS9nUR                  S:w  a  SSUR                   34$ S
UR                  4$ )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   NrB   ruffcheckz--fixz--unsafe-fixesrD   rE   TrF   rG   FzFailed to run ruff!
)	rW   rK   rL   rM   rN   r   rO   rP   rQ   )rR   rS   rW   rT   s       r    run_ruffrY      s     ^^ NNII
	
 F$ A-fmm_===r   c                    [         [        4 H7  nU" X5      u  p1U(       a  M  [        U5        [        R                  " S5        M9     U$ )zFormat the specified file using black and ruff.

Returns:
  Formatted source code.

Raises:
  ImportError: If either is not installed.
  SystemExit: If either failed.
   )rU   rY   printrM   exit)rR   rS   fnsuccesss       r    run_lintersr`      s=     (#T*w&MHHQK	 $ Mr   c                x   [         /nUR                  U R                  5        U R                  (       aa  SU R                  ;  a  UR                  S5        SU R                  ;  a  UR                  S5        UR                  SU R                   S35        SR	                  U5      /n[
        R                  R                  U R                  5      n/ n[        U5       GH  nUR                  R                  S   R                  S	:X  d   eUR                  R                  S	 UR                  UR                  5        UR                   H8  n[        U[        R                   5      (       d  M$  UR"                  S
:X  d  M6  Sn  O   Sn[        R                   " S5      /Ul        [%        U5      n[        R&                  " U5      c  UR(                  SS2	 OUR(                  SS2	 [
        R*                  " USS9n	U(       a  U	R-                  SS5      n	[.        R1                  [        U[        R2                  5      (       a  SOSU R4                  UR                  U-   5      n
U	[7        U
S5      -   nUR                  U5        GM     UR9                  5         UR;                  SSU< 35        SR	                  U5      $ )zRScan 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_protectionNr[   z    )indent_withz
->Iteratorz->AbstractContextManagerz await  z
__all__ = z

)HEADERr9   r   r   r=   astorcode_to_ast
parse_filer   r2   r6   r7   namer*   r"   r#   r+   r,   r@   get_docstringbody	to_sourcereplaceTEMPLATEr<   r%   r   r   sortinsert)rR   header	generatedrS   method_namesmethoddecis_cmnew_argsfunctemplatesnippets               r    gen_public_wrappers_sourcer}      s>   
 XF
MM$,,}} $,,.MM>?t||+MM.);DMM?#N	
 !I))$))4FL$V,{{"&&&000KKQFKK(((C#sxx((SVV7G-G )
 E "%*@!A B +62 V$,A AB v7;<<.HID ??#FC,@,@AAIsLLKK("
 '22 	!W -Z Q*\$456;;y!!r   c                    U R                  5        HJ  u  p[        R                  R                  U5      (       d    g[	        U5      R                  SS9nX2:w  d  MJ    g   g)NFutf-8)rJ   T)itemsosr   existsr   	read_text)	new_filesnew_path
new_source
old_sources       r    matches_disk_filesr   	  sQ     ) 1ww~~h''(^--w-?
# !2 r   c                  0 nU  H  n[        SUR                  5        [        U5      n[        X45      n[        R                  R                  UR                  5      u  pV[        R                  R                  U[        U-   5      nXBU'   M     [        U5      nU(       a5  U(       d"  [        S5        [        R                  " S5        g [        S5        g UR                  5        H+  u  pt[        USSSS9 n	U	R                  U5        S S S 5        M-     [        S	5        U(       d  [        R                  " S5        g g ! , (       d  f       Mh  = f)
Nz	Scanning:z2Generated sources are outdated. Please regenerate.r[   z!Generated sources are up to date.wr   
)rJ   newlinez!Regenerated sources successfully.)r\   r   r}   r`   r   splitr=   PREFIXr   rM   r]   r   openwrite)
filesdo_testr   rR   r   dirnamebasenamer   matches_diskfps
             r    processr     s    Ik499%/5
 2
GGMM$))477<<():;((  &i0LFGHHQK56$-OO$5 HhgtD$ ED %6 	12HHQK  EDs   6D>>
E	c                    [         R                  " SS9n U R                  SSSSS9  U R                  5       n[        R
                  " 5       nUS-  R                  5       (       d   eUS	-  n[        US
-  S[        S9[        US-  S[        S9[        US-  SS[        S9[        US-  SS[        S9[        US-  SS[        S9/n[        XAR                  S9  g )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])r1   r   r   z0Iterator[ast.FunctionDef | ast.AsyncFunctionDef])r>   z&ast.FunctionDef | ast.AsyncFunctionDefr   r   )rR   r   rS   r   r   ztuple[bool, str])rR   r   rS   r   r   r   )rR   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   rK   rM   pathlibr   textwrapr   typingr   r   collections.abcr   r   typing_extensionsr	   rh   r   rg   rp   definer   r'   r.   r2   r@   rU   rY   r`   r}   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   