AlkantarClanX12

Your IP : 18.224.70.11


Current Path : /opt/alt/python34/lib64/python3.4/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/__pycache__/pathlib.cpython-34.pyo

�
h f��@sSddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
mZmZddlmZddlmZmZmZmZmZmZmZddlmZdZejd	krUddlZej �dd
�ddfkrFddlm!Z!nd
ZdZ!ndZddddddgZ"dd�Z#Gdd�de$�Z%Gdd�de%�Z&Gdd�de%�Z'e&�Z(e'�Z)Gdd�d�Z*Gdd�de*�Z+e+�Z,ed d!��Z-d"d#�Z.e/ed$�rGej0�e.�Z.nGd%d&�d&�Z1Gd'd(�d(�Z2Gd)d*�d*e1�Z3Gd+d,�d,e1�Z4Gd-d.�d.e1�Z5Gd/d0�d0e	�Z6Gd1d�de$�Z7Gd2d�de7�Z8Gd3d�de7�Z9Gd4d�de7�Z:Gd5d�de:e8�Z;Gd6d�de:e9�Z<dS)7�N)�Sequence)�contextmanager)�EINVAL�ENOENT�ENOTDIR)�
attrgetter)�S_ISDIR�S_ISLNK�S_ISREG�S_ISSOCK�S_ISBLK�S_ISCHR�S_ISFIFO)�quote_from_bytesT�nt��)�_getfinalpathnameF�PurePath�
PurePosixPath�PureWindowsPath�Path�	PosixPath�WindowsPathcCs"d|kp!d|kp!d|kS)N�*�?�[�)�patrr�,/opt/alt/python34/lib64/python3.4/pathlib.py�_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__0sz_Flavour.__init__cCs�g}|j}|j}d}}t|�}x@|D]8}|sGq5n|rb|j||�}n|j|�\}}}	||	kr�xvt|	j|��D]1}
|
r�|
dkr�|jtj|
��q�q�Wn+|	r�|	dkr�|jtj|	��n|s|r5|sixU|D]J}|s*qn|rE|j||�}n|j|�d}|rPqqWnPq5q5W|s}|r�|j||�n|j	�|||fS)N��.r)
r"�altsep�reversed�replace�	splitroot�split�append�sys�intern�reverse)r$�partsZparsedr"r(�drv�root�it�partZrel�xrrr�parse_parts3s@		

 

z_Flavour.parse_partscCs�|r8|r�|r�||||g|dd�fSn_|r�||ksh|j|�|j|�kr�||||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$r2r3r1Zdrv2Zroot2Zparts2rrr�join_parsed_partsYs
%*z_Flavour.join_parsed_partsN)�__name__�
__module__�__qualname__�__doc__r%r7r:rrrrr!,s&r!c@sKeZdZdZdZdZeZej	dkZ
edd�ee
d�e
d�d	�D��ed
d�ee
d�e
d�d	�D��BZd
Zddddhdd�ed	d�D�Bdd�ed	d�D�BZedd�Zdd�Zdd�Zdd�Zedd�Zd d!�Zd"d#�Zd$d%�Zd&S)'�_WindowsFlavour�\�/Trccs|]}t|�VqdS)N)�chr)�.0r6rrr�	<genexpr>wsz_WindowsFlavour.<genexpr>�a�zr8ccs|]}t|�VqdS)N)rB)rCr6rrrrDxs�A�Zz\\?\ZCONZPRNZAUXZNULcCsh|]}d|�qS)zCOM%dr)rC�irrr�	<setcomp>~s	z_WindowsFlavour.<setcomp>�
cCsh|]}d|�qS)zLPT%dr)rCrIrrrrJs	cCs�|dd�}|dd�}||krp||krp|j|�\}}|dd�}|dd�}nd}|dd�}||krf||krf||krf|j|d�}|dkrf|j||d�}||dkrc|dkr	t|�}n|r8||d|�|||dd�fS|d|�|||dd�fSqcqfnd}	}
|dkr�||jkr�|dd�}	|dd�}|}n||kr�|}
|j|�}n||	|
|fS)	Nrr8rr&��:���rN)�_split_extended_path�find�len�
drive_letters�lstrip)r$r5r"�first�second�prefixZthird�indexZindex2r2r3rrrr+�s6$).
	z_WindowsFlavour.splitrootcCs
|j�S)N)�lower)r$�srrrr9�sz_WindowsFlavour.casefoldcCsdd�|D�S)NcSsg|]}|j��qSr)rX)rC�prrr�
<listcomp>�s	z2_WindowsFlavour.casefold_parts.<locals>.<listcomp>r)r$r1rrr�casefold_parts�sz_WindowsFlavour.casefold_partscCs?t|�}|stj�Stdk	r;|jt|��SdS)N)�str�os�getcwdr�_ext_to_normal)r$�pathrYrrr�resolve�s
z_WindowsFlavour.resolvecCs|d}|j|�rr|dd�}|dd�}|jd�rr||dd�7}d|dd�}qrn||fS)Nr&�zUNC\rLr@)�
startswith)r$rYZ
ext_prefixrVrrrrO�sz$_WindowsFlavour._split_extended_pathcCs|j|�dS)Nr8)rO)r$rYrrrr`�sz_WindowsFlavour._ext_to_normalcCsE|s
dS|djd�r!dS|djd�dj�|jkS)NFrz\\r8r'rN)rd�	partition�upper�reserved_names)r$r1rrr�is_reserved�s
z_WindowsFlavour.is_reservedcCs�|j}t|�dkrg|ddkrg|j�dd�jd�}d|t|jd��fSdt|j�jd��SdS)Nrr8rMrAz
file:///%s/%szutf-8zfile:)�driverQ�as_posixrS�urlquote_from_bytes�encode)r$rari�restrrr�make_uri�s	"z_WindowsFlavour.make_uriN)r;r<r=r"r(�has_drv�ntpath�pathmodr^�name�is_supported�set�range�ordrRZext_namespace_prefixrgr+r9r\rbrOr`rhrnrrrrr?ks$/3)	'	
r?c@s�eZdZdZdZdZeZej	dkZ
edd�Zdd�Zd	d
�Z
dd�Zd
d�Zdd�ZdS)�
_PosixFlavourrAr&FrcCss|rb|d|krb|j|�}t|�t|�dkrRd|d|fSd||fSn
dd|fSdS)Nrrr&)rSrQ)r$r5r"Z
stripped_partrrrr+�sz_PosixFlavour.splitrootcCs|S)Nr)r$rYrrrr9�sz_PosixFlavour.casefoldcCs|S)Nr)r$r1rrrr\�sz_PosixFlavour.casefold_partscsj|j�|j�i�����fdd��|j�rEdn	tj�}�|t|��pi�S)Ncs;|j��rd}nx|j��D]}|s(|dkrGq(n|dkrq|j��\}}}q(n|�|}|�kr��|}|dk	r�q(ntd|��ny�j|�}Wn@tk
r}z |jtkr��n|}WYdd}~Xq(Xd�|<�||�}|�|<q(W|S)Nr&r'z..zSymlink loop from %r)rdr,�
rpartition�RuntimeError�readlink�OSError�errnor)rarmrr�_�newpath�target�e)�_resolve�accessor�seenr"rrr�s0	

z'_PosixFlavour.resolve.<locals>._resolver&)r"�	_accessor�is_absoluter^r_r])r$ra�baser)r�r�r�r"rrbs		%z_PosixFlavour.resolvecCsdS)NFr)r$r1rrrrh.sz_PosixFlavour.is_reservedcCst|�}dt|�S)Nzfile://)�bytesrk)r$raZbpathrrrrn1sz_PosixFlavour.make_uriN)r;r<r=r"r(ro�	posixpathrqr^rrrsr+r9r\rbrhrnrrrrrw�s,rwc@seZdZdZdS)�	_AccessorzjAn accessor implements a particular (system-specific or not) way of
    accessing paths on the filesystem.N)r;r<r=r>rrrrr�<sr�c@sEeZdZdd�Zdd�Zeej�Zeej�Zeej�Zeej	�Z	eej
�Z
eed�r�eej�Zndd�Zeej
�Z
eej�Zeej�Zeej�Zeej�Zerereej�Zq&dd	�Zned
d	��Zeej�Zdd�Zd
S)�_NormalAccessorcs+tj���fdd��}t|�S)Ncs�t|�|�S)N)r])�pathobj�args)�strfuncrr�wrappedDsz._NormalAccessor._wrap_strfunc.<locals>.wrapped)�	functools�wraps�staticmethod)r�r�r)r�r�
_wrap_strfuncCs!z_NormalAccessor._wrap_strfunccs+tj���fdd��}t|�S)Ncs�t|�t|�|�S)N)r])ZpathobjAZpathobjBr�)r�rrr�Jsz5_NormalAccessor._wrap_binary_strfunc.<locals>.wrapped)r�r�r�)r�r�r)r�r�_wrap_binary_strfuncIs!z$_NormalAccessor._wrap_binary_strfunc�lchmodcCstd��dS)Nz%lchmod() not available on this system)�NotImplementedError)r$r��moderrrr�\sz_NormalAccessor.lchmodcCstd��dS)Nz&symlink() not available on this system)r�)rE�b�target_is_directoryrrr�symlinkmsz_NormalAccessor.symlinkcCstjt|�t|��S)N)r^r�r])rEr�r�rrrr�qscCs
tj|�S)N)r^rz)r$rarrrrzxsz_NormalAccessor.readlinkN)r;r<r=r�r�r^�stat�lstat�open�listdir�chmod�hasattrr��mkdir�unlink�rmdir�renamer*r�supports_symlinksr�r��utimerzrrrrr�As,r�c#sdy�j�VWnMtk
r_i���fdd�}d|_z	|VWd�j�XYnXdS)Ncs=y�|SWn*tk
r8�|�}�|<|SYnXdS)N)�KeyError)r��value)�cache�funcrr�wrapper�s

z_cached.<locals>.wrapperT)�
__cached__�AttributeError�clear)r�r�r)r�r�r�_cached�s	
		r�cCsr|d}|dd�}|dkr/t}n6d|krJtd��nt|�r_t}nt}|||�S)Nrr8z**z:Invalid pattern: '**' can only be an entire path component)�_RecursiveWildcardSelector�
ValueErrorr �_WildcardSelector�_PreciseSelector)�
pattern_partsr�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.cCs1||_|r!t|�|_nt�|_dS)N)r�r��	successor�_TerminatingSelector)r$r�rrrr%�s	z_Selector.__init__cCs@t|�}|j}|j}|jj}|j||||�S)zuIterate over all child paths of `parent_path` matched by this
        selector.  This can contain parent_path itself.)�type�is_dir�existsr�r��_select_from)r$�parent_pathZpath_clsr�r�r�rrr�select_from�s
		z_Selector.select_fromN)r;r<r=r>r%r�rrrrr��sr�c@seZdZdd�ZdS)r�ccs	|VdS)Nr)r$r�r�r�r�rrrr��sz!_TerminatingSelector._select_fromN)r;r<r=r�rrrrr��sr�c@s(eZdZdd�Zdd�ZdS)r�cCs||_tj||�dS)N)rrr�r%)r$rrr�rrrr%�s	z_PreciseSelector.__init__ccs}y`||�sdS|j|j�}||�r_x+|jj||||�D]}|VqMWnWntk
rxdSYnXdS)N)�_make_child_relpathrrr�r��PermissionError)r$r�r�r�r�rarZrrrr��s"
z_PreciseSelector._select_fromN)r;r<r=r%r�rrrrr��sr�c@s(eZdZdd�Zdd�ZdS)r�cCs/tjtj|��|_tj||�dS)N)�re�compile�fnmatch�	translaterr�r%)r$rr�rrrr%�sz_WildcardSelector.__init__c
cs�y�||�sdS|jj}xo||�D]a}||�}|jj|�r,|j|�}x+|jj||||�D]}	|	Vq{Wq,q,WWntk
r�dSYnXdS)N)�_flavourr9r�matchr�r�r�r�)
r$r�r�r�r��cfrrZ
casefoldedrarZrrrr��s"
z_WildcardSelector._select_fromN)r;r<r=r%r�rrrrr��sr�c@s4eZdZdd�Zdd�Zdd�ZdS)r�cCstj||�dS)N)r�r%)r$rr�rrrr%�sz#_RecursiveWildcardSelector.__init__ccs�|Vykxd||�D]V}|j|�}||�r|j�rx%|j|||�D]}|VqYWqqWWntk
r�dSYnXdS)N)r��
is_symlink�_iterate_directoriesr�)r$r�r�r�rrrarZrrrr��s
z/_RecursiveWildcardSelector._iterate_directoriesc	cs�y�||�sdSt|���}t�}zq|jj}x^|j|||�D]G}x>|||||�D]'}||krl|V|j|�qlqlWqPWWd|j�XWdQXWntk
r�dSYnXdS)N)r�rtr�r�r��addr�r�)	r$r�r�r�r�ZyieldedZsuccessor_selectZstarting_pointrZrrrr��s	
z'_RecursiveWildcardSelector._select_fromN)r;r<r=r%r�r�rrrrr��sr�c@sLeZdZdZdZdd�Zdd	�Zd
d�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�_partscCs7t|�|_|j|_|j|_|j|_dS)N)r�r�r�r�r�)r$rarrrr%sz_PathParents.__init__cCs4|js|jr#t|j�dSt|j�SdS)Nr8)r�r�rQr�)r$rrr�__len__sz_PathParents.__len__cCs[|dks|t|�kr-t|��n|jj|j|j|jd|d��S)Nrr8)rQ�
IndexErrorr��_from_parsed_partsr�r�r�)r$�idxrrr�__getitem__#sz_PathParents.__getitem__cCsdj|jj�S)Nz<{}.parents>)�formatr�r;)r$rrr�__repr__)sz_PathParents.__repr__N)z_pathclsz_drvz_rootz_parts)	r;r<r=r>�	__slots__r%r�r�r�rrrrr�sr�c@s\eZdZdZdXZd	d
�Zdd�Zed
d��Zeddd��Z	eddd��Z
edd��Zdd�Zdd�Z
dd�Zdd�Zdd�Zd d!�Zd"d#�Zed$d%��Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zeed�d2d3�Zeed�d2d4�Zed5d6��Zed7d8��Zed9d:��Z ed;d<��Z!ed=d>��Z"d?d@�Z#dAdB�Z$dCdD�Z%edEdF��Z&dGdH�Z'dIdJ�Z(dKdL�Z)edMdN��Z*edOdP��Z+dQdR�Z,dSdT�Z-dUdV�Z.dWS)YraHPurePath 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_cpartscGs7|tkr*tjdkr!tnt}n|j|�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^rrrr�_from_parts)r�r�rrr�__new__9szPurePath.__new__cCs|jt|j�fS)N)�	__class__�tupler�)r$rrr�
__reduce__CszPurePath.__reduce__cCs�g}xh|D]`}t|t�r2||j7}q
t|t�rW|jt|��q
tdt|���q
W|jj|�S)Nz/argument should be a path or str object, not %r)	�
isinstancerr�r]r-�	TypeErrorr�r�r7)r�r�r1rErrr�_parse_argsHs
zPurePath._parse_argsTcCsYtj|�}|j|�\}}}||_||_||_|rU|j�n|S)N)�objectr�r�r�r�r��_init)r�r��initr$r2r3r1rrrr�Ys			
zPurePath._from_partscCsAtj|�}||_||_||_|r=|j�n|S)N)r�r�r�r�r�r�)r�r2r3r1r�r$rrrr�fs			
zPurePath._from_parsed_partscCsB|s|r.|||jj|dd��S|jj|�SdS)Nr8)r�r#)r�r2r3r1rrr�_format_parsed_partsps"zPurePath._format_parsed_partscCsdS)Nr)r$rrrr�wszPurePath._initcCs^|j|�\}}}|jj|j|j|j|||�\}}}|j|||�S)N)r�r�r:r�r�r�r�)r$r�r2r3r1rrr�_make_child{s	*zPurePath._make_childcCsRy|jSWn@tk
rM|j|j|j|j�p<d|_|jSYnXdS)z[Return the string representation of the path, suitable for
        passing to system calls.r'N)r�r�r�r�r�r�)r$rrr�__str__�s
zPurePath.__str__cCs"|j}t|�j|jd�S)zNReturn the string representation of the path with forward (/)
        slashes.rA)r�r]r*r")r$�frrrrj�s	zPurePath.as_posixcCstjt|��S)zaReturn the bytes representation of the path.  This is only
        recommended to use under Unix.)r^�fsencoder])r$rrr�	__bytes__�szPurePath.__bytes__cCsdj|jj|j��S)Nz{}({!r}))r�r�r;rj)r$rrrr��szPurePath.__repr__cCs+|j�std��n|jj|�S)z Return the path as a 'file' URI.z.relative path can't be expressed as a file URI)r�r�r�rn)r$rrr�as_uri�szPurePath.as_uricCsCy|jSWn1tk
r>|jj|j�|_|jSYnXdS)N)r�r�r�r\r�)r$rrr�_cparts�s

zPurePath._cpartscCs5t|t�stS|j|jko4|j|jkS)N)r�r�NotImplementedr�r�)r$�otherrrr�__eq__�szPurePath.__eq__cCsCy|jSWn1tk
r>tt|j��|_|jSYnXdS)N)r�r��hashr�r�)r$rrr�__hash__�s

zPurePath.__hash__cCs6t|t�s"|j|jk	r&tS|j|jkS)N)r�rr�r�r�)r$r�rrr�__lt__�s"zPurePath.__lt__cCs6t|t�s"|j|jk	r&tS|j|jkS)N)r�rr�r�r�)r$r�rrr�__le__�s"zPurePath.__le__cCs6t|t�s"|j|jk	r&tS|j|jkS)N)r�rr�r�r�)r$r�rrr�__gt__�s"zPurePath.__gt__cCs6t|t�s"|j|jk	r&tS|j|jkS)N)r�rr�r�r�)r$r�rrr�__ge__�s"zPurePath.__ge__�docz.The drive prefix (letter or UNC path), if any.zThe root of the path, if any.cCs|j|j}|S)z/The concatenation of the drive and root, or ''.)r�r�)r$�anchorrrrr��szPurePath.anchorcCs?|j}t|�|js$|jr*dndkr7dS|dS)z!The final path component, if any.r8rr&rN)r�rQr�r�)r$r1rrrrr�s	*z
PurePath.namecCsT|j}|jd�}d|ko9t|�dknrL||d�SdSdS)z*The final component's last suffix, if any.r'rr8Nr&)rr�rfindrQ)r$rrrIrrr�suffix�s
	&zPurePath.suffixcCsO|j}|jd�rgS|jd�}dd�|jd�dd�D�S)z1A list of the final component's suffixes, if any.r'cSsg|]}d|�qS)r'r)rCr�rrrr[�s	z%PurePath.suffixes.<locals>.<listcomp>r8N)rr�endswithrSr,)r$rrrrr�suffixes�s
	zPurePath.suffixescCsT|j}|jd�}d|ko9t|�dknrL|d|�S|SdS)z0The final path component, minus its last suffix.r'rr8N)rrr�rQ)r$rrrIrrr�stem�s
	&z
PurePath.stemcCs�|jstd|f��n|jj|f�\}}}|s�|d|jj|jjgks�|s�|s�t|�dkr�td|��n|j|j|j	|j
dd�|g�S)z-Return a new path with the file name changed.z%r has an empty namer8zInvalid name %rNrNrN)rrr�r�r7r"r(rQr�r�r�r�)r$rrr2r3r1rrr�	with_name�s	)zPurePath.with_namecCs|j}|j|ks0|jrC|j|krCtd|��n|rY|jd�se|dkrxtd|��n|j}|s�td|f��n|j}|s�||}n|dt|��|}|j|j	|j
|jdd�|g�S)zCReturn a new path with the file suffix changed (or added, if none).zInvalid suffix %rr'z%r has an empty nameNr8rN)r�r"r(r�rdrrr�rQr�r�r�r�)r$r�r�rrZ
old_suffixrrr�with_suffixs	'"		
zPurePath.with_suffixc
GsW|std��n|j}|j}|j}|rS||g|dd�}n|}|j|�\}}}|r�||g|dd�}	n|}	t|	�}
|jj}|
dkr�|p�|n||d|
��||	�kr(|j|||�}t	dj
t|�t|����n|jd|
dkrC|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 argumentr8Nrz{!r} does not start with {!r}r&)
r�r�r�r�r�rQr�r\r�r�r�r]r�)
r$r�r1r2r3Z	abs_partsZto_drvZto_rootZto_partsZto_abs_parts�nr�Z	formattedrrr�relative_tos(				:	zPurePath.relative_tocCs=y|jSWn+tk
r8t|j�|_|jSYnXdS)zZAn object providing sequence-like access to the
        components in the filesystem path.N)r�r�r�r�)r$rrrr17s

zPurePath.partscGs
|j|�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�joinpathCszPurePath.joinpathcCs|j|f�S)N)r�)r$�keyrrr�__truediv__KszPurePath.__truediv__cCs|j|g|j�S)N)r�r�)r$rrrr�__rtruediv__NszPurePath.__rtruediv__cCsZ|j}|j}|j}t|�dkr=|s9|r=|S|j|||dd��S)zThe logical parent of the path.r8NrN)r�r�r�rQr�)r$r2r3r1rrr�parentQs			zPurePath.parentcCs
t|�S)z*A sequence of this path's logical parents.)r�)r$rrr�parents[szPurePath.parentscCs'|js
dS|jjp&t|j�S)zSTrue if the path is absolute (has both a root and, if applicable,
        a drive).F)r�r�ro�boolr�)r$rrrr�`s	zPurePath.is_absolutecCs|jj|j�S)zaReturn True if the path contains one of the special names reserved
        by the system, if any.)r�rhr�)r$rrrrhgszPurePath.is_reservedc	Cs/|jj}||�}|jj|f�\}}}|sKtd��n|rj|||j�krjdS|r�|||j�kr�dS|j}|s�|r�t|�t|�kr�dS|dd�}nt|�t|�kr�dSx?tt	|�t	|��D]"\}}t
j||�sdSqWdS)zE
        Return True if this path matches the given pattern.
        z
empty patternFr8NT)r�r9r7r�r�r�r�rQ�zipr)r�Zfnmatchcase)	r$Zpath_patternr�r2r3Z	pat_partsr1r5rrrrr�ls(	(zPurePath.matchN)z_drvz_rootz_partsz_strz_hashz_ppartsz_cached_cparts)/r;r<r=r>r�r�r��classmethodr�r�r�r�r�r�r�rjr�r�r��propertyr�r�r�r�r�r�r�rrir3r�rrr�r�rrrrr1rrrr	r
r�rhr�rrrrr-s\
	
			
	
 
c@seZdZeZfZdS)rN)r;r<r=�_posix_flavourr�r�rrrrr�sc@seZdZeZfZdS)rN)r;r<r=�_windows_flavourr�r�rrrrr�sc@s�eZdZdRZdd�Zddd�Zdd	�Zd
d�Zdd
�Zdd�Z	ddd�Z
ddd�Zedd��Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(dSdddd*d+�Zdd,d-d.�Zdd/d0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Zd>d?�Zd/d@dA�Z dBdC�Z!dDdE�Z"dFdG�Z#dHdI�Z$dJdK�Z%dLdM�Z&dNdO�Z'dPdQ�Z(dS)Trr��_closedcOsr|tkr*tjdkr!tnt}n|j|dd�}|jjsdtd|j	f��n|j
�|S)Nrr�Fz$cannot instantiate %r on your system)rr^rrrrr�r�rsr�r;r�)r�r��kwargsr$rrrr��s
zPath.__new__NcCs1d|_|dk	r$|j|_n	t|_dS)NF)rr��_normal_accessor)r$�templaterrrr��s	z
Path._initcCs)|j|g}|j|j|j|�S)N)r�r�r�r�)r$r5r1rrrr��szPath._make_child_relpathcCs|jr|j�n|S)N)r�
_raise_closed)r$rrr�	__enter__�s	
zPath.__enter__cCs
d|_dS)NT)r)r$�t�v�tbrrr�__exit__�sz
Path.__exit__cCstd��dS)NzI/O operation on closed path)r�)r$rrrr�szPath._raise_closedi�cCs|jj|||�S)N)r�r�)r$rr�flagsr�rrr�_opener�szPath._openeri�cCs,|jr|j�n|jj|||�S)zm
        Open the file pointed by this path and return a file descriptor,
        as os.open() does.
        )rrr�r�)r$rr�rrr�	_raw_open�s	
zPath._raw_opencCs|tj��S)zjReturn a new path pointing to the current working directory
        (as returned by os.getcwd()).
        )r^r_)r�rrr�cwd�szPath.cwdccsm|jr|j�nxP|jj|�D]<}|dkrAq)n|j|�V|jr)|j�q)q)WdS)zyIterate over the files in this directory.  Does not yield any
        result for the special paths '.' and '..'.
        r'�..N>r'r)rrr�r�r�)r$rrrrr�iterdir�s	
	zPath.iterdirccs�|jj|�}|jj|f�\}}}|s<|rKtd��ntt|��}x|j|�D]}|VqmWdS)z�Iterate over this subtree and yield all existing files (of any
        kind, including directories) matching the given pattern.
        z%Non-relative patterns are unsupportedN)r�r9r7r�r�r�r�)r$�patternr2r3r��selectorrZrrr�glob�sz	Path.globccs�|jj|�}|jj|f�\}}}|s<|rKtd��ntdt|��}x|j|�D]}|VqqWdS)z�Recursively yield all existing files (of any kind, including
        directories) matching the given pattern, anywhere in this subtree.
        z%Non-relative patterns are unsupported�**N)r$)r�r9r7r�r�r�r�)r$r!r2r3r�r"rZrrr�rglob�sz
Path.rglobcCs_|jr|j�n|j�r&|S|jtj�g|jdd�}|jd|�|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.
        r�Fr)rrr�r�r^r_r�r�)r$�objrrr�absolute�s	
%z
Path.absolutecCs�|jr|j�n|jj|�}|dkrS|j�t|j��}n|jjj|�}|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).
        Nr�Fr)rrr�rbr�r]r'rq�normpathr�r�)r$rYZnormedr&rrrrbs	

zPath.resolvecCs|jj|�S)zh
        Return the result of the stat() system call on this path, like
        os.stat() does.
        )r�r�)r$rrrr� sz	Path.statcCs%ddl}|j|j�j�jS)z:
        Return the login name of the file owner.
        rN)�pwd�getpwuidr��st_uidZpw_name)r$r)rrr�owner'sz
Path.ownercCs%ddl}|j|j�j�jS)z8
        Return the group name of the file gid.
        rN)�grpZgetgrgidr��st_gidZgr_name)r$r-rrr�group.sz
Path.group�rr8c	CsA|jr|j�ntjt|�|||||d|j�S)z|
        Open the file pointed by this path and return a file object, as
        the built-in open() function does.
        Zopener)rr�ior�r]r)r$r��	buffering�encoding�errors�newlinerrrr�5s	
!z	Path.openTcCs�|jr|j�n|rOy|jj|d�Wntk
rGYqOXdSntjtjB}|su|tjO}n|j	||�}tj
|�dS)zS
        Create this file with the given access mode, if it doesn't exist.
        N)rrr�r�r{r^�O_CREAT�O_WRONLY�O_EXCLr�close)r$r��exist_okr�fdrrr�touch@s	

z
Path.touchFcCs�|jr|j�n|s2|jj||�nzy|jj||�Wn`tk
r�}z@|jtkrs�n|jjdd�|jj||�WYdd}~XnXdS)Nr
T)rrr�r�r{r|rr	)r$r�r
r�rrrr�Ws	
z
Path.mkdircCs-|jr|j�n|jj||�dS)zF
        Change the permissions of the path, like os.chmod().
        N)rrr�r�)r$r�rrrr�es	
z
Path.chmodcCs-|jr|j�n|jj||�dS)z�
        Like chmod(), except if the path points to a symlink, the symlink's
        permissions are changed, rather than its target's.
        N)rrr�r�)r$r�rrrr�ms	
zPath.lchmodcCs*|jr|j�n|jj|�dS)zd
        Remove this file or link.
        If the path is a directory, use rmdir() instead.
        N)rrr�r�)r$rrrr�vs	
zPath.unlinkcCs*|jr|j�n|jj|�dS)zF
        Remove this directory.  The directory must be empty.
        N)rrr�r�)r$rrrr�s	
z
Path.rmdircCs&|jr|j�n|jj|�S)z�
        Like stat(), except if the path points to a symlink, the symlink's
        status information is returned, rather than its target's.
        )rrr�r�)r$rrrr��s	
z
Path.lstatcCs-|jr|j�n|jj||�dS)z5
        Rename this path to the given path.
        N)rrr�r�)r$rrrrr��s	
zPath.renamecCs-|jr|j�n|jj||�dS)zo
        Rename this path to the given path, clobbering the existing
        destination if it exists.
        N)rrr�r*)r$rrrrr*�s	
zPath.replacecCs0|jr|j�n|jj|||�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)rrr�r�)r$rr�rrr�
symlink_to�s	
zPath.symlink_tocCsYy|j�WnDtk
rT}z$|jttfkr>�ndSWYdd}~XnXdS)z+
        Whether this path exists.
        FNT)r�r{r|rr)r$r�rrrr��szPath.existscCsbyt|j�j�SWnDtk
r]}z$|jttfkrG�ndSWYdd}~XnXdS)z3
        Whether this path is a directory.
        FN)rr��st_moder{r|rr)r$r�rrrr��szPath.is_dircCsbyt|j�j�SWnDtk
r]}z$|jttfkrG�ndSWYdd}~XnXdS)zq
        Whether this path is a regular file (also True for symlinks pointing
        to regular files).
        FN)r
r�r>r{r|rr)r$r�rrr�is_file�szPath.is_filecCsbyt|j�j�SWnDtk
r]}z$|jttfkrG�ndSWYdd}~XnXdS)z7
        Whether this path is a symbolic link.
        FN)r	r�r>r{r|rr)r$r�rrrr��szPath.is_symlinkcCsbyt|j�j�SWnDtk
r]}z$|jttfkrG�ndSWYdd}~XnXdS)z6
        Whether this path is a block device.
        FN)rr�r>r{r|rr)r$r�rrr�is_block_device�szPath.is_block_devicecCsbyt|j�j�SWnDtk
r]}z$|jttfkrG�ndSWYdd}~XnXdS)z:
        Whether this path is a character device.
        FN)r
r�r>r{r|rr)r$r�rrr�is_char_device�szPath.is_char_devicecCsbyt|j�j�SWnDtk
r]}z$|jttfkrG�ndSWYdd}~XnXdS)z.
        Whether this path is a FIFO.
        FN)rr�r>r{r|rr)r$r�rrr�is_fifo�szPath.is_fifocCsbyt|j�j�SWnDtk
r]}z$|jttfkrG�ndSWYdd}~XnXdS)z0
        Whether this path is a socket.
        FN)rr�r>r{r|rr)r$r�rrr�	is_socketszPath.is_socket)z	_accessorz_closedrN))r;r<r=r�r�r�r�rrrrrr
rr r#r%r'rbr�r,r/r�r<r�r�r�r�r�r�r�r*r=r�r�r?r�r@rArBrCrrrrr�sN	
				



c@seZdZfZdS)rN)r;r<r=r�rrrrrsc@seZdZfZdS)rN)r;r<r=r�rrrrrs)=r�r�r1rpr^r�r�r.�collectionsr�
contextlibrr|rrr�operatorrr�rr	r
rrr
rZurllib.parserrkr�rrrZgetwindowsversionr�__all__r r�r!r?rwrrr�r�rr�r�r�r�r�r�r�r�r�r�rrrrrrrrrr�<module>sd4"		?zS		;	
'�Z��