
    #)f-                    \   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

from ._ki import LOCALS_KEY_KI_PROTECTION_ENABLED
from ._run import GLOBAL_RUN_CONTEXT
zlocals()[LOCALS_KEY_KI_PROTECTION_ENABLED] = True
try:
    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        T/var/www/html/flask-app/venv/lib/python3.12/site-packages/trio/_tools/gen_exports.pyr   r   /   s:    
JLEKKD9Hc95;;r48GS8r   r   c                Z    t        | t        j                  t        j                  f      ryy)zHCheck if the AST node is either a function
    or an async function
    TF)
isinstanceastFunctionDefAsyncFunctionDef)nodes    r   is_functionr$   7   s#     $#*>*>?@r   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/   I   s+       T?Js   $..c                ^   g }| j                   j                   D ]  }|j                  |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 )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appendargvararg
kwonlyargskwargformatjoin)funcdef	call_argsr5   s      r   create_passthrough_argsr=   V   s     I||   "!"||w||226667||&& 23012|| 2 2 6 667==9-..r   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   j   so     
 ^^	w(:DIIsKF A.v}}o>>>r   c                    ddl }t        j                  t        j                  d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-fixesz--output-format=textrA   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        | |      \  }}|s t        |       t        j                  d       t	        | |      \  }}|s t        |       t        j                  d       |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   printrJ   exitrV   )rO   rP   successresponses       r   run_lintersr]      sU     "$/GXh x0GXhOr   c                &   t         g}| j                  r|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 ]y  }|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}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contextmanagerTFNrX   z    )indent_withz
->Iteratorz->ContextManagerz await  z
__all__ = z

)HEADERr   r4   r   r:   astorcode_to_ast
parse_filer   r/   r3   r5   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_sourcery      s9   
 XF||dll#}} $,,.MM>?t||+MM.);DMM?#N	
 !I))$))4FL$V, +"{{"&&&00KKQFKK((( 	C#sxx(SVV7G-G	
 E !# +62 V$,A AB v7;<<.@AD ??#FC,@,@AIsLLKK("
 '22 	!W+"Z Q*\$456;;y!!r   c                    | j                         D ]S  \  }}t        j                  j                  |      s yt	        |d      5 }|j                         }d d d        |k7  sS y y# 1 sw Y   xY w)NFutf-8rG   T)itemsosr   existsopenread)	new_filesnew_path
new_sourceold_file
old_sources        r   matches_disk_filesr     sl     ) 1 *ww~~h'(W- 	)!J	)# 		) 	)s   A((A1	c               B   i }| D ]  }t        d|j                         t        |      }t        ||      }t        j                  j                  |j                        \  }}t        j                  j                  |t        |z         }|||<    |r8t        |      s!t        d       t        j                  d       y t        d       y |j                         D ]-  \  }}t        |dd      5 }|j                  |       d d d        / t        d       y # 1 sw Y   ExY w)	Nz	Scanning:z2Generated sources are outdated. Please regenerate.rX   z!Generated sources are up to date.wr{   r|   z!Regenerated sources successfully.)rY   r   ry   r]   r~   splitr:   PREFIXr   rJ   rZ   r}   r   write)	filesdo_testr   rO   r   dirnamebasenamer   fs	            r   processr     s    I )k499%/5
 z2
GGMM$))477<<():;(	() !),FGHHQK56$-OO$5 	$ Hjhg6 $!
#$ $	$ 	12$ $s   -DD	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   6  s   $$BF $|2T   ##%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
zfrom typing import Callable, ContextManager, TYPE_CHECKING

if TYPE_CHECKING:
    import select

    from .. import _core
    from ._traps import Abort, RaiseCancelT
    from .._file_io import _HasFileNo
zfrom typing import TYPE_CHECKING, ContextManager

if TYPE_CHECKING:
    from .._file_io import _HasFileNo
    from ._windows_cffi import Handle, CData
    from typing_extensions import Buffer

    from ._unbounded_queue import UnboundedQueue
__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	   rd   r   rc   rl   definer   r$   r+   r/   r=   rR   rV   r]   ry   r   r   r   r   r   r   r   r   r   r   r   r   <module>r      s    #  
 	  
     2+ 	
 9 9 9


5
/(>$N0H"V30(/V 		 zF r   