o
    Rh(#                     @  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Z6eG d&d' d'e6ej7Z8eG d(d) d)e6ej9Z:dS ).    )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                   sF   d fdd}t | jr!d	j d
j 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+    L/home/air/sanwanet/backup_V2/venv/lib/python3.10/site-packages/trio/_path.pywrapper%   s    z0_wraps_async.<locals>.decorator.<locals>.wrapperzLike :meth:`~.z`, but async.


)r.   r/   r0   r1   r)   r&   )r   __doc__
__module____qualname__r   r+   r6   r'   r3   r5   	decorator$   s   
z_wraps_async.<locals>.decorator)r+   r,   r)   r-   r4   )r'   r>   r4   r=   r5   _wraps_async!   s   r?   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rB   r.   r0   r3   r4   r5   r6   7   s   z_wrap_method.<locals>.wrapper)rB   r$   r.   r/   r0   r1   r)   r&   r?   r<   r4   r3   r5   _wrap_method4      rF   4Callable[Concatenate[pathlib.Path, P], pathlib.Path]1Callable[Concatenate[PathT, P], Awaitable[PathT]]c                   s   t  d
 fdd	}|S )NrB   r#   r.   r/   r0   r1   r)   c                  s"   |   | | g|R i |S r2   )	__class__rC   rD   r3   r4   r5   r6   A   s   "z"_wrap_method_path.<locals>.wrapper)rB   r#   r.   r/   r0   r1   r)   r#   rE   r<   r4   r3   r5   _wrap_method_path>   rG   rK   >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 )NrB   r#   r.   r/   r0   r1   r)   Iterable[PathT]c                  s(   t | jg  | | g|R i |S r2   )maprJ   rC   rD   r3   r4   r5   r6   K   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).
)rB   r#   r.   r/   r0   r1   r)   rN   )r?   r9   __name__r<   r4   r3   r5   _wrap_method_path_iterableH   s   rQ   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]]rC   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$   osnameWindowsPath	PosixPathsuper__new__)clsr.   rJ   r4   r5   rZ   n   s   zPath.__new__c                 C     | t j S r2   )pathlibr$   cwdr[   r4   r4   r5   r_   s      zPath.cwdc                 C  r]   r2   )r^   r$   homer`   r4   r4   r5   rb   x   ra   z	Path.homerNmoder   	bufferingintencoding
str | NoneerrorsnewlineAsyncIOWrapper[TextIOWrapper]c                      d S r2   r4   rB   re   rf   rh   rj   rk   r4   r4   r5   open}      z	Path.openr   
Literal[0]NoneAsyncIOWrapper[FileIO]c                   rm   r2   r4   rn   r4   r4   r5   ro      rp   r   Literal[-1, 1]AsyncIOWrapper[BufferedRandom]c                   rm   r2   r4   rn   r4   r4   r5   ro      rp   r   AsyncIOWrapper[BufferedWriter]c                   rm   r2   r4   rn   r4   r4   r5   ro      rp   r   AsyncIOWrapper[BufferedReader]c                   rm   r2   r4   rn   r4   r4   r5   ro      rp   AsyncIOWrapper[BinaryIO]c                   rm   r2   r4   rn   r4   r4   r5   ro      rp   strAsyncIOWrapper[IO[Any]]c                   rm   r2   r4   rn   r4   r4   r5   ro      rp   r   r0   c                 O  s   t | | j|i |S r2   )r   rC   ro   rD   r4   r4   r5   ro      s   c                 C  s   dt | dS )Nz
trio.Path())ry   rB   r4   r4   r5   __repr__   s   zPath.__repr__)      win32)r~   
   )r~      c                 C  s   t j| S r2   )r^   r$   as_urir|   r4   r4   r5   r      s   zPath.as_uri)r.   rS   r)   r!   )r)   r!   )rc   rd   NNN)re   r   rf   rg   rh   ri   rj   ri   rk   ri   r)   rl   )NNN)re   r   rf   rq   rh   rr   rj   rr   rk   rr   r)   rs   )rd   NNN)re   r   rf   rt   rh   rr   rj   rr   rk   rr   r)   ru   )re   r   rf   rt   rh   rr   rj   rr   rk   rr   r)   rv   )re   r   rf   rt   rh   rr   rj   rr   rk   rr   r)   rw   )re   r   rf   rg   rh   rr   rj   rr   rk   rr   r)   rx   )re   ry   rf   rg   rh   ri   rj   ri   rk   ri   r)   rz   )r.   r   r0   r   r)   rz   )r)   ry   )>rP   r:   r;   r9   	__slots____annotations__rZ   classmethodr?   r^   r$   r_   rb   r   ro   r}   rF   statchmodexistsrQ   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_mountrK   readlinkrenamereplace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$   c   s   
 

						
	

c                   @  $   e Zd ZU dZdZejZded< dS )rX   zfAn async :class:`pathlib.PosixPath` that executes blocking methods in :meth:`trio.to_thread.run_sync`.r4   rR   rC   N)	rP   r:   r;   r9   r   r^   rX   rC   r   r4   r4   r4   r5   rX         
 rX   c                   @  r   )rW   zhAn async :class:`pathlib.WindowsPath` that executes blocking methods in :meth:`trio.to_thread.run_sync`.r4   rR   rC   N)	rP   r:   r;   r9   r   r^   rW   rC   r   r4   r4   r4   r5   rW     r   rW   )r'   r(   r)   r*   )r+   r@   r)   rA   )r+   rH   r)   rI   )r+   rL   r)   rM   );
__future__r   rU   r^   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&   r?   rF   rK   rQ   PurePathr$   PurePosixPathrX   PureWindowsPathrW   r4   r4   r4   r5   <module>   s8    $





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