Ë
    _§1h³-  ã                  ó\  — 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
z‡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   © ó    úU/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/trio/_tools/gen_exports.pyr   r   0   s:   … à
ƒJØƒLØ�E—K‘K¨°DÔ9€HˆcÓ9Ø�5—;‘; r°4Ô8€GˆSÔ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    € ô �dœSŸ_™_¬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Ü˜)¤S§X¡XÕ.°9·<±<À9Ó3LÙð	ð r   c              #  ó`   K  — t        j                  | «      D ]  }t        |«      sŒ|–— Œ y­w)z¢Return 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Ú   € ð %,§L¡L×$5Ñ$5Ö6˜S�—“Ð6€IÐ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Ð(:¸D¿I¹IÀsÐ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€   € ó ä�^‰^ô �N‰NØØØØØØØ�I‰IØð
	
ð ØØô€Fð$ ×Ñ˜AÒØÐ-¨f¯m©m¨_Ð=Ð=Ð=Ø�—‘ÐÐr   c                ó†   — t         t        fD ]1  } || |«      \  }}|rŒt        |«       t        j                  d«       Œ3 |S )z¿Format 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   € ô œ(Ð#ò ˆÙ˜T 6Ó*‰ˆ�ÚÜ�&ŒMÜ�H‰H�Q�Kð	ð €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   À   sB  € ô
 ˆX€FØ
‡M�M�$—,‘,ÔØ‡}‚}ð  $§,¡,Ñ.Ø�M‰MÐ>Ô?Ø˜tŸ|™|Ñ+Ø�M‰M˜.Ô)Ø�‰Ø;¸D¿M¹M¸?È#ÐNô	
ð —‘˜“Ð!€Iä×Ñ×)Ñ)¨$¯)©)Ó4€FØ€LÜ$ VÓ,ó +"ˆà�{‰{×Ñ Ñ"×&Ñ&¨&Ò0Ð0Ð0Ø�K‰K×Ñ˜QÐØ×Ñ˜FŸK™KÔ(à×(Ñ(ò 	ˆCÜ˜#œsŸx™xÕ(¨S¯V©VÐ7GÓ-GØ�Ùð	ð
 ˆEô "%§¡Ð*@Ó!AÐ BˆÔô +¨6Ó2ˆô ×Ñ˜VÓ$Ð,Ø—‘šA‘ð —‘˜A™B�ô �‰˜v°7Ô;ˆáØ—<‘< Ð.HÓIˆDô —?‘?Ü# F¬C×,@Ñ,@ÔA‰IÀsØ�L‰LØ�K‰K˜(Ñ"ó
ˆð œ ¨'Ó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ò Ñˆ�*Ü�w‰w�~‰~˜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Øò )ˆÜˆk˜4Ÿ9™9Ô%Ü/°Ó5ˆ
Ü   zÓ2ˆ
ÜŸG™GŸM™M¨$¯)©)Ó4Ñˆ�Ü—7‘7—<‘< ¬°(Ñ):Ó;ˆØ(ˆ	�(Òð)ô & iÓ0€LÙÙÜÐFÔGÜ�H‰H�Q�KäÐ5Õ6à$-§O¡OÓ$5ò 	%Ñ ˆH�jÜ�h ¨g¸tÔDð %ÈØ—‘˜Ô$÷%ð %ð	%ô 	Ð1Ô2Ùä�H‰H�Q�Kð ÷%ð %ú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äˆT�IÑ˜x´Ô=ÜØÐ(Ñ(Ø Ü&ô	
ô
 	ØÐ#Ñ#ØØÜ#ô		
ô 	Ø�>Ñ!ØØÜ!ô		
ô 	Ø�?Ñ"ØØÜ"ô		
ð'€Gô6 ˆ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   