a XC?h���@s2ddlZddlZddlZddlZddlZddlZddlZddlZddlm Z ddl m Z m Z m Z mZmZddlmZddlmZmZmZmZmZmZmZddlmZdZgd�Zd Zd Z d Z!e e eefZ"ee e!fZ#d d �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�Z/e0ed��rbe�1�e/�Z/Gdd�d�Z2Gdd �d �Z3Gd!d"�d"e2�Z4Gd#d$�d$e2�Z5Gd%d&�d&e2�Z6Gd'd(�d(e �Z7Gd)d*�d*e&�Z8ej9�:e8�Gd+d,�d,e8�Z;Gd-d.�d.e8�ZGd3d4�d4e=e<�Z?dS)5�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)�PurePath� PurePosixPath�PureWindowsPath�Path� PosixPath� WindowsPath��{i�cCs t|dd�tvpt|dd�tvS)N�errno�winerror)�getattr�_IGNORED_ERROS�_IGNORED_WINERRORS)Z exception�r�,/opt/alt/python39/lib64/python3.9/pathlib.py� _ignore_error(s�r cCsd|vpd|vpd|vS)N�*�?�[r)�patrrr�_is_wildcard_pattern-sr%c@s(eZdZdZdd�Zdd�Zdd�ZdS) �_FlavourzPA flavour implements a particular (platform-specific) set of path semantics.cCs|jj|_dS�N)�sep�join��selfrrr�__init__7sz_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) r+�partsZparsedr(r/�drv�root�it�partZrel�xrrr� 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)r+r9r:r8Zdrv2Zroot2Zparts2rrr�join_parsed_parts`sz_Flavour.join_parsed_partsN)�__name__� __module__� __qualname__�__doc__r,r>rArrrrr&3s&r&c@s�eZdZdZdZdZeZej dkZ e d�Z dZ hd�dd �d D�Bd d �d D�BZefd d �Zdd�Zdd�Zdd�Ze fdd�Zdd�Zdd�Zdd�ZdS)�_WindowsFlavour�\�/T�ntZ4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZz\\?\>ZNULzCONOUT$ZCONZPRNzCONIN$ZAUXcCsh|] }d|�qS)zCOM%sr��.0�crrr� ��z_WindowsFlavour.u123456789¹²³cCsh|] }d|�qS)zLPT%srrJrrrrM�rNc 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)Nrr?�r-�������:)�_split_extended_path�find�len� drive_letters�lstrip) r+r<r(�first�second�prefixZthird�indexZindex2r9r:rrrr2�s6      "    z_WindowsFlavour.splitrootcCs|��Sr'��lower�r+�srrrr@�sz_WindowsFlavour.casefoldcCsdd�|D�S)NcSsg|] }|���qSrr\)rK�prrr� �rNz2_WindowsFlavour.casefold_parts..r�r+r8rrr�casefold_parts�sz_WindowsFlavour.casefold_partscCst�t�|�tj�jSr')�re�compile�fnmatch� translate� IGNORECASE� fullmatch�r+�patternrrr�compile_pattern�sz_WindowsFlavour.compile_patterncCsXd}|�|�rP|dd�}|dd�}|�d�rP||dd�7}d|dd�}||fS)Nr-�zUNC\rPrG)� startswith)r+r_Z ext_prefixrZrrrrS�s    z$_WindowsFlavour._split_extended_pathcCsJ|sdS|d�d�rdS|d�d�d�d�d�d�}|��|jvS)NFrz\\rQr.rR� )rn� partition�rstrip�upper�reserved_names)r+r8�namerrr� is_reserved�s "z_WindowsFlavour.is_reservedcCsd|j}t|�dkrJ|ddkrJ|��dd��d�}d|t|�d��fSdt|���d��SdS)NrOr?rRrHz file:///%s/%szutf-8zfile:)�driverU�as_posixrW�urlquote_from_bytes�encode)r+�pathrv�restrrr�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) NZ USERPROFILEZHOMEPATHZ HOMEDRIVEr-zCan't determine home directoryZUSERNAMErQ�%Can't determine home directory for %rr?)�os�environ�KeyError� RuntimeErrorr>r))r+�username�userhomer9r:r8rrr� gethomedir�s*     � z_WindowsFlavour.gethomedirN)rBrCrDr(r/�has_drv�ntpath�pathmodr~rt� is_supported�setrVZext_namespace_prefixrsr2r@rcrlrSrur|r�rrrrrFrs*  � �� '   rFc@sbeZdZdZdZdZeZej dkZ efdd�Z dd�Z d d �Z d d �Zd d�Zdd�Zdd�ZdS)� _PosixFlavourrHr-FrIcCsV|rH|d|krH|�|�}t|�t|�dkrz tjdWSty:ddl}|�t���jYS0n6ddl}z|�|�jWStyrtd|��Yn0dS)N�HOMErr}) r~rr��pwd�getpwuid�getuid�pw_dir�getpwnamr�)r+r�r�rrrr�.s   �z_PosixFlavour.gethomedirN)rBrCrDr(r/r�� posixpathr�r~rtr�r2r@rcrlrur|r�rrrrr�s  r�c@seZdZdZdS)� _AccessorzjAn accessor implements a particular (system-specific or not) way of accessing paths on the filesystem.N)rBrCrDrErrrrr�Bsr�c@s�eZdZejZejZejZejZejZej Z e ed�r>ej Z ndd�Z ej Z ej Z e ed�rdejZn edd��ZejZejZejZe ed�r�ejZn dd d �ZejZd d �Zd d�Zdd�ZejZeejj�Zeejj�ZdS)�_NormalAccessor�lchmodcCs td��dS)Nz%lchmod() not available on this system��NotImplementedError)r+Zpathobj�moderrrr�Xsz_NormalAccessor.lchmod�linkcCs td��dS)Nz&os.link() not available on this systemr��r+�targetrrr�link_tobsz_NormalAccessor.link_to�symlinkFcCs td��dS)Nz)os.symlink() not available on this systemr�)r+�srcZdst�target_is_directoryrrrr�osz_NormalAccessor.symlinkcCs t�|�Sr')r~�readlink�r+rzrrrr�usz_NormalAccessor.readlinkcCs>zddl}|�|�|�j�jWSty8td��Yn0dS)Nrz*Path.owner() is unsupported on this system)r�r��stat�st_uidZpw_name� ImportErrorr�)r+rzr�rrr�ownerxs  z_NormalAccessor.ownercCs>zddl}|�|�|�j�jWSty8td��Yn0dS)Nrz*Path.group() is unsupported on this system)�grpZgetgrgidr��st_gidZgr_namer�r�)r+rzr�rrr�groups  z_NormalAccessor.groupN)F)rBrCrDr~r��lstat�open�listdir�scandir�chmod�hasattrr��mkdir�unlinkr�r�� staticmethod�rmdir�renamer1r��utimer�r�r��getcwdrz� expanduser�realpathrrrrr�Gs8      r�cCsR|d}|dd�}|dkr"t}n$d|vr4td��nt|�rBt}nt}||||�S)Nrr?�**z:Invalid pattern: '**' can only be an entire path component)�_RecursiveWildcardSelector� ValueErrorr%�_WildcardSelector�_PreciseSelector)� pattern_parts�flavourr$� child_parts�clsrrr�_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)r+r�r�rrrr,�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�exists� _accessorr��iter� _select_from)r+� parent_pathZpath_clsr�r�r�rrr� select_from�sz_Selector.select_fromN)rBrCrDrEr,r�rrrrr��s r�c@seZdZdd�ZdS)r�ccs |VdSr'r)r+r�r�r�r�rrrr��sz!_TerminatingSelector._select_fromN)rBrCrDr�rrrrr��sr�c@seZdZdd�Zdd�ZdS)r�cCs||_t�|||�dSr')rtr�r,)r+rtr�r�rrrr,�sz_PreciseSelector.__init__ccsZz@|�|j�}|jr|n||�r>|j�||||�D] }|Vq2WntyTYdS0dSr')�_make_child_relpathrtr�r�r��PermissionError)r+r�r�r�r�rzr`rrrr��s   z_PreciseSelector._select_fromN�rBrCrDr,r�rrrrr��sr�c@seZdZdd�Zdd�ZdS)r�cCs|�|�|_t�|||�dSr')rl�matchr�r,�r+r$r�r�rrrr,�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��OSErrorr rtr�r�r�r�r�) r+r�r�r�r�� scandir_it�entries�entry�ertrzr`rrrr��s& &"   z_WildcardSelector._select_fromNr�rrrrr��sr�c@s$eZdZdd�Zdd�Zdd�ZdS)r�cCst�|||�dSr')r�r,r�rrrr,�sz#_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)�formatr�rBr*rrr�__repr__7sz_PathParents.__repr__N) rBrCrDrE� __slots__r,r�r�r�rrrrr�s r�c@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. )r�r�r��_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. rI)rr~rtrr� _from_parts)r��argsrrr�__new__IszPurePath.__new__cCs|jt|j�fSr')� __class__�tupler�r*rrr� __reduce__SszPurePath.__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) � isinstancerr�r~�fspath�strr4� TypeErrorr��_flavourr>)r�r�r8�arrr� _parse_argsXs    ��zPurePath._parse_argsTcCs<t�|�}|�|�\}}}||_||_||_|r8|��|Sr')�objectr�r�r�r�r��_init)r�r��initr+r9r:r8rrrr�ls zPurePath._from_partscCs,t�|�}||_||_||_|r(|��|Sr')r�r�r�r�r�r�)r�r9r:r8rr+rrrr�ys zPurePath._from_parsed_partscCs4|s|r$|||j�|dd��S|j�|�SdSr�)r�r))r�r9r:r8rrr�_format_parsed_parts�szPurePath._format_parsed_partscCsdSr'rr*rrrr��szPurePath._initcCs@|�|�\}}}|j�|j|j|j|||�\}}}|�|||�Sr')r�r�rAr�r�r�r�)r+r�r9r:r8rrr� _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.r.N)r��AttributeErrorrr�r�r�r*rrr�__str__�s  ��zPurePath.__str__cCst|�Sr')r�r*rrr� __fspath__�szPurePath.__fspath__cCs|j}t|��|jd�S)zNReturn the string representation of the path with forward (/) slashes.rH)r�r�r1r(�r+�frrrrw�szPurePath.as_posixcCs t�|�S)zaReturn the bytes representation of the path. This is only recommended to use under Unix.)r~�fsencoder*rrr� __bytes__�szPurePath.__bytes__cCsd�|jj|���S)Nz{}({!r}))r�r�rBrwr*rrrr��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)� is_absoluter�r�r|r*rrr�as_uri�szPurePath.as_uricCs6z|jWSty0|j�|j�|_|jYS0dSr')r�rr�rcr�r*rrr�_cparts�s  zPurePath._cpartscCs&t|t�stS|j|jko$|j|juSr')r�r�NotImplementedr r��r+�otherrrr�__eq__�s zPurePath.__eq__cCs6z|jWSty0tt|j��|_|jYS0dSr')r�r�hashr�r r*rrr�__hash__�s  zPurePath.__hash__cCs&t|t�r|j|jurtS|j|jkSr'�r�rr�r r rrrr�__lt__�szPurePath.__lt__cCs&t|t�r|j|jurtS|j|jkSr'rrrrr�__le__�szPurePath.__le__cCs&t|t�r|j|jurtS|j|jkSr'rrrrr�__gt__�szPurePath.__gt__cCs&t|t�r|j|jurtS|j|jkSr'rrrrr�__ge__�szPurePath.__ge__cCs|Sr'r)r�r�rrr�__class_getitem__�szPurePath.__class_getitem__r�z.The drive prefix (letter or UNC path), if any.)�docr�zThe root of the path, if any.cCs|j|j}|S)z/The concatenation of the drive and root, or ''.)r�r�)r+�anchorrrrr�s zPurePath.anchorcCs.|j}t|�|js|jrdndkr&dS|dS)z!The final path component, if any.r?rr-rQ)r�rUr�r�rbrrrrt�sz PurePath.namecCsD|j}|�d�}d|kr,t|�dkr.r?N)rt�endswithrWr3�r+rtrrr�suffixess   zPurePath.suffixescCsD|j}|�d�}d|kr,t|�dkrr(r/rUr�r�r�r�)r+rtr9r:r8rrr� with_names�� �  �zPurePath.with_namecCs|�||j�S)z(Return a new path with the stem changed.)r%r)r+r#rrr� with_stem%szPurePath.with_stemcCs�|j}|j|vs |jr.|j|vr.td|f��|r<|�d�rD|dkrPtd|��|j}|shtd|f��|j}|s|||}n|dt|� �|}|�|j |j |j dd�|g�S)z�Return a new path with the file suffix changed. If the path has no suffix, add given suffix. If the given suffix is an empty string, remove the suffix from the path. zInvalid suffix %rr.r$NrQ) r�r(r/r�rnrtrrUr�r�r�r�)r+rrrtZ old_suffixrrr� with_suffix)s   �zPurePath.with_suffixc Gs�|s td��|j}|j}|j}|r8||g|dd�}n|}|�|�\}}}|rf||g|dd�} n|} t| �} |jj} | dkr�|s�|r�n| |d| ��| | �kr�|�|||�} t d� t |�t | ����|� d| dkr�|nd|| d��S)z�Return the relative path to another path identified by the passed arguments. If the operation is not possible (because this is not a subpath of the other path), raise ValueError. zneed at least one argumentr?NrzU{!r} is not in the subpath of {!r} OR one path is relative and the other is absolute.r-) r�r�r�r�r�rUr�rcrr�r�r�r�) r+rr8r9r:Z abs_partsZto_drvZto_rootZto_partsZ to_abs_parts�n�cfZ formattedrrr� relative_to>s, * � �zPurePath.relative_tocGs*z|j|�WdSty$YdS0dS)zFReturn True if the path is relative to another path or False. TFN)r*r�rrrr�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�rr�r�r*rrrr8hs   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). )r)r+r�rrr�joinpathtszPurePath.joinpathcCs*z|�|f�WSty$tYS0dSr')rr�r �r+�keyrrr� __truediv__|s zPurePath.__truediv__cCs0z|�|g|j�WSty*tYS0dSr')r�r�r�r r-rrr� __rtruediv__�s zPurePath.__rtruediv__cCs@|j}|j}|j}t|�dkr*|s&|r*|S|�|||dd��S)zThe logical parent of the path.r?NrQ)r�r�r�rUr�)r+r9r:r8rrr�parent�s zPurePath.parentcCst|�S)z*A sequence of this path's logical parents.)r�r*rrr�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)r�r�r��boolr�r*rrrr �szPurePath.is_absolutecCs|j�|j�S)zaReturn True if the path contains one of the special names reserved by the system, if any.)r�rur�r*rrrru�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 patternFr?NT) r�r@r>r�r�r�r rU�zipr0rfZ fnmatchcase) r+Z path_patternr)r9r:Z pat_partsr8r<r$rrrr��s( zPurePath.matchN)T)T)3rBrCrDrEr�r�r�� classmethodr�r�r�rr�rrrrwr r�r �propertyr rrrrrrrrrvr:rrtrr"r#r%r&r'r*r+r8r,r/r0r1r2r rur�rrrrr;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. rN)rBrCrDrE�_posix_flavourr�r�rrrrr�src@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. rN)rBrCrDrE�_windows_flavourr�r�rrrrr�src@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)NrIF�rz$cannot instantiate %r on your system) rr~rtrrr�r�r�r�rBr�)r�r��kwargsr+rrrr��s�z Path.__new__NcCs|dur|j|_nt|_dSr')r��_normal_accessor)r+�templaterrrr��s z Path._initcCs|j|g}|�|j|j|�Sr')r�r�r�r�)r+r<r8rrrr��s zPath._make_child_relpathcCs|Sr'rr*rrr� __enter__�szPath.__enter__cCsdSr'r)r+�t�v�tbrrr�__exit__s z Path.__exit__�cCs|j�|||�Sr'�r�r�)r+rt�flagsr�rrr�_opener sz Path._opener��cCs|j�|||�S)zm Open the file pointed by this path and return a file descriptor, as os.open() does. rC)r+rDr�rrr� _raw_openszPath._raw_opencCs |t���S)zjReturn a new path pointing to the current working directory (as returned by os.getcwd()). )r~r��r�rrr�cwdszPath.cwdcCs||�j�d��S)zrReturn a new path pointing to the user's home directory (as returned by os.path.expanduser('~')). N)r�r�rHrrr�home sz 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�rr�r~rz�samestat)r+Z other_path�stZother_strrr�samefile's   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 '..'. >z..r.N)r�r�r�r!rrr�iterdir2sz 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) r5�auditr�r�r�r>r�r�r�r��r+rkr9r:r�Zselectorr`rrr�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.rglobrO)r�N)r5rPr�r>r�r�r�r�rQrrr�rglobJsz 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. Fr9�r<)r r�r~r�r�r�)r+�objrrr�absoluteWs  z Path.absoluteFc Cs�dd�}z|jj||d�}Wn.tyJ}z||��WYd}~n d}~00|�|f�}|s�z |��Wn,ty�}z||�WYd}~n d}~00|S)z� Make the path absolute, resolving all symlinks on the way and also normalizing it (for example turning slashes into backslashes under Windows). cSs0t|dd�}|jtks|tkr,td|j��dS)NrrzSymlink loop from %r)rrr�_WINERROR_CANT_RESOLVE_FILENAMEr��filename)r�rrrr� check_eloopns z!Path.resolve..check_eloop)�strictN)r�r�r�r�r�)r+rZrYr_r�r`rrr�resolvegs  z Path.resolvecCs |j�|�S)zh Return the result of the stat() system call on this path, like os.stat() does. )r�r�r*rrrr��sz Path.statcCs |j�|�S)z: Return the login name of the file owner. )r�r�r*rrrr��sz Path.ownercCs |j�|�S)z8 Return the group name of the file gid. )r�r�r*rrrr��sz Path.group�rrQc Cstj|||||||jd�S)z| Open the file pointed by this path and return a file object, as the built-in open() function does. )Zopener)�ior�rE)r+r�� buffering�encoding�errors�newlinerrrr��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��readrrrr� 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`Nrd)r+r_r`rrrr� read_text�szPath.read_textcCsBt|�}|jdd��}|�|�Wd�S1s40YdS)zO Open the file in bytes mode, write to it, and close the file. �wbrcN)� memoryviewr��write)r+�dataZviewrrrr� 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�wrgN)r�r�r�r�rBr�rk)r+rlr_r`rrrr� write_text�s  �zPath.write_textcCs,|j�|�}|j|fdd�}|j|d�|S)zD Return the path to which the symbolic link points. Fr9rT)r�r�r�r�)r+rzrUrrrr��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_EXCLrG�close)r+r��exist_okrD�fdrrr�touch�s    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)r2rtFN)r�r��FileNotFoundErrorr1r�r�)r+r�r2rtrrrr��s   z Path.mkdircCs|j�||�dS)zF Change the permissions of the path, like os.chmod(). N)r�r��r+r�rrrr��sz 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�rxrrrr��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�rw)r+Z missing_okrrrr��s  z Path.unlinkcCs|j�|�dS)zF Remove this directory. The directory must be empty. N)r�r�r*rrrr�sz 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*rrrr� sz 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�rrrr�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�r1r�r�rrrr1!s 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�)r+r�r�rrr� symlink_to.szPath.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�rrrr�5s z Path.link_toc CsTz |��WnBty<}zt|�s&�WYd}~dSd}~0tyNYdS0dS)z+ Whether this path exists. NFT)r�r�r r��r+r�rrrr�Cs  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�rzrrrr�Rs 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�rzrrr�is_filebs 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�r1r��st_devr��st_ino)r+Z parent_devZdevZinoZ parent_inorrr�is_mountss    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�rzrrrr��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�rzrrr�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�rzrrr�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�rzrrr�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�rzrrr� is_socket�s 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) rNr?�~)r�r�r�r�r�r�)r+Zhomedirrrrr��s ��zPath.expanduser)N)rB)rF)F)r\rQNNN)NN)NN)rBT)rFFF)F)F)3rBrCrDrEr�r�r�r�r=rArErGr5rIrJrMrNrRrSrVr[r�r�r�r�rfrhrmror�rvr�r�r�r�r�r�r�r1ryr�r�r�r|rr�r�r�r�r�r�rrrrr�sh �         �        rc@seZdZdZdZdS)rzsPath subclass for non-Windows systems. On a POSIX system, instantiating a Path should return this object. rN)rBrCrDrEr�rrrrr�src@seZdZdZdZdd�ZdS)rzqPath subclass for Windows systems. On a Windows system, instantiating a Path should return this object. rcCs td��dS)Nz-Path.is_mount() is unsupported on this systemr�r*rrrr�szWindowsPath.is_mountN)rBrCrDrEr�rrrrrr�sr)@rf� functoolsr]r�r~r�rdr5�_collections_abcrrrrrrr�operatorrr�r r r r r rrZ urllib.parserrxZsupports_symlinks�__all__Z_WINERROR_NOT_READYZ_WINERROR_INVALID_NAMErWrrr r%r�r&rFr�r8r7r�r�r;r�r�r�r�r�r�r�r�r�r�PathLike�registerrrrrrrrrr�sp  $   �?9F  ,