
     fS-                    b   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j         G d d                      Zd2dZd2dZd3dZd4dZd5dZd5dZd6d Z d7d!Z!d8d%Z"d9d*Z#d:d+Z$d,Z%d-Z&d.Z'd/Z(d0Z)e*d1k    r e$             dS dS );zG
Code generation script for class methods
to be exported as public API
    )annotationsN)Path)indent)TYPE_CHECKING)IterableIterator)	TypeGuard
_generatedaE  # ***********************************************************
# ******* WARNING: AUTOGENERATED! ALL EDITS WILL BE LOST ******
# *************************************************************
from __future__ import annotations

import sys

from ._ki import LOCALS_KEY_KI_PROTECTION_ENABLED
from ._run import GLOBAL_RUN_CONTEXT
zsys._getframe().f_locals[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	<   d
S )Filer   pathstrmodname T)defaultkw_onlyplatformimportsN)__name__
__module____qualname____annotations__attrsfieldr   r        Z/var/www/api.educacionweb.es/myenv/lib/python3.11/site-packages/trio/_tools/gen_exports.pyr   r   1   sh         JJJLLLEKD999H99995;r4888G888888r   r   nodeast.ASTreturn1TypeGuard[ast.FunctionDef | ast.AsyncFunctionDef]c                N    t          | t          j        t          j        f          S )zHCheck if the AST node is either a function
    or an async function
    )
isinstanceastFunctionDefAsyncFunctionDef)r   s    r   is_functionr'   9   s     dS_c.BCDDDr   c                    t          |           r2| j        D ]*}t          |t          j                  r|j        dk    r dS +dS )z-Check if the AST node has a _public decorator_publicTF)r'   decorator_listr#   r$   Nameid)r   	decorators     r   	is_publicr.   @   sQ    4 , 	 	I)SX.. 9<93L3Ltt5r   tree0Iterator[ast.FunctionDef | ast.AsyncFunctionDef]c              #  ^   K   t          j        |           D ]}t          |          r|V  dS )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.   )r/   r   s     r   get_public_methodsr3   I   sA         T?? 	JJJ r   funcdef&ast.FunctionDef | ast.AsyncFunctionDefr   c                   d | j         j         D             }| j         j        r'|                    d| j         j        j        z              | j         j        D ]'}|                    |j        dz   |j        z              (| j         j        r'|                    d| j         j        j        z              d                    d                    |                    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)"
    c                    g | ]	}|j         
S r   )arg).0r8   s     r   
<listcomp>z+create_passthrough_args.<locals>.<listcomp>^   s    666S666r   *=z**z({})z, )argsvarargappendr8   
kwonlyargskwargformatjoin)r4   	call_argsr8   s      r   create_passthrough_argsrE   V   s     76GL$5666I| 8w|266777|& 2 2301111| 8 2 66777==9--...r   filesourcetuple[bool, str]c                    ddl }t          j        t          j        ddd| j        dg|dd	          }|j        dk    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!
)	rK   
subprocessrunsys
executabler   
returncodestderrstdout)rF   rG   rK   results       r   	run_blackr[   h   sv     LLL
 ^	w(:DIsK  F A>v}>>>>r   c                    ddl }t          j        t          j        dddddd| j        d	g	|d
d          }|j        dk    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   NrJ   ruffcheckz--fixz--unsafe-fixesrL   rM   TrN   rO   FzFailed to run ruff!
)	r]   rS   rT   rU   rV   r   rW   rX   rY   )rF   rG   r]   rZ   s       r   run_ruffr_      s     KKK^ NI
	
   F$ A=fm====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.
       )r[   printrU   exitr_   )rF   rG   successresponses       r   run_lintersrf      sq     "$//GX h x00GX hOr   c                   t           g}| j        r|                    | j                   | j        rZd| j        vr|                    d           d| j        vr|                    d           |                    d| j         d           d                    |          g}t
          j                            | j                  }g }t          |          D ]V}|j
        j
        d         j        d	k    sJ |j
        j
        d= |                    |j                   |j        D ]+}t          |t          j                  r|j        d
k    rd} n,d}g |_        t%          |          }t          j        |          |j        dd= n
|j        dd= t          j        |d          }	|r|	                    dd          }	t.                              t          |t          j                  rdnd| j        |j        |z             }
|	t7          |
d          z   }|                    |           X|                                 |                    dd|           d                    |          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contextmanagerTFNra   z    )indent_withz
->Iteratorz->ContextManagerz await  z
__all__ = z

)HEADERr   r?   r   rC   astorcode_to_ast
parse_filer   r3   r=   r8   namer*   r#   r$   r+   r,   rE   get_docstringbody	to_sourcereplaceTEMPLATErB   r&   r   r   sortinsert)rF   header	generatedrG   method_namesmethoddecis_cmnew_argsfunctemplatesnippets               r   gen_public_wrappers_sourcer      s   
 XF| $dl###} 	
 $,..MM>???t|++MM.)))NDMNNN	
 	
 	
 !I))$)44FL$V,, +" +"{"&&0000KQFK(((( 	 	C#sx(( SV7G-G-GE !# +622 V$$,AAA ABB v7;;; 	B<<.@AAD ??#FC,@AAJIIsLK("
 
 '222 	!!!!Q5\55666;;y!!!r   	new_filesdict[str, str]boolc                
   |                                  D ]m\  }}t          j                            |          s dS t	          |d          5 }|                                }d d d            n# 1 swxY w Y   ||k    r dS ndS )NFutf-8rR   T)itemsosr   existsopenread)r   new_path
new_sourceold_file
old_sources        r   matches_disk_filesr     s     ) 1 1  *w~~h'' 	55(W--- 	)!J	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)##55 $4s   A..A2	5A2	filesIterable[File]do_testNonec                  i }| D ]}t          d|j                   t          |          }t          ||          }t          j                            |j                  \  }}t          j                            |t          |z             }|||<   |rEt          |          s%t          d           t          j
        d           d S t          d           d S |                                D ]D\  }}t          |dd          5 }|                    |           d d d            n# 1 swxY w Y   Et          d           d S )	Nz	Scanning:z2Generated sources are outdated. Please regenerate.ra   z!Generated sources are up to date.wr   r   z!Regenerated sources successfully.)rb   r   r   rf   r   splitrC   PREFIXr   rU   rc   r   r   write)	r   r   r   rF   r   dirnamebasenamer   fs	            r   processr     s   I ) )k49%%%/55
 z22
GMM$)447<<():;;(	( 
3!),, 	7FGGGHQKKKKK566666$-OO$5$5 	$ 	$ Hjhg666 $!
###$ $ $ $ $ $ $ $ $ $ $ $ $ $ $122222s   D$$D(	+D(	c            
        t          j        d          } |                     dddd           |                                 }t	          j                    }|dz                                  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                   d S )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   3  sX   $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   r   r    r!   )r/   r   r    r0   )r4   r5   r    r   )rF   r   rG   r   r    rH   )rF   r   rG   r   r    r   )rF   r   r    r   )r   r   r    r   )r   r   r   r   r    r   )r    r   )+__doc__
__future__r   r   r$   r   rS   rU   pathlibr   textwrapr   typingr   r   collections.abcr   r   typing_extensionsr	   rm   r   rl   ru   definer   r'   r.   r3   rE   r[   r_   rf   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>r      sG    # " " " " "  



 				     



                          ,22222222++++++ 		
 9 9 9 9 9 9 9 9E E E E   
 
 
 
/ / / /$   ># # # #L   0H" H" H" H"V   3 3 3 30(/ (/ (/ (/V 		 zDFFFFF r   