add-determinism 0.7.3

RPM buildroot helper to strip nondeterministic bits in files
Documentation
a

Z��^�c@sbddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZmZm
Z
mZmZddlmZddlmZmZmZmZmZmZmZddlmZdZejdkr�ddlZe� �dd	�d
kr�ddlm!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�Z<Gd0d1�d1e9�Z=Gd2d3�d3e9�Z>Gd4d5�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�)ir)�_getfinalpathnameF)�PurePath�
PurePosixPath�PureWindowsPath�Path�	PosixPath�WindowsPath)ii�cCs t|dd�tvpt|dd�tvS)N�errnoZwinerror)Zgetattr�_IGNORED_ERROS�_IGNORED_WINERRORS)Z	exception�r�/usr/lib64/python3.9/pathlib.py�
_ignore_error-s�rcCsd|vpd|vpd|vS)NZ*z?z[r)�patrrr�_is_wildcard_pattern2�r 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__<�z_Flavour.__init__cCsg}|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�sysZinternZreverse)r'�partsZparsedr$r,�drv�rootZit�partZrelZxrrr�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'r4r5r3Zdrv2Zroot2Zparts2rrr�join_parsed_partsesz_Flavour.join_parsed_partsN)�__name__�
__module__�__qualname__�__doc__r(r7r:rrrrr"8s&r"c@s�eZdZdZdZdZeZej	dkZ
ed�ZdZ
hd�dd	�ed
d�D�Bdd	�ed
d�D�BZefd
d�Zdd�Zdd�Zdd�Zd#dd�Ze
fdd�Zdd�Zdd�Zdd�Zd d!�Zd"S)$�_WindowsFlavour�\�/TrZ4abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZz\\?\>ZPRNZAUXZNULZCONcC�h|]}d|�qS)zCOM%dr��.0�irrr�	<setcomp>��z_WindowsFlavour.<setcomp>r8i
cCrB)zLPT%drrCrrrrF�rGcCs\|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)Nrr8rr*�������:)�_split_extended_pathZfind�len�
drive_letters�lstrip)r'r6r$ZfirstZsecond�prefixZthirdZindexZindex2r4r5rrrr/�s6"

z_WindowsFlavour.splitrootcCs|��Sr#�Zlower�r'�srrrr9�r)z_WindowsFlavour.casefoldcCsdd�|D�S)NcSsg|]}|���qSrrP)rD�prrr�
<listcomp>�rGz2_WindowsFlavour.casefold_parts.<locals>.<listcomp>r�r'r3rrr�casefold_parts�r)z_WindowsFlavour.casefold_partscCst�t�|�tj�jSr#)�re�compile�fnmatch�	translateZ
IGNORECASE�	fullmatch�r'�patternrrr�compile_pattern�r)z_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�pathr0r1r%r-)r'rd�strictrRZ
previous_sZ
tail_partsZtailrrr�resolve�s$
z_WindowsFlavour.resolvecCsXd}|�|�rP|dd�}|dd�}|�d�rP||dd�7}d|dd�}||fS)Nr*izUNC\rHr@)�
startswith)r'rRZ
ext_prefixrOrrrrK�s

z$_WindowsFlavour._split_extended_pathcCs|�|�dS�Nr8)rKrQrrrrb��z_WindowsFlavour._ext_to_normalcCs6|sdS|d�d�rdS|d�d�d��|jvS)NFrz\\rIr+)rgZ	partitionZupper�reserved_namesrUrrr�is_reserved�s
z_WindowsFlavour.is_reservedcCsd|j}t|�dkrJ|ddkrJ|��dd��d�}d|t|�d��fSdt|���d��SdS)Nrr8rJrAz
file:///%s/%szutf-8zfile:)�driverL�as_posixrN�urlquote_from_bytesZencode)r'rdrl�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)
NZUSERPROFILEZHOMEPATHZ	HOMEDRIVEr*zCan't determine home directoryZUSERNAMErI�%Can't determine home directory for %rr8)r`�environ�KeyError�RuntimeErrorr7r%)r'�usernameZuserhomer4r5r3rrr�
gethomedir�s*


�
z_WindowsFlavour.gethomedirN�F)r;r<r=r$r,�has_drv�ntpath�pathmodr`�name�is_supported�setrMZext_namespace_prefixZrangerjr/r9rVr^rfrKrbrkrprvrrrrr?ws.
���'

r?c@sleZdZdZdZdZeZej	dkZ
efdd�Zdd�Zd	d
�Z
dd�Zdd
d�Zdd�Zdd�Zdd�ZdS)�
_PosixFlavourrAr*FrcCsV|rH|d|krH|�|�}t|�t|�dkr<d|d|fSd||fSn
dd|fSdS)Nrrr*)rNrL)r'r6r$Z
stripped_partrrrr/$s
z_PosixFlavour.splitrootcC�|Sr#rrQrrrr93r)z_PosixFlavour.casefoldcCrr#rrUrrrrV6r)z_PosixFlavour.casefold_partscCst�t�|��jSr#)rWrXrYrZr[r\rrrr^9r)z_PosixFlavour.compile_patterncsJ|j�|j�i������fdd��|��r0dnt��}�|t|��pH�S)Ncs�|���rd}|���D]�}|r|dkr*q|dkrD|���\}}}q|�|}|�vrv�|}|durjqtd|��z��|�}Wn8ty�}z |jtkr��r��|}WYd}~qd}~00d�|<�||�}|�|<q|S)Nr*r+�..zSymlink loop from %r)rgr0Z
rpartitionrt�readlink�OSErrorrr)rdror{Z_Znewpath�target�e��_resolveZaccessorZseenr$rerrr�@s0


z'_PosixFlavour.resolve.<locals>._resolver*)r$�	_accessor�is_absoluter`rar_)r'rdreZbaserr�rrf<s&z_PosixFlavour.resolvecCsdS�NFrrUrrrrkir)z_PosixFlavour.is_reservedcCst|�}dt|�S)Nzfile://)Zbytesrn)r'rdZbpathrrrrplsz_PosixFlavour.make_uricCsx|s>ztjdWSty:ddl}|�t���jYS0n6ddl}z|�|�jWStyrtd|��Yn0dS)NZHOMErrq)	r`rrrs�pwd�getpwuidZgetuidZpw_dirZgetpwnamrt)r'rur�rrrrvrs�z_PosixFlavour.gethomedirNrw)r;r<r=r$r,rx�	posixpathrzr`r{r|r/r9rVr^rfrkrprvrrrrr~s

-r~c@seZdZdZdS)�	_AccessorzjAn accessor implements a particular (system-specific or not) way of
    accessing paths on the filesystem.N)r;r<r=r>rrrrr��sr�c@s�eZdZejZejZejZejZejZej	Z	e
ed�r>ejZndd�ZejZej
Z
e
ed�rdejZnedd��ZejZejZejZer�er�ejZq�dd�Zned	d��ZejZd
d�Zdd
�Zdd�ZdS)�_NormalAccessor�lchmodcC�td��dS)Nz%lchmod() not available on this system��NotImplementedError)r'Zpathobj�moderrrr��r)z_NormalAccessor.lchmod�linkcCr�)Nz&os.link() not available on this systemr��r'r�rrr�link_to�riz_NormalAccessor.link_tocCr�)Nz&symlink() not available on this systemr���aZb�target_is_directoryrrr�symlink�r)z_NormalAccessor.symlinkcCst�||�Sr#)r`r�r�rrrr��ricCs
t�|�Sr#)r`r��r'rdrrrr��r)z_NormalAccessor.readlinkcC�>zddl}|�|�|�j�jWSty8td��Yn0dS)Nrz*Path.owner() is unsupported on this system)r�r��statZst_uidZpw_name�ImportErrorr�)r'rdr�rrr�owner��
z_NormalAccessor.ownercCr�)Nrz*Path.group() is unsupported on this system)�grpZgetgrgidr�Zst_gidZgr_namer�r�)r'rdr�rrr�group�r�z_NormalAccessor.groupN)r;r<r=r`r��lstat�open�listdir�scandir�chmod�hasattrr��mkdir�unlinkr�r�Zstaticmethod�rmdir�renamer.r�supports_symlinksr��utimer�r�r�rrrrr��s8




r�cCsR|d}|dd�}|dkr"t}n$d|vr4td��nt|�rBt}nt}||||�S)Nrr8�**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�existsr�r�Ziter�_select_from)r'�parent_pathZpath_clsr�r�r�rrr�select_from�sz_Selector.select_fromN)r;r<r=r>r(r�rrrrr��s	r�c@seZdZdd�ZdS)r�ccs
|VdSr#r)r'r�r�r�r�rrrr�r)z!_TerminatingSelector._select_fromN)r;r<r=r�rrrrr�sr�c@�eZdZdd�Zdd�ZdS)r�cCs||_t�|||�dSr#)r{r�r()r'r{r�r�rrrr(
sz_PreciseSelector.__init__ccsZz@|�|j�}|jr|n||�r>|j�||||�D]
}|Vq2WntyTYdS0dSr#)�_make_child_relpathr{r�r�r��PermissionError)r'r�r�r�r�rdrSrrrr�sz_PreciseSelector._select_fromN�r;r<r=r(r�rrrrr��r�c@r�)r�cCs|�|�|_t�|||�dSr#)r^�matchr�r(�r'rr�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�r�rr{r�r�r�r�r�)r'r�r�r�r��
scandir_it�entries�entryr�r{rdrSrrrr�s&
&"

z_WildcardSelector._select_fromNr�rrrrr�r�r�c@s$eZdZdd�Zdd�Zdd�ZdS)r�cCst�|||�dSr#)r�r(r�rrrr(9r)z#_RecursiveWildcardSelector.__init__ccs�|Vz�||��}t|�}Wd�n1s.0Y|D]v}d}z|��}Wn.ty~}zt|�sj�WYd}~n
d}~00|r<|��s<|�|j�}	|�|	||�D]
}
|
Vq�q<Wnty�YdS0dSr�)	r�r�r�r�
is_symlinkr�r{�_iterate_directoriesr�)r'r�r�r�r�r�r�Zentry_is_dirr�rdrSrrrr�<s"
&z/_RecursiveWildcardSelector._iterate_directoriesc	cs�zjt�}zT|jj}|�|||�D]0}|||||�D]}||vr2|V|�|�q2q W|��n
|��0Wnty~YdS0dSr#)r}r�r�r�ZaddZclearr�)	r'r�r�r�r�ZyieldedZsuccessor_selectZstarting_pointrSrrrr�Osz'_RecursiveWildcardSelector._select_fromN)r;r<r=r(r�r�rrrrr�7sr�c@s4eZdZdZdZdd�Zdd�Zdd�Zd	d
�ZdS)�_PathParentszvThis object provides sequence-like access to the logical ancestors
    of a path.  Don't try to construct it yourself.)�_pathcls�_drv�_root�_partscCs&t|�|_|j|_|j|_|j|_dSr#)r�r�r�r�r�r�rrrr(hs
z_PathParents.__init__cCs(|js|jrt|j�dSt|j�SdSrh)r�r�rLr�r&rrr�__len__osz_PathParents.__len__cCs@|dks|t|�krt|��|j�|j|j|jd|d��S)Nrr8)rLZ
IndexErrorr��_from_parsed_partsr�r�r�)r'Zidxrrr�__getitem__us
�z_PathParents.__getitem__cCsd�|jj�S)Nz<{}.parents>)�formatr�r;r&rrr�__repr__{r)z_PathParents.__repr__N)	r;r<r=r>�	__slots__r(r�r�r�rrrrr�csr�c@s�eZdZdZdZdd�Zdd�Zedd��Zed\d
d��Z	ed]dd
��Z
edd��Zdd�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.
        r)rr`r{rr�_from_parts)r��argsrrr�__new__�szPurePath.__new__cCs|jt|j�fSr#)�	__class__�tupler�r&rrr�
__reduce__�r!zPurePath.__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`Zfspathr_r1�	TypeErrorr��_flavourr7)r�r�r3r�rrr�_parse_args�s


��zPurePath._parse_argsTcCs<t�|�}|�|�\}}}||_||_||_|r8|��|Sr#)�objectr�r�r�r�r��_init)r�r��initr'r4r5r3rrrr��s
zPurePath._from_partscCs,t�|�}||_||_||_|r(|��|Sr#)r�r�r�r�r�r�)r�r4r5r3r�r'rrrr��s
zPurePath._from_parsed_partscCs4|s|r$|||j�|dd��S|j�|�SdSrh)r�r%)r�r4r5r3rrr�_format_parsed_parts�szPurePath._format_parsed_partscC�dSr#rr&rrrr��rizPurePath._initcCs@|�|�\}}}|j�|j|j|j|||�\}}}|�|||�Sr#)r�r�r:r�r�r�r�)r'r�r4r5r3rrr�_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��AttributeErrorr�r�r�r�r&rrr�__str__�s��zPurePath.__str__cC�t|�Sr#)r_r&rrr�
__fspath__�r)zPurePath.__fspath__cCs|j}t|��|jd�S)zNReturn the string representation of the path with forward (/)
        slashes.rA)r�r_r.r$�r'�frrrrm�szPurePath.as_posixcCs
t�|�S)zaReturn the bytes representation of the path.  This is only
        recommended to use under Unix.)r`Zfsencoder&rrr�	__bytes__�r!zPurePath.__bytes__cCsd�|jj|���S)Nz{}({!r}))r�r�r;rmr&rrrr��r)zPurePath.__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�rpr&rrr�as_uri�szPurePath.as_uricCs6z|jWSty0|j�|j�|_|jYS0dSr#)r�r�r�rVr�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�Zhashr�r�r&rrr�__hash__s
zPurePath.__hash__cCs&t|t�r|j|jurtS|j|jkSr#�r�rr�r�r�r�rrr�__lt__�zPurePath.__lt__cCs&t|t�r|j|jurtS|j|jkSr#r�r�rrr�__le__rzPurePath.__le__cCs&t|t�r|j|jurtS|j|jkSr#r�r�rrr�__gt__rzPurePath.__gt__cCs&t|t�r|j|jurtS|j|jkSr#r�r�rrr�__ge__rzPurePath.__ge__cC�|Sr#r)r�r�rrr�__class_getitem__"r)zPurePath.__class_getitem__r�z.The drive prefix (letter or UNC path), if any.)Zdocr�zThe root of the path, if any.cCs|j|j}|S)z/The concatenation of the drive and root, or ''.)r�r�)r'�anchorrrrr+�zPurePath.anchorcCs.|j}t|�|js|jrdndkr&dS|dS)z!The final path component, if any.r8rr*rI)r�rLr�r�rUrrrr{1sz
PurePath.namecCsD|j}|�d�}d|kr,t|�dkr<nn||d�SdSdS)z{
        The final component's last suffix, if any.

        This includes the leading period. For example: '.txt'
        r+rr8Nr*�r{ZrfindrL�r'r{rErrr�suffix9s

 zPurePath.suffixcCs:|j}|�d�rgS|�d�}dd�|�d�dd�D�S)z�
        A list of the final component's suffixes, if any.

        These include the leading periods. For example: ['.tar', '.gz']
        r+cSsg|]}d|�qS)r+r)rDr
rrrrTRrGz%PurePath.suffixes.<locals>.<listcomp>r8N)r{ZendswithrNr0�r'r{rrr�suffixesGs


zPurePath.suffixescCsD|j}|�d�}d|kr,t|�dkr<nn|d|�S|SdS)z0The final path component, minus its last suffix.r+rr8Nrr	rrr�stemTs

 z
PurePath.stemcCs�|jstd|f��|j�|f�\}}}|rX|d|jj|jjfvsX|sX|sXt|�dkrdtd|��|�|j|j	|j
dd�|g�S)z-Return a new path with the file name changed.�%r has an empty namerIr8zInvalid name %rN)r{r�r�r7r$r,rLr�r�r�r�)r'r{r4r5r3rrr�	with_name^s��
��zPurePath.with_namecCs|�||j�S)z(Return a new path with the stem changed.)rr
)r'r
rrr�	with_stemirizPurePath.with_stemcCs�|j}|j|vs |jr.|j|vr.td|f��|r<|�d�rD|dkrPtd|��|j}|shtd|f��|j}|s|||}n|dt|��|}|�|j	|j
|jdd�|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+rNrI)r�r$r,r�rgr{r
rLr�r�r�r�)r'r
r�r{Z
old_suffixrrr�with_suffixms
�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 argumentr8NrzU{!r} is not in the subpath of {!r} OR one path is relative and the other is absolute.r*)
r�r�r�r�r�rLr�rVr�r�r�r_r�)
r'r�r3r4r5Z	abs_partsZto_drvZto_rootZto_partsZto_abs_partsZn�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)rr�r�rrr�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�r�r�r�r&rrrr3�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).
        )r�)r'r�rrr�joinpath�szPurePath.joinpathcCs*z|�|f�WSty$tYS0dSr#)r�r�r��r'Zkeyrrr�__truediv__�szPurePath.__truediv__cCs0z|�|g|j�WSty*tYS0dSr#)r�r�r�r�rrrr�__rtruediv__�szPurePath.__rtruediv__cCs@|j}|j}|j}t|�dkr*|s&|r*|S|�|||dd��S)zThe logical parent of the path.r8NrI)r�r�r�rLr�)r'r4r5r3rrr�parent�szPurePath.parentcCr�)z*A sequence of this path's logical parents.)r�r&rrr�parents�r!zPurePath.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�rxZboolr�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�rkr�r&rrrrk�r!zPurePath.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 patternFr8NT)r�r9r7r�r�r�r�rLZzipr-rYZfnmatchcase)	r'Zpath_patternrr4r5Z	pat_partsr3r6rrrrr��s(zPurePath.matchN�Tr)3r;r<r=r>r�r�r��classmethodr�r�r�r�r�r�r�r�rmr�r�r�Zpropertyr�r�r�r�rrrrrrlr5rr{r
rr
rrrrrr3rrrrrr�rkr�rrrrrs|

	


��





	!	

	
rc@�eZdZdZeZdZdS)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)r;r<r=r>�_posix_flavourr�r�rrrrr�rc@r)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)r;r<r=r>�_windows_flavourr�r�rrrrrrrc@s�eZdZdZdZdd�Zdddd�Zdd	�Zd
d�Zdd
�Z	dedd�Z
dfdd�Ze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;�Zdld<d=�Zd>d?�Z d@dA�Z!dmdBdC�Z"dDdE�Z#dFdG�Z$dHdI�Z%dJdK�Z&dLdM�Z'dndNdO�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�r�z$cannot instantiate %r on your system)rr`r{rrr�r�r|r�r;r�)r�r�Zkwargsr'rrrr�)s�zPath.__new__NcCs|dur|j|_nt|_dSr#)r��_normal_accessor)r'�templaterrrr�3s
z
Path._initcCs|j|g}|�|j|j|�Sr#)r�r�r�r�)r'r6r3rrrr�<rzPath._make_child_relpathcCrr#rr&rrr�	__enter__Br)zPath.__enter__cCr�r#r)r'ZtZvZtbrrr�__exit__Es	z
Path.__exit__�cCs|j�|||�Sr#�r�r�)r'r{�flagsr�rrr�_openerPrizPath._opener��cCs|j�|||�S)zm
        Open the file pointed by this path and return a file descriptor,
        as os.open() does.
        r')r'r(r�rrr�	_raw_openT�zPath._raw_opencCs|t���S)zjReturn a new path pointing to the current working directory
        (as returned by os.getcwd()).
        )r`ra�r�rrr�cwd]r,zPath.cwdcCs||�j�d��S)zrReturn a new path pointing to the user's home directory (as
        returned by os.path.expanduser('~')).
        N)r�rvr-rrr�homedr,z	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�r�r�r`rdZsamestat)r'Z
other_pathZstZother_strrr�samefileks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 '..'.
        >r+r�N)r�r�r�rrrr�iterdirvsz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)
r2�auditr�r�r�r7r�r�r�r��r'r]r4r5r�ZselectorrSrrr�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.rglobr2)r�N)r2r3r�r7r�r�r�r�r4rrr�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.
        Fr!�r#)r�r�r`rar�r�)r'�objrrr�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).
        )reNFr!r7)	r�rfr�r_r9rzZnormpathr�r�)r'rerRZnormedr8rrrrf�szPath.resolvecC�|j�|�S)zh
        Return the result of the stat() system call on this path, like
        os.stat() does.
        )r�r�r&rrrr��r,z	Path.statcCr:)z:
        Return the login name of the file owner.
        )r�r�r&rrrr���z
Path.ownercCr:)z8
        Return the group name of the file gid.
        )r�r�r&rrrr��r;z
Path.group�rrIc	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�r))r'r�Z	buffering�encoding�errorsZnewlinerrrr��s�z	Path.opencCs8|jdd��}|��Wd�S1s*0YdS)zK
        Open the file in bytes mode, read it, and close the file.
        Zrb�r�N�r�Zreadr�rrr�
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?NrA)r'r>r?r�rrr�	read_text�szPath.read_textcCsBt|�}|jdd��}|�|�Wd�S1s40YdS)zO
        Open the file in bytes mode, write to it, and close the file.
        Zwbr@N)Z
memoryviewr��write)r'�dataZviewr�rrr�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 %sZwrCN)r�r_r�r�r;r�rE)r'rFr>r?r�rrr�
write_text�s
�zPath.write_textcCs,|j�|�}|j|fdd�}|j|d�|S)zD
        Return the path to which the symbolic link points.
        Fr!r7)r�r�r�r�)r'rdr8rrrr��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`ZO_CREATZO_WRONLYZO_EXCLr+Zclose)r'r��exist_okr(Zfdrrr�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)rrIFN)r�r�rcrr�r�)r'r�rrIrrrr�sz
Path.mkdircC�|j�||�dS)zF
        Change the permissions of the path, like os.chmod().
        N)r�r��r'r�rrrr�)r;z
Path.chmodcCrK)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�rLrrrr�/r,zPath.lchmodcCs.z|j�|�Wnty(|s$�Yn0dS)zd
        Remove this file or link.
        If the path is a directory, use rmdir() instead.
        N)r�r�rc)r'Z
missing_okrrrr�6s
zPath.unlinkcCs|j�|�dS)zF
        Remove this directory.  The directory must be empty.
        N)r�r�r&rrrr�Ar;z
Path.rmdircCr:)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�Gr,z
Path.lstatcCrK)zE
        Create a hard link pointing to a path named target.
        N)r�r�r�rrrr�Nr;zPath.link_tocC�|j�||�|�|�S)zx
        Rename this path to the given path,
        and return a new Path instance pointing to the given path.
        )r�r�r�r�rrrr�TszPath.renamecCrM)z�
        Rename this path to the given path, clobbering the existing
        destination if it exists, and return a new Path instance
        pointing to the given path.
        )r�r.r�r�rrrr.\szPath.replacecCs|j�|||�dS)z�
        Make this path a symlink pointing to the given path.
        Note the order of arguments (self, target) is the reverse of os.symlink's.
        N)r�r�)r'r�r�rrr�
symlink_toer,zPath.symlink_toc
CsTz|��WnBty<}zt|�s&�WYd}~dSd}~0tyNYdS0dS)z+
        Whether this path exists.
        NFT)r�r�rr��r'r�rrrr�nszPath.existsc
C�Xzt|��j�WSty@}zt|�s*�WYd}~dSd}~0tyRYdS0dS)z3
        Whether this path is a directory.
        NF)rr��st_moder�rr�rOrrrr�}�zPath.is_dirc
CrP)zq
        Whether this path is a regular file (also True for symlinks pointing
        to regular files).
        NF)r
r�rQr�rr�rOrrr�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�rr�Zst_devr�Zst_ino)r'Z
parent_devZdevZinoZ
parent_inorrr�is_mount�s

z
Path.is_mountc
CrP)z7
        Whether this path is a symbolic link.
        NF)r	r�rQr�rr�rOrrrr��szPath.is_symlinkc
CrP)z6
        Whether this path is a block device.
        NF)rr�rQr�rr�rOrrr�is_block_device�rRzPath.is_block_devicec
CrP)z:
        Whether this path is a character device.
        NF)r
r�rQr�rr�rOrrr�is_char_device�rRzPath.is_char_devicec
CrP)z.
        Whether this path is a FIFO.
        NF)rr�rQr�rr�rOrrr�is_fifo�rRzPath.is_fifoc
CrP)z0
        Whether this path is a socket.
        NF)rr�rQr�rr�rOrrr�	is_socket�rRzPath.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)
        rNr8z~)r�r�r�r�rvr�)r'Zhomedirrrr�
expandusers��zPath.expanduserr#)r&)r*rw)r<rINNN�NNrZ)r&T)r*FFrwrw)3r;r<r=r>r�r�r�r�r$r%r)r+rr.r/r0r1r5r6r9rfr�r�r�r�rBrDrGrHr�rJr�r�r�r�r�r�r�r�r.rNr�r�rSrTr�rUrVrWrXrYrrrrrsh�
	

	




�
	
	

	


	
	rc@seZdZdZdZdS)rzsPath subclass for non-Windows systems.

    On a POSIX system, instantiating a Path should return this object.
    rN)r;r<r=r>r�rrrrr
src@seZdZdZdZdd�ZdS)rzqPath subclass for Windows systems.

    On a Windows system, instantiating a Path should return this object.
    rcCr�)Nz-Path.is_mount() is unsupported on this systemr�r&rrrrTr)zWindowsPath.is_mountN)r;r<r=r>r�rTrrrrrsr)ArYZ	functoolsr=ryr`r�rWr2Z_collections_abcrrrrrrrZoperatorrr�rr	r
rrr
rZurllib.parserrnr�r{rZgetwindowsversionrZ__all__rrrr r�r"r?r~r rr�r�r"r�r�r�r�r�r�r�r�r�rZPathLikeZregisterrrrrrrrrrZ<module>sp$

?&fF
,

t