a �DOg9��@sbddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z m Z m Z mZmZddlmZddlmZmZmZmZmZmZmZddlmZdZejdkr�ddlZe� �dd �d kr�dd lm!Z!q�d ZdZ!ndZgd �Z"e e eefZ#dZ$dd�Z%dd�Z&Gdd�de'�Z(Gdd�de(�Z)Gdd�de(�Z*e)�Z+e*�Z,Gdd�d�Z-Gdd�de-�Z.e.�Z/dd�Z0e1ed��r�e�2�e0�Z0Gd d!�d!�Z3Gd"d#�d#�Z4Gd$d%�d%e3�Z5Gd&d'�d'e3�Z6Gd(d)�d)e3�Z7Gd*d+�d+e �Z8Gd,d-�d-e'�Z9ej:�;e9�Gd.d/�d/e9�ZGd4d5�d5e>e<�Z?Gd6d7�d7e>e=�Z@dS)8�N)�Sequence)�EINVAL�ENOENT�ENOTDIR�EBADF�ELOOP)� attrgetter)�S_ISDIR�S_ISLNK�S_ISREG�S_ISSOCK�S_ISBLK�S_ISCHR�S_ISFIFO)�quote_from_bytesT�nt�)�r)�_getfinalpathnameF)�PurePath� PurePosixPath�PureWindowsPath�Path� PosixPath� WindowsPath)��{i�cCs t|dd�tvpt|dd�tvS)N�errno�winerror)�getattr�_IGNORED_ERROS�_IGNORED_WINERRORS)� exception�r#�/usr/lib64/python3.9/pathlib.py� _ignore_error.s�r%cCsd|vpd|vpd|vS)N�*�?�[r#)�patr#r#r$�_is_wildcard_pattern3sr*c@s(eZdZdZdd�Zdd�Zdd�ZdS) �_FlavourzPA flavour implements a particular (platform-specific) set of path semantics.cCs|jj|_dS�N)�sep�join��selfr#r#r$�__init__=sz_Flavour.__init__c Csg}|j}|j}d}}t|�}|D]�}|s.q$|r>|�||�}|�|�\}}} || vr�t| �|��D] } | rd| dkrd|�t�| ��qdn| r�| dkr�|�t�| ��|s�|r$|s�|D]0}|s�q�|r�|�||�}|�|�d}|r�q�q�q�q$|s�|�r|�||�|� �|||fS)N��.r) r-�altsep�reversed�replace� splitroot�split�append�sys�intern�reverse) r0�parts�parsedr-r4�drv�root�it�part�rel�xr#r#r$� parse_parts@s@     z_Flavour.parse_partscCsz|r*|sp|rp||||g|dd�fSnF|rb||ksJ|�|�|�|�krp||||dd�fSn||||fS|||fS)z� Join the two paths represented by the respective (drive, root, parts) tuples. Return a new (drive, root, parts) tuple. �N)�casefold)r0r?r@r=�drv2�root2�parts2r#r#r$�join_parsed_partsfsz_Flavour.join_parsed_partsN)�__name__� __module__� __qualname__�__doc__r1rErKr#r#r#r$r+9s&r+c@s�eZdZdZdZdZeZej dkZ e d�Z dZ hd�dd �d D�Bd d �d D�BZefd d �Zdd�Zdd�Zdd�Zd"dd�Ze fdd�Zdd�Zdd�Zdd�Zdd �Zd!S)#�_WindowsFlavour�\�/TrZ4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZz\\?\>zCONOUT$�PRN�AUX�CONzCONIN$�NULcCsh|] }d|�qS)zCOM%sr#��.0�cr#r#r$� ��z_WindowsFlavour.u123456789¹²³cCsh|] }d|�qS)zLPT%sr#rWr#r#r$rZ�r[c Cs\|dd�}|dd�}||krP||krP|�|�\}}|dd�}|dd�}nd}|dd�}||kr�||kr�||kr�|�|d�}|dkr�|�||d�}||dkr�|dkr�t|�}|r�||d|�|||dd�fS|d|�|||dd�fSd} } |dk�r6||jv�r6|dd�} |dd�}|}||k�rN|} |�|�}|| | |fS)NrrFrr2�������:)�_split_extended_path�find�len� drive_letters�lstrip) r0rBr-�first�second�prefix�third�index�index2r?r@r#r#r$r7�s6      "    z_WindowsFlavour.splitrootcCs|��Sr,��lower�r0�sr#r#r$rG�sz_WindowsFlavour.casefoldcCsdd�|D�S)NcSsg|] }|���qSr#rj)rX�pr#r#r$� �r[z2_WindowsFlavour.casefold_parts..r#�r0r=r#r#r$�casefold_parts�sz_WindowsFlavour.casefold_partscCst�t�|�tj�jSr,)�re�compile�fnmatch� translate� IGNORECASE� fullmatch�r0�patternr#r#r$�compile_pattern�sz_WindowsFlavour.compile_patternFcCs�t|�}|st��Sd}tdur�|r2|�t|��Sg}z|�t|��}Wn@ty�|}tj�|�\}}|�|�||kr�|YSYq60tjj |gt |��R�Sq6dSr,) �str�os�getcwdr�_ext_to_normal�FileNotFoundError�pathr8r9r.r5)r0r��strictrm� previous_s� tail_parts�tailr#r#r$�resolve�s$  z_WindowsFlavour.resolvecCsXd}|�|�rP|dd�}|dd�}|�d�rP||dd�7}d|dd�}||fS)Nr2�zUNC\r\rQ)� startswith)r0rm� ext_prefixrfr#r#r$r_�s    z$_WindowsFlavour._split_extended_pathcCs|�|�dS�NrF)r_rlr#r#r$r~�sz_WindowsFlavour._ext_to_normalcCsJ|sdS|d�d�rdS|d�d�d�d�d�d�}|��|jvS)NFrz\\r]r3r^� )r�� partition�rstrip�upper�reserved_names)r0r=�namer#r#r$� is_reserved�s "z_WindowsFlavour.is_reservedcCsd|j}t|�dkrJ|ddkrJ|��dd��d�}d|t|�d��fSdt|���d��SdS)NrrFr^rRz file:///%s/%szutf-8zfile:)�drivera�as_posixrc�urlquote_from_bytes�encode)r0r�r��restr#r#r$�make_uri�s�z_WindowsFlavour.make_uricCs�dtjvrtjd}nHdtjvrVztjd}WntyDd}Yn0|tjd}ntd��|r�tjd|kr�|�|f�\}}}|dtjdkr�td|��||d<|s�|r�|||�|d d��}n |�|�}|S) N� USERPROFILE�HOMEPATH� HOMEDRIVEr2zCan't determine home directory�USERNAMEr]�%Can't determine home directory for %rrF)r|�environ�KeyError� RuntimeErrorrEr.)r0�username�userhomer?r@r=r#r#r$� gethomedir s*     � z_WindowsFlavour.gethomedirN)F)rLrMrNr-r4�has_drv�ntpath�pathmodr|r�� is_supported�setrb�ext_namespace_prefixr�r7rGrqrzr�r_r~r�r�r�r#r#r#r$rPxs.  � �� '    rPc@sleZdZdZdZdZeZej dkZ efdd�Z dd�Z d d �Z d d �Zdd d�Zdd�Zdd�Zdd�ZdS)� _PosixFlavourrRr2FrcCsV|rH|d|krH|�|�}t|�t|�dkrsz_PosixFlavour.casefoldcCs|Sr,r#rpr#r#r$rqAsz_PosixFlavour.casefold_partscCst�t�|��jSr,)rrrsrtrurwrxr#r#r$rzDsz_PosixFlavour.compile_patterncsJ|j�|j�i������fdd��|��r0dnt��}�|t|��pH�S)Nc s�|���rd}|���D]�}|r|dkr*q|dkrD|���\}}}q|���rX||}n |�|}|�vr��|}|dur~qtd|��z��|�}Wn8ty�}z |jtkr��r��|}WYd}~qd}~00d�|<�||�}|�|<q|S)Nr2r3�..zSymlink loop from %r) r�r8� rpartition�endswithr��readlink�OSErrorrr)r�r�r��_�newpath�target�e��_resolve�accessor�seenr-r�r#r$r�Ks4        z'_PosixFlavour.resolve.._resolver2)r-� _accessor� is_absoluter|r}r{)r0r�r��baser#r�r$r�Gs )z_PosixFlavour.resolvecCsdS�NFr#rpr#r#r$r�wsz_PosixFlavour.is_reservedcCst|�}dt|�S)Nzfile://)�bytesr�)r0r��bpathr#r#r$r�zsz_PosixFlavour.make_uricCsx|s>z tjdWSty:ddl}|�t���jYS0n6ddl}z|�|�jWStyrtd|��Yn0dS)N�HOMErr�) r|r�r��pwd�getpwuid�getuid�pw_dir�getpwnamr�)r0r�r�r#r#r$r��s   �z_PosixFlavour.gethomedirN)F)rLrMrNr-r4r�� posixpathr�r|r�r�r7rGrqrzr�r�r�r�r#r#r#r$r�'s   0r�c@seZdZdZdS)� _AccessorzjAn accessor implements a particular (system-specific or not) way of accessing paths on the filesystem.N)rLrMrNrOr#r#r#r$r��sr�c@s�eZdZejZejZejZejZejZej Z e ed�r>ej Z ndd�Z ej Z ej Z e ed�rdejZn edd��ZejZejZejZer�er�ejZq�dd�Zn ed d��ZejZd d �Zd d �Zdd�ZdS)�_NormalAccessor�lchmodcCs td��dS)Nz%lchmod() not available on this system��NotImplementedError)r0�pathobj�moder#r#r$r��sz_NormalAccessor.lchmod�linkcCs td��dS)Nz&os.link() not available on this systemr��r0r�r#r#r$�link_to�sz_NormalAccessor.link_tocCs td��dS)Nz&symlink() not available on this systemr���a�b�target_is_directoryr#r#r$�symlink�sz_NormalAccessor.symlinkcCs t�||�Sr,)r|r�r�r#r#r$r��scCs t�|�Sr,)r|r��r0r�r#r#r$r��sz_NormalAccessor.readlinkcCs>zddl}|�|�|�j�jWSty8td��Yn0dS)Nrz*Path.owner() is unsupported on this system)r�r��stat�st_uid�pw_name� ImportErrorr�)r0r�r�r#r#r$�owner�s  z_NormalAccessor.ownercCs>zddl}|�|�|�j�jWSty8td��Yn0dS)Nrz*Path.group() is unsupported on this system)�grp�getgrgidr��st_gid�gr_namer�r�)r0r�r�r#r#r$�group�s  z_NormalAccessor.groupN)rLrMrNr|r��lstat�open�listdir�scandir�chmod�hasattrr��mkdir�unlinkr�r�� staticmethod�rmdir�renamer6r�supports_symlinksr��utimer�r�r�r#r#r#r$r��s8     r�cCsR|d}|dd�}|dkr"t}n$d|vr4td��nt|�rBt}nt}||||�S)NrrF�**z:Invalid pattern: '**' can only be an entire path component)�_RecursiveWildcardSelector� ValueErrorr*�_WildcardSelector�_PreciseSelector)� pattern_parts�flavourr)� child_parts�clsr#r#r$�_make_selector�s  r�� lru_cachec@s eZdZdZdd�Zdd�ZdS)� _SelectorzYA selector matches a specific glob pattern part against the children of a given path.cCs0||_|rt||�|_d|_nt�|_d|_dS)NTF)r�r�� successor�dironly�_TerminatingSelector)r0r�r�r#r#r$r1�s  z_Selector.__init__cCs<t|�}|j}|j}|jj}||�s,tg�S|�||||�S)zuIterate over all child paths of `parent_path` matched by this selector. This can contain parent_path itself.)�type�is_dir�existsr�r��iter� _select_from)r0� parent_path�path_clsr�r�r�r#r#r$� select_fromsz_Selector.select_fromN)rLrMrNrOr1rr#r#r#r$r��s r�c@seZdZdd�ZdS)r�ccs |VdSr,r#)r0r�r�r�r�r#r#r$r�sz!_TerminatingSelector._select_fromN)rLrMrNr�r#r#r#r$r�sr�c@seZdZdd�Zdd�ZdS)r�cCs||_t�|||�dSr,)r�r�r1)r0r�r�r�r#r#r$r1sz_PreciseSelector.__init__ccsZz@|�|j�}|jr|n||�r>|j�||||�D] }|Vq2WntyTYdS0dSr,)�_make_child_relpathr�r�r�r��PermissionError)r0r�r�r�r�r�rnr#r#r$r�s   z_PreciseSelector._select_fromN�rLrMrNr1r�r#r#r#r$r�sr�c@seZdZdd�Zdd�ZdS)r�cCs|�|�|_t�|||�dSr,)rz�matchr�r1�r0r)r�r�r#r#r$r1(s z_WildcardSelector.__init__c cs�z�||��}t|�}Wd�n1s(0Y|D]�}|jr�z|��sNWq6Wn:ty�}z"t|�sj�WYd}~q6WYd}~n d}~00|j} |�| �r6|�| �} |j� | |||�D] } | Vq�q6Wnt y�YdS0dSr,) �listr�r�r�r%r�rrr�r�r) r0r�r�r�r�� scandir_it�entries�entryr�r�r�rnr#r#r$r�,s& &"   z_WildcardSelector._select_fromNrr#r#r#r$r�&sr�c@s$eZdZdd�Zdd�Zdd�ZdS)r�cCst�|||�dSr,)r�r1rr#r#r$r1Gsz#_RecursiveWildcardSelector.__init__c cs�|Vz�||��}t|�}Wd�n1s.0Y|D]v}d}z |��}Wn.ty~}zt|�sj�WYd}~n d}~00|r<|��s<|�|j�} |�| ||�D] } | Vq�q)�formatrrLr/r#r#r$�__repr__�sz_PathParents.__repr__N) rLrMrNrO� __slots__r1rrrr#r#r#r$rqs rc@s�eZdZdZdZdd�Zdd�Zedd��Zed\d d ��Z ed]d d ��Z edd��Z dd�Z dd�Z dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zed d!��Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zeed0�d1d2�Zeed3�d4d2�Zed5d6��Z ed7d8��Z!ed9d:��Z"ed;d<��Z#ed=d>��Z$d?d@�Z%dAdB�Z&dCdD�Z'dEdF�Z(dGdH�Z)edIdJ��Z*dKdL�Z+dMdN�Z,dOdP�Z-edQdR��Z.edSdT��Z/dUdV�Z0dWdX�Z1dYdZ�Z2d[S)^ra|Base class for manipulating paths without I/O. PurePath represents a filesystem path and offers operations which don't imply any actual filesystem I/O. Depending on your system, instantiating a PurePath will return either a PurePosixPath or a PureWindowsPath object. You can also instantiate either of these classes directly, regardless of your system. )rrr�_str�_hash�_pparts�_cached_cpartscGs$|turtjdkrtnt}|�|�S)z�Construct a PurePath from one or several strings and or existing PurePath objects. The strings and path objects are combined so as to yield a canonicalized path, which is incorporated into the new PurePath object. r)rr|r�rr� _from_parts)r��argsr#r#r$�__new__�szPurePath.__new__cCs|jt|j�fSr,)� __class__�tuplerr/r#r#r$� __reduce__�szPurePath.__reduce__cCsdg}|D]N}t|t�r"||j7}qt�|�}t|t�rF|�t|��qtdt|���q|j � |�S)NzNargument should be a str object or an os.PathLike object returning str, not %r) � isinstancerrr|�fspathr{r9� TypeErrorr��_flavourrE)r�r%r=r�r#r#r$� _parse_args�s    ��zPurePath._parse_argsTcCs<t�|�}|�|�\}}}||_||_||_|r8|��|Sr,)�objectr&r.rrr�_init)r�r%�initr0r?r@r=r#r#r$r$�s zPurePath._from_partscCs,t�|�}||_||_||_|r(|��|Sr,)r/r&rrrr0)r�r?r@r=r1r0r#r#r$r�s zPurePath._from_parsed_partscCs4|s|r$|||j�|dd��S|j�|�SdSr�)r-r.)r�r?r@r=r#r#r$�_format_parsed_parts�szPurePath._format_parsed_partscCsdSr,r#r/r#r#r$r0�szPurePath._initcCs@|�|�\}}}|j�|j|j|j|||�\}}}|�|||�Sr,)r.r-rKrrrr)r0r%r?r@r=r#r#r$� _make_child�s � zPurePath._make_childcCs@z|jWSty:|�|j|j|j�p,d|_|jYS0dS)z[Return the string representation of the path, suitable for passing to system calls.r3N)r �AttributeErrorr2rrrr/r#r#r$�__str__�s  ��zPurePath.__str__cCst|�Sr,)r{r/r#r#r$� __fspath__�szPurePath.__fspath__cCs|j}t|��|jd�S)zNReturn the string representation of the path with forward (/) slashes.rR)r-r{r6r-�r0�fr#r#r$r��szPurePath.as_posixcCs t�|�S)zaReturn the bytes representation of the path. This is only recommended to use under Unix.)r|�fsencoder/r#r#r$� __bytes__�szPurePath.__bytes__cCsd�|jj|���S)Nz{}({!r}))rr'rLr�r/r#r#r$r�szPurePath.__repr__cCs|��std��|j�|�S)z Return the path as a 'file' URI.z.relative path can't be expressed as a file URI)r�r�r-r�r/r#r#r$�as_uriszPurePath.as_uricCs6z|jWSty0|j�|j�|_|jYS0dSr,)r#r4r-rqrr/r#r#r$�_cpartss  zPurePath._cpartscCs&t|t�stS|j|jko$|j|juSr,)r*r�NotImplementedr<r-�r0�otherr#r#r$�__eq__s zPurePath.__eq__cCs6z|jWSty0tt|j��|_|jYS0dSr,)r!r4�hashr(r<r/r#r#r$�__hash__s  zPurePath.__hash__cCs&t|t�r|j|jurtS|j|jkSr,�r*rr-r=r<r>r#r#r$�__lt__szPurePath.__lt__cCs&t|t�r|j|jurtS|j|jkSr,rCr>r#r#r$�__le__!szPurePath.__le__cCs&t|t�r|j|jurtS|j|jkSr,rCr>r#r#r$�__gt__&szPurePath.__gt__cCs&t|t�r|j|jurtS|j|jkSr,rCr>r#r#r$�__ge__+szPurePath.__ge__cCs|Sr,r#)r�r�r#r#r$�__class_getitem__0szPurePath.__class_getitem__rz.The drive prefix (letter or UNC path), if any.)�docrzThe root of the path, if any.cCs|j|j}|S)z/The concatenation of the drive and root, or ''.)rr)r0�anchorr#r#r$rJ9s zPurePath.anchorcCs.|j}t|�|js|jrdndkr&dS|dS)z!The final path component, if any.rFrr2r])rrarrrpr#r#r$r�?sz PurePath.namecCsD|j}|�d�}d|kr,t|�dkr.rFN)r�r�rcr8�r0r�r#r#r$�suffixesUs   zPurePath.suffixescCsD|j}|�d�}d|kr,t|�dkrr#r#r$�is_relative_to�s   zPurePath.is_relative_tocCs2z|jWSty,t|j�|_|jYS0dS)zZAn object providing sequence-like access to the components in the filesystem path.N)r"r4r(rr/r#r#r$r=�s   zPurePath.partscGs |�|�S)z�Combine this path with one or several arguments, and return a new path representing either a subpath (if all arguments are relative paths) or a totally different path (if one of the arguments is anchored). )r3)r0r%r#r#r$�joinpath�szPurePath.joinpathcCs*z|�|f�WSty$tYS0dSr,)r3r,r=�r0�keyr#r#r$� __truediv__�s zPurePath.__truediv__cCs0z|�|g|j�WSty*tYS0dSr,)r$rr,r=rcr#r#r$� __rtruediv__�s zPurePath.__rtruediv__cCs@|j}|j}|j}t|�dkr*|s&|r*|S|�|||dd��S)zThe logical parent of the path.rFNr])rrrrar)r0r?r@r=r#r#r$�parent�s zPurePath.parentcCst|�S)z*A sequence of this path's logical parents.)rr/r#r#r$�parents�szPurePath.parentscCs|js dS|jj pt|j�S)zSTrue if the path is absolute (has both a root and, if applicable, a drive).F)rr-r��boolrr/r#r#r$r��szPurePath.is_absolutecCs|j�|j�S)zaReturn True if the path contains one of the special names reserved by the system, if any.)r-r�rr/r#r#r$r��szPurePath.is_reservedc Cs�|jj}||�}|j�|f�\}}}|s0td��|rF|||j�krFdS|r\|||j�kr\dS|j}|sj|r�t|�t|�kr~dS|dd�}nt|�t|�kr�dStt |�t |��D]\}}t � ||�s�dSq�dS)zE Return True if this path matches the given pattern. z empty patternFrFNT) r-rGrEr�rrr<ra�zipr5rt� fnmatchcase) r0� path_patternr^r?r@� pat_partsr=rBr)r#r#r$r�s( zPurePath.matchN)T)T)3rLrMrNrOrr&r)� classmethodr.r$rr2r0r3r5r6r�r:rr;�propertyr<r@rBrDrErFrGrHrr�r@rJr�rOrQrRrTrUrWr`rar=rbrerfrgrhr�r�rr#r#r#r$r�s|       ��      !    rc@seZdZdZeZdZdS)rz�PurePath subclass for non-Windows systems. On a POSIX system, instantiating a PurePath should return this object. However, you can also instantiate it directly on any system. r#N)rLrMrNrO�_posix_flavourr-rr#r#r#r$rsrc@seZdZdZeZdZdS)rz�PurePath subclass for Windows systems. On a Windows system, instantiating a PurePath should return this object. However, you can also instantiate it directly on any system. r#N)rLrMrNrO�_windows_flavourr-rr#r#r#r$rsrc@s�eZdZdZdZdd�Zdddd�Zdd �Zd d �Zd d �Z dedd�Z dfdd�Z e dd��Z e dd��Zdd�Zdd�Zdd�Zdd�Zd d!�Zdgd#d$�Zd%d&�Zd'd(�Zd)d*�Zdhd-d.�Zd/d0�Zdid1d2�Zd3d4�Zdjd5d6�Zd7d8�Zdkd:d;�Zdldd?�Z d@dA�Z!dmdBdC�Z"dDdE�Z#dFdG�Z$dHdI�Z%dJdK�Z&dndLdM�Z'dNdO�Z(dPdQ�Z)dRdS�Z*dTdU�Z+dVdW�Z,dXdY�Z-dZd[�Z.d\d]�Z/d^d_�Z0d`da�Z1dbdc�Z2dS)ora�PurePath subclass that can make system calls. Path represents a filesystem path but unlike PurePath, also offers methods to do system calls on path objects. Depending on your system, instantiating a Path will return either a PosixPath or a WindowsPath object. You can also instantiate a PosixPath or WindowsPath directly, but cannot instantiate a WindowsPath on a POSIX system or vice versa. )r�cOsL|turtjdkrtnt}|j|dd�}|jjs@td|j f��|� �|S)NrF�r1z$cannot instantiate %r on your system) rr|r�rrr$r-r�r�rLr0)r�r%�kwargsr0r#r#r$r&7s�z Path.__new__NcCs|dur|j|_nt|_dSr,)r��_normal_accessor)r0�templater#r#r$r0As z Path._initcCs|j|g}|�|j|j|�Sr,)rrrr)r0rBr=r#r#r$rJs zPath._make_child_relpathcCs|Sr,r#r/r#r#r$� __enter__PszPath.__enter__cCsdSr,r#)r0�t�v�tbr#r#r$�__exit__Ss z Path.__exit__�cCs|j�|||�Sr,�r�r�)r0r��flagsr�r#r#r$�_opener^sz Path._opener��cCs|j�|||�S)zm Open the file pointed by this path and return a file descriptor, as os.open() does. r|)r0r}r�r#r#r$� _raw_openbszPath._raw_opencCs |t���S)zjReturn a new path pointing to the current working directory (as returned by os.getcwd()). )r|r}�r�r#r#r$�cwdkszPath.cwdcCs||�j�d��S)zrReturn a new path pointing to the user's home directory (as returned by os.path.expanduser('~')). N)r-r�r�r#r#r$�homersz Path.homecCsB|��}z |��}Wnty2|j�|�}Yn0tj�||�S)zoReturn whether other_path is the same or not as this file (as returned by os.path.samefile()). )r�r4r�r|r��samestat)r0� other_path�st�other_str#r#r$�samefileys   z Path.samefileccs,|j�|�D]}|dvrq |�|�Vq dS)zyIterate over the files in this directory. Does not yield any result for the special paths '.' and '..'. >r3r�N)r�r�rrPr#r#r$�iterdir�sz Path.iterdirccsnt�d||�|s td�|���|j�|f�\}}}|s<|rDtd��tt|�|j�}|� |�D] }|Vq^dS)z�Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern. zpathlib.Path.globzUnacceptable pattern: {!r}�%Non-relative patterns are unsupportedN) r:�auditr�rr-rEr�r�r(r�r0ryr?r@r��selectorrnr#r#r$�glob�sz Path.globccs`t�d||�|j�|f�\}}}|s*|r2td��tdt|�|j�}|�|�D] }|VqPdS)z�Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree. zpathlib.Path.rglobr�)r�N)r:r�r-rEr�r�r(rr�r#r#r$�rglob�sz Path.rglobcCs6|��r |S|jt��g|jdd�}|j|d�|S)aReturn an absolute version of this path. This function works even if the path doesn't point to anything. No normalization is done, i.e. all '.' and '..' will be kept along. Use resolve() to get the canonical path to a file. Frr�ru)r�r$r|r}rr0)r0�objr#r#r$�absolute�s  z Path.absoluteFcCsZ|jj||d�}|dur,|��t|���}|jj�|�}|j|fdd�}|j|d�|S)z� Make the path absolute, resolving all symlinks on the way and also normalizing it (for example turning slashes into backslashes under Windows). )r�NFrrr�) r-r�r�r{r�r��normpathr$r0)r0r�rm�normedr�r#r#r$r��s  z Path.resolvecCs |j�|�S)zh Return the result of the stat() system call on this path, like os.stat() does. )r�r�r/r#r#r$r��sz Path.statcCs |j�|�S)z: Return the login name of the file owner. )r�r�r/r#r#r$r��sz Path.ownercCs |j�|�S)z8 Return the group name of the file gid. )r�r�r/r#r#r$r��sz Path.group�rr]c Cstj|||||||jd�S)z| Open the file pointed by this path and return a file object, as the built-in open() function does. )�opener)�ior�r~)r0r�� buffering�encoding�errors�newliner#r#r$r��s�z Path.opencCs8|jdd��}|��Wd�S1s*0YdS)zK Open the file in bytes mode, read it, and close the file. �rb�r�N�r��readr7r#r#r$� read_bytes�szPath.read_bytescCs<|jd||d��}|��Wd�S1s.0YdS)zJ Open the file in text mode, read it, and close the file. r��r�r�r�Nr�)r0r�r�r8r#r#r$� read_text�szPath.read_textcCsBt|�}|jdd��}|�|�Wd�S1s40YdS)zO Open the file in bytes mode, write to it, and close the file. �wbr�N)� memoryviewr��write)r0�data�viewr8r#r#r$� write_bytes�szPath.write_bytescCsXt|t�std|jj��|jd||d��}|�|�Wd�S1sJ0YdS)zN Open the file in text mode, write to it, and close the file. zdata must be str, not %s�wr�N)r*r{r,r'rLr�r�)r0r�r�r�r8r#r#r$� write_text�s  �zPath.write_textcCs,|j�|�}|j|fdd�}|j|d�|S)zD Return the path to which the symbolic link points. Frrr�)r�r�r$r0)r0r�r�r#r#r$r�s  z Path.readlinkTcCsb|r.z|j�|d�Wnty(Yn0dStjtjB}|sH|tjO}|�||�}t�|�dS)zS Create this file with the given access mode, if it doesn't exist. N) r�r�r�r|�O_CREAT�O_WRONLY�O_EXCLr��close)r0r��exist_okr}�fdr#r#r$�touchs    z Path.touchcCsxz|j�||�Wn`tyT|r.|j|kr0�|jjddd�|j|d|d�Yn tyr|rl|��sn�Yn0dS)z< Create a new directory at this given path. T)rhr�FN)r�r�rrgr�r�)r0r�rhr�r#r#r$r�&s   z Path.mkdircCs|j�||�dS)zF Change the permissions of the path, like os.chmod(). N)r�r��r0r�r#r#r$r�7sz Path.chmodcCs|j�||�dS)z� Like chmod(), except if the path points to a symlink, the symlink's permissions are changed, rather than its target's. N)r�r�r�r#r#r$r�=sz Path.lchmodcCs.z|j�|�Wnty(|s$�Yn0dS)zd Remove this file or link. If the path is a directory, use rmdir() instead. N)r�r�r)r0� missing_okr#r#r$r�Ds  z Path.unlinkcCs|j�|�dS)zF Remove this directory. The directory must be empty. N)r�r�r/r#r#r$r�Osz Path.rmdircCs |j�|�S)z� Like stat(), except if the path points to a symlink, the symlink's status information is returned, rather than its target's. )r�r�r/r#r#r$r�Usz Path.lstatcCs|j�||�|�|�S)a2 Rename this path to the target path. The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, *not* the directory of the Path object. Returns the new Path instance pointing to the target path. )r�r�r'r�r#r#r$r�\s z Path.renamecCs|j�||�|�|�S)aS Rename this path to the target path, overwriting if that path exists. The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, *not* the directory of the Path object. Returns the new Path instance pointing to the target path. )r�r6r'r�r#r#r$r6is z Path.replacecCs|j�|||�dS)z� Make this path a symlink pointing to the target path. Note the order of arguments (link, target) is the reverse of os.symlink. N)r�r�)r0r�r�r#r#r$� symlink_tovszPath.symlink_tocCs|j�||�dS)aQ Make the target path a hard link pointing to this path. Note this function does not make this path a hard link to *target*, despite the implication of the function and argument names. The order of arguments (target, link) is the reverse of Path.symlink_to, but matches that of os.link. N)r�r�r�r#r#r$r�}s z Path.link_toc CsTz |��WnBty<}zt|�s&�WYd}~dSd}~0tyNYdS0dS)z+ Whether this path exists. NFT)r�r�r%r��r0r�r#r#r$r��s  z Path.existsc CsXzt|��j�WSty@}zt|�s*�WYd}~dSd}~0tyRYdS0dS)z3 Whether this path is a directory. NF)r r��st_moder�r%r�r�r#r#r$r��s z Path.is_dirc CsXzt|��j�WSty@}zt|�s*�WYd}~dSd}~0tyRYdS0dS)zq Whether this path is a regular file (also True for symlinks pointing to regular files). NF)r r�r�r�r%r�r�r#r#r$�is_file�s z Path.is_filecCsn|��r|��sdSz|j��j}Wnty8YdS0|��j}||krPdS|��j}|j��j}||kS)z; Check if this path is a POSIX mount point FT)r�r�rgr��st_devr��st_ino)r0� parent_dev�dev�ino� parent_inor#r#r$�is_mount�s    z Path.is_mountc CsXzt|��j�WSty@}zt|�s*�WYd}~dSd}~0tyRYdS0dS)z7 Whether this path is a symbolic link. NF)r r�r�r�r%r�r�r#r#r$r �s zPath.is_symlinkc CsXzt|��j�WSty@}zt|�s*�WYd}~dSd}~0tyRYdS0dS)z6 Whether this path is a block device. NF)r r�r�r�r%r�r�r#r#r$�is_block_device�s zPath.is_block_devicec CsXzt|��j�WSty@}zt|�s*�WYd}~dSd}~0tyRYdS0dS)z: Whether this path is a character device. NF)rr�r�r�r%r�r�r#r#r$�is_char_device�s zPath.is_char_devicec CsXzt|��j�WSty@}zt|�s*�WYd}~dSd}~0tyRYdS0dS)z. Whether this path is a FIFO. NF)rr�r�r�r%r�r�r#r#r$�is_fifo�s z Path.is_fifoc CsXzt|��j�WSty@}zt|�s*�WYd}~dSd}~0tyRYdS0dS)z0 Whether this path is a socket. NF)r r�r�r�r%r�r�r#r#r$� is_sockets zPath.is_socketcCs`|js\|js\|jr\|jddd�dkr\|j�|jddd��}|�|g|jdd��S|S)zl Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser) rNrF�~)rrrr-r�r$)r0�homedirr#r#r$� expandusers ��zPath.expanduser)N)r{)r)F)r�r]NNN)NN)NN)r{T)rFF)F)F)3rLrMrNrOrr&r0rrvrzr~r�rnr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r6r�r�r�r�r�r�r r�r�r�r�r�r#r#r#r$r*sh �         �        rc@seZdZdZdZdS)rzsPath subclass for non-Windows systems. On a POSIX system, instantiating a Path should return this object. r#N)rLrMrNrOrr#r#r#r$r*src@seZdZdZdZdd�ZdS)rzqPath subclass for Windows systems. On a Windows system, instantiating a Path should return this object. r#cCs td��dS)Nz-Path.is_mount() is unsupported on this systemr�r/r#r#r$r�8szWindowsPath.is_mountN)rLrMrNrOrr�r#r#r#r$r1sr)Art� functoolsr�r�r|r�rrr:�_collections_abcrrrrrrr�operatorrr�r r r r r rr� urllib.parserr�r�r�rZgetwindowsversionr�__all__r r!r%r*r/r+rPr�rqrpr�r�rtr�r�r�r�r�r�r�r�rr�PathLike�registerrrrrrr#r#r#r$�sr  $   ?0iF  ,