o
    Oh*%                     @  s  d dl mZ d dlZd dlZd dlZd dlmZmZ d dlm	Z	 d dl
mZmZmZmZmZmZmZ d dlmZmZ d dlmZ d dlmZ erd d	lmZmZmZ d d
lmZmZm Z m!Z!m"Z" d dl#m$Z$m%Z%m&Z&m'Z'm(Z( d dl)m*Z*m+Z+m,Z,m-Z- e,dZ.edddZ/edZ0d,ddZ1d-ddZ2d.dd Z3d/d#d$Z4G d%d dej5Z6e6j7j8re6j7j89d&d'e6j7_8eG d(d) d)e6ej:Z;eG d*d+ d+e6ej<Z=dS )0    )annotationsN)partialupdate_wrapper)cleandoc)IOTYPE_CHECKINGAnyBinaryIOClassVarTypeVaroverload)AsyncIOWrapper	wrap_file)final)run_sync)	AwaitableCallableIterable)BufferedRandomBufferedReaderBufferedWriterFileIOTextIOWrapper)OpenBinaryModeOpenBinaryModeReadingOpenBinaryModeUpdatingOpenBinaryModeWritingOpenTextMode)ConcatenateLiteral	ParamSpecSelfPPathTPath)boundTwrappedCallable[..., object]return5Callable[[Callable[P, T]], Callable[P, Awaitable[T]]]c                   s   d fdd}|S )NfnCallable[P, T]r)   Callable[P, Awaitable[T]]c                   sr   d fdd}t | jr7j}|d	d
}|dd
}j}|dd}d| d| dtj d|_|S )NargsP.argskwargsP.kwargsr)   r&   c                    s"   t t g| R i |I d H S N)r   r   )r.   r0   r+    G/home/air/yokohama/back/venv/lib/python3.10/site-packages/trio/_path.pywrapper%   s    z0_wraps_async.<locals>.decorator.<locals>.wrapperzpathlib._localpathlibzpathlib._abcPathBaser$   zLike :meth:`~.z`, but async.


)r.   r/   r0   r1   r)   r&   )r   __doc__
__module__replace__qualname__r   )r+   r6   modulenamer'   r3   r5   	decorator$   s   
z_wraps_async.<locals>.decorator)r+   r,   r)   r-   r4   )r'   rB   r4   rA   r5   _wraps_async!   s   rC   r+   )Callable[Concatenate[pathlib.Path, P], T],Callable[Concatenate[Path, P], Awaitable[T]]c                   s   t  d fd	d
}|S )Nselfr$   r.   r/   r0   r1   r)   r&   c                  s    |  | g|R i |S r2   )_wrapped_clsrF   r.   r0   r3   r4   r5   r6   A   s   z_wrap_method.<locals>.wrapper)rF   r$   r.   r/   r0   r1   r)   r&   rC   r+   r6   r4   r3   r5   _wrap_method>      rK   4Callable[Concatenate[pathlib.Path, P], pathlib.Path]1Callable[Concatenate[PathT, P], Awaitable[PathT]]c                   s   t  d
 fdd	}|S )NrF   r#   r.   r/   r0   r1   r)   c                  s"   |   | | g|R i |S r2   )	__class__rG   rH   r3   r4   r5   r6   K   s   "z"_wrap_method_path.<locals>.wrapper)rF   r#   r.   r/   r0   r1   r)   r#   rI   rJ   r4   r3   r5   _wrap_method_pathH   rL   rP   >Callable[Concatenate[pathlib.Path, P], Iterable[pathlib.Path]];Callable[Concatenate[PathT, P], Awaitable[Iterable[PathT]]]c                   s8   t  d fd	d
}|jr| jd j d7  _|S )NrF   r#   r.   r/   r0   r1   r)   Iterable[PathT]c                  s(   t | jg  | | g|R i |S r2   )maprO   rG   rH   r3   r4   r5   r6   U   s   (z+_wrap_method_path_iterable.<locals>.wrapperz
This is an async method that returns a synchronous iterator, so you
use it like:

.. code:: python

    for subpath in await mypath.z():
        ...

.. note::

    The iterator is loaded into memory immediately during the initial
    call (see `issue #501
    <https://github.com/python-trio/trio/issues/501>`__ for discussion).
)rF   r#   r.   r/   r0   r1   r)   rS   )rC   r;   __name__rJ   r4   r3   r5   _wrap_method_path_iterableR   s   rV   c                      sP  e Zd ZU dZdZded< d< fd	d
Zeee	j
jd=ddZeee	j
jd=ddZe					d>d?ddZe			d@dAd!dZe				dBdCd%dZe				dBdDd(dZe				dBdEd+dZe				dBdFd-dZe				dBdGd0dZee	j
jdHd3dZdId4d5Zee	j
jZee	j
jZee	j
jZee	j
jZee	j
jZee	j
jZee	j
jZee	j
jZee	j
jZee	j
jZee	j
jZee	j
jZejd6kree	j
j Z ee	j
j!Z!ee	j
j"Z"ee	j
j#Z#ee	j
j$Z$ej%d7kree	j
j&Z&ee	j
j'Z'ej%d7ksejd6kr!ee	j
j(Z(e)e	j
j*Z*e)e	j
j+Z+e)e	j
j,Z,e)e	j
j-Z-ee	j
j.Z.ee	j
j/Z/ejd8krQee	j
j0Z0ee	j
j1Z1ee	j
j2Z2e)e	j
j3Z3e)e	j
j4Z4ee	j
j5Z5ee	j
j6Z6ee	j
j7Z7ee	j
j8Z8ee	j
j9Z9ejd6k ree	j
j:Z:ejd9kree	j
j;Z;dId:d;Z<  Z=S )Jr$   zAn async :class:`pathlib.Path` that executes blocking methods in :meth:`trio.to_thread.run_sync`.

    Instantiating :class:`Path` returns a concrete platform-specific subclass, one of :class:`PosixPath` or
    :class:`WindowsPath`.
    r4   ClassVar[type[pathlib.Path]]rG   r.   str | os.PathLike[str]r)   r!   c                   s.   | t u rtjdkrtnt} t j| g|R  S )Nnt)r$   osr@   WindowsPath	PosixPathsuper__new__)clsr.   rO   r4   r5   r^   x   s   zPath.__new__c                 C     | t j S r2   )r7   r$   cwdr_   r4   r4   r5   rb   }      zPath.cwdc                 C  ra   r2   )r7   r$   homerc   r4   r4   r5   re      rd   z	Path.homerNmoder   	bufferingintencoding
str | NoneerrorsnewlineAsyncIOWrapper[TextIOWrapper]c                      d S r2   r4   rF   rh   ri   rk   rm   rn   r4   r4   r5   open      z	Path.openr   
Literal[0]NoneAsyncIOWrapper[FileIO]c                   rp   r2   r4   rq   r4   r4   r5   rr      rs   r   Literal[-1, 1]AsyncIOWrapper[BufferedRandom]c                   rp   r2   r4   rq   r4   r4   r5   rr      rs   r   AsyncIOWrapper[BufferedWriter]c                   rp   r2   r4   rq   r4   r4   r5   rr      rs   r   AsyncIOWrapper[BufferedReader]c                   rp   r2   r4   rq   r4   r4   r5   rr      rs   AsyncIOWrapper[BinaryIO]c                   rp   r2   r4   rq   r4   r4   r5   rr      rs   strAsyncIOWrapper[IO[Any]]c                   rp   r2   r4   rq   r4   r4   r5   rr      rs   r   r0   c                 O  s   t | | j|i |S r2   )r   rG   rr   rH   r4   r4   r5   rr      s   c                 C  s   dt | dS )Nz
trio.Path())r|   rF   r4   r4   r5   __repr__   s   zPath.__repr__)      win32)r   
   )r      c                 C  s   t j| S r2   )r7   r$   as_urir   r4   r4   r5   r     s   zPath.as_uri)r.   rX   r)   r!   )r)   r!   )rf   rg   NNN)rh   r   ri   rj   rk   rl   rm   rl   rn   rl   r)   ro   )NNN)rh   r   ri   rt   rk   ru   rm   ru   rn   ru   r)   rv   )rg   NNN)rh   r   ri   rw   rk   ru   rm   ru   rn   ru   r)   rx   )rh   r   ri   rw   rk   ru   rm   ru   rn   ru   r)   ry   )rh   r   ri   rw   rk   ru   rm   ru   rn   ru   r)   rz   )rh   r   ri   rj   rk   ru   rm   ru   rn   ru   r)   r{   )rh   r|   ri   rj   rk   rl   rm   rl   rn   rl   r)   r}   )r.   r   r0   r   r)   r}   )r)   r|   )>rU   r<   r>   r;   	__slots____annotations__r^   classmethodrC   r7   r$   rb   re   r   rr   r   rK   statchmodexistsrV   globrglobis_diris_file
is_symlink	is_socketis_fifois_block_deviceis_char_devicesysversion_infois_junctioniterdirlchmodlstatmkdirplatformownergroupis_mountrP   readlinkrenamer=   resolvermdir
symlink_tohardlink_totouchunlinkabsolute
expanduser
read_bytes	read_textsamefilewrite_bytes
write_textlink_to
full_matchr   __classcell__r4   r4   r`   r5   r$   m   s   
 

						
	

z `..` z ``..`` c                   @  $   e Zd ZU dZdZejZded< dS )r\   zfAn async :class:`pathlib.PosixPath` that executes blocking methods in :meth:`trio.to_thread.run_sync`.r4   rW   rG   N)	rU   r<   r>   r;   r   r7   r\   rG   r   r4   r4   r4   r5   r\   	     
 r\   c                   @  r   )r[   zhAn async :class:`pathlib.WindowsPath` that executes blocking methods in :meth:`trio.to_thread.run_sync`.r4   rW   rG   N)	rU   r<   r>   r;   r   r7   r[   rG   r   r4   r4   r4   r5   r[     r   r[   )r'   r(   r)   r*   )r+   rD   r)   rE   )r+   rM   r)   rN   )r+   rQ   r)   rR   )>
__future__r   rZ   r7   r   	functoolsr   r   inspectr   typingr   r   r   r	   r
   r   r   trio._file_ior   r   
trio._utilr   trio.to_threadr   collections.abcr   r   r   ior   r   r   r   r   	_typeshedr   r   r   r   r   typing_extensionsr   r   r    r!   r"   r#   r&   rC   rK   rP   rV   PurePathr$   relative_tor;   r=   PurePosixPathr\   PureWindowsPathr[   r4   r4   r4   r5   <module>   s<    $





 