Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/py/_path/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/py/_path/__pycache__/common.cpython-37.pyc

B

���]�9�@s�dZddlZddlZddlZddlZddlZejdkpDeedd�dkZyddlm	Z	Wne
k
rrdd	�Z	YnXGd
d�d�ZGdd
�d
e�Z
Gdd�de�ZGdd�d�ZGdd�d�ZdS)�
�N�win32�_nameF�nt)�fspathcCs�t|tjjtjjf�r|St|�}y
|�|�Stk
r�t|d�rH�yddl	}Wnt
k
rhYnXt||j�r�tj�|�Std|j
��YnXdS)a	
        Return the string representation of the path.
        If str or bytes is passed in, it is returned unchanged.
        This code comes from PEP 519, modified to support earlier versions of
        python.

        This is required for python < 3.6.
        �
__fspath__rNz/expected str, bytes or os.PathLike object, not )�
isinstance�py�builtin�text�bytes�typer�AttributeError�hasattr�pathlib�ImportErrorZPurePath�	TypeError�__name__)�path�	path_typer�r�@/opt/alt/python37/lib/python3.7/site-packages/py/_path/common.pyr
s 	

rc@speZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�Checkers)�exists�link�dir�filecCs
||_dS)N)r)�selfrrrr�__init__/szCheckers.__init__cCst�dS)N)�NotImplementedError)rrrrr2szCheckers.dircCst�dS)N)r)rrrrr5sz
Checkers.filecCs|jj�d�S)N�.)r�basename�
startswith)rrrr�dotfile8szCheckers.dotfilecCs|�d�sd|}|jj|kS)Nr )r"r�ext)r�argrrrr$;s
zCheckers.extcCst�dS)N)r)rrrrr@szCheckers.existscCs|jj|kS)N)rr!)rr%rrrr!CszCheckers.basenamecCs|jj�|�S)N)rr!r")rr%rrr�
basestartsFszCheckers.basestartscCs|j�|�S)N)r�relto)rr%rrrr'IszCheckers.reltocCs|j�|�S)N)r�fnmatch)rr%rrrr(LszCheckers.fnmatchcCst|j��|�S)N)�strr�endswith)rr%rrrr*OszCheckers.endswithcCs`�xX|��D�]J\}}d}d}yt||�}WnTtk
r�|dd�dkr|d}yt||dd��}Wntk
rzYnXYnX|dkr�td||jf��yDtj�|�jdkr�||�|Ar�dSnt	|�t	|��A|Ar�dSWqtj
jtj
jtj
j
fk
�rVxL|jD]B}||k�r*|�|��r*dSd|}||k�r|�|��sdS�qWYqXqWdS)NF��notTzno %r checker available for %r�)�items�getattrrrrr	�codeZ
getrawcode�co_argcount�bool�error�ENOENT�ENOTDIRZEBUSY�_depend_on_existence�get)r�kw�name�value�invert�methrrr�	_evaluateRs>"

zCheckers._evaluateN)r�
__module__�__qualname__r6rrrr#r$rr!r&r'r(r*r=rrrrr,src@seZdZdS)�NeverRaisedN)rr>r?rrrrr@wsr@c@sZeZdZdZeZdd�ZeZdd�Zeeddej�Zdd�Z	ee	dde	j�Z	d	d
�Z
ee
dde
j�Z
dd�Zeeddej�Zd
d�Zdd�Z
dd�ZdBdd�ZdCdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�ZdDd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Z dde!d/d/fd:d;�Z"d<d=�Z#d>d?�Z$d@dA�Z%dS)E�PathBasez3 shared implementation for filesystem path objects.cCs|�t|��S)N)�joinr)r�otherrrr�__div__~szPathBase.__div__cCs|�d�dS)z basename part of path. r!r)�
_getbyspec)rrrrr!�szPathBase.basenameNcCs|�d�dS)z dirname part of path. �dirnamer)rE)rrrrrF�szPathBase.dirnamecCs|�d�dS)z pure base name of the path.�purebasenamer)rE)rrrrrG�szPathBase.purebasenamecCs|�d�dS)z+ extension of the path (including the '.').r$r)rE)rrrrr$�szPathBase.extcOs|jdd�j||�S)zB return the directory path joined with any given path arguments.  �)r!)�newrB)r�args�kwargsrrr�dirpath�szPathBase.dirpathc	Cs|�d��
}|��SQRXdS)z5 read and return a bytestring from reading the path. �rbN)�open�read)r�frrr�read_binary�szPathBase.read_binaryc	Cs"|jd|d��
}|��SQRXdS)z9 read and return a Unicode string from reading the path. �r)�encodingN)rNrO)rrSrPrrr�	read_text�szPathBase.read_textrRc	Cs|�|��
}|��SQRXdS)z5 read and return a bytestring from reading the path. N)rNrO)r�moderPrrrrO�sz
PathBase.readr-cCsNtjdkrd}nd}|s,|�|�}|�d�S|�|�}z|��S|��XdS)zw read and return a list of lines from the path. if cr is False, the
newline will be removed from the end of each line. )r+ZrUrRrN)�sys�version_inforO�splitrN�	readlines�close)rZcrrU�contentrPrrrrY�s



zPathBase.readlinescCs.|�d�}ztj�tjjj|�S|��XdS)z7 (deprecated) return object unpickled from self.read() rMN)rNr	r3Zchecked_callZstd�pickle�loadrZ)rrPrrrr]�s
z
PathBase.loadcCsV|�|�rtj�|d��y|�|�Wn*tjjk
rP|�|�|��YnXdS)z move this path to target. z.cannot move path into a subdirectory of itselfN)r'r	r3�EINVAL�rename�EXDEV�copy�remove)r�targetrrr�move�s

z
PathBase.movecCstt|��S)z. return a string representation of this path. )�reprr))rrrr�__repr__�szPathBase.__repr__cKs|sddi}|�|��|�S)a	 check a path for existence and properties.

            Without arguments, return True if the path exists, otherwise False.

            valid checkers::

                file=1    # is a file
                file=0    # is not a file (may not even exist)
                dir=1     # is a dir
                link=1    # is a link
                exists=1  # exists

            You can specify multiple checker definitions, for example::

                path.check(file=1, link=1)  # a link pointing to a file
        rr-)rr=)rr8rrr�check�szPathBase.checkcCst|�|�S)a3return true if the basename/fullname matches the glob-'pattern'.

        valid pattern characters::

            *       matches everything
            ?       matches any single character
            [seq]   matches any character in seq
            [!seq]  matches any char not in seq

        If the pattern contains a path-separator then the full path
        is used for pattern matching and a '*' is prepended to the
        pattern.

        if the pattern doesn't contain a path-separator the pattern
        is only matched against the basename.
        )�	FNMatcher)r�patternrrrr(�szPathBase.fnmatchcCs�t|ttf�std|f��t|�}|r@|d|jkr@||j7}|j}tjdks`tt	dd�dkr�t	j
�|��t	j
�|��r�|t
|�d�Sn|�|�r�|t
|�d�SdS)z` return a string which is the relative part of the path
        to the given 'relpath'.
        z%r: not a string or path object���rrNrrH)rr)rAr�sep�strpathrV�platformr/�osr�normcaser"�len)r�relpathZ
strrelpathZstrselfrrrr'�s

zPathBase.reltocGs|j|ddi�S)z2 ensure the path joined with args is a directory. rT)Zensure)rrJrrr�
ensure_dirszPathBase.ensure_dircCs�y|||krtjS|�|�}|s&t|�S|�|�}|�|�}|rP|�|j�d}nd}tjg|}|rn|�|�|j�	|�}|St
k
r�t|�SXdS)z� return a string which is a relative path from self
            (assumed to be a directory) to dest such that
            self.join(bestrelpath) == dest and if not such
            path can be determined return dest.
        r-rN)rn�curdir�commonr)r'�countrk�pardir�appendrBr)r�dest�baseZ	self2baseZreldest�n�lrcrrr�bestrelpaths$



zPathBase.bestrelpathcCs|��S)N)rg)rrrrr-szPathBase.existscCs|jdd�S)Nr-)r)rg)rrrr�isdir0szPathBase.isdircCs|jdd�S)Nr-)r)rg)rrrr�isfile3szPathBase.isfileFcCs@|}|g}x$|}|��}||kr"P|�|�qW|s<|��|S)z` return a root-first list of all ancestor directories
            plus the path itself.
        )rLrw�reverse)rr�currentr{�lastrrr�parts6szPathBase.partscCs8d}x.t|��|���D]\}}||kr,|S|}qW|S)zk return the common part shared with the other path
            or None if there is no common part.
        N)�zipr�)rrCr��x�yrrrrtFszPathBase.commoncCs|j|jt|�d�S)z: return new path object with 'other' added to the basename)r!)rIr!r))rrCrrr�__add__QszPathBase.__add__cCs6yt|j|j�Stk
r0tt|�t|��SXdS)z  return sort value (-1, 0, +1). N)Zcmprlrr))rrCrrr�__cmp__UszPathBase.__cmp__cCs2y|j|jkStk
r,t|�t|�kSXdS)N)rlrr))rrCrrr�__lt__\szPathBase.__lt__ccs*x$t|||||��|�D]
}|VqWdS)a� yields all paths below the current one

            fil is a filter (glob pattern or callable), if not matching the
            path will not be yielded, defaulting to None (everything is
            returned)

            rec is a filter (glob pattern or callable) that controls whether
            a node is descended, defaulting to None

            ignore is an Exception class that is ignoredwhen calling dirlist()
            on any of the paths (by default, all exceptions are reported)

            bf if True will cause a breadthfirst search instead of the
            default depthfirst. Default: False

            sort if True will sort entries within each directory level.
        N)�Visitor�gen)r�fil�rec�ignore�bf�sortr�rrr�visitbszPathBase.visitcCs&|r"t|d�r|�|�n|��dS)N�__call__)rr�)r�resr�rrr�	_sortlistws
zPathBase._sortlistcCs|jt|�kS)z> return True if other refers to the same stat object as self. )rlr))rrCrrr�samefile~szPathBase.samefilecCs|jS)N)rl)rrrrr�szPathBase.__fspath__)rR)r-)F)&rr>r?�__doc__rrD�__truediv__r!�propertyrFrGr$rLrQrTrOrYr]rdrfrgr(r'rrr|rr}r~r�rtr�r�r�r@r�r�r�rrrrrrAzsJ


rAc@seZdZdd�Zdd�ZdS)r�cCsxt|tjj�rt|�}t|tjj�r0t|�|_n t|d�sJ|rJdd�|_n||_||_||_||_	|rjt
ppdd�|_dS)Nr�cSsdS)NTr)rrrr�<lambda>��z"Visitor.__init__.<locals>.<lambda>cSs|S)Nr)r�rrrr��r�)rr	r
Z_basestringrhr�rr�r��breadthfirst�sorted�optsort)rr�r�r�r�r�rrrr�szVisitor.__init__c#s�y|��}Wn|jk
r"dSX|j�|��fdd�|D��}|jspx&|D]}x|�|�D]
}|Vq^WqNWx,|�|�D]}|jdks�|�|�r||Vq|W|jr�x&|D]}x|�|�D]
}|Vq�Wq�WdS)Ncs,g|]$}|jdd�r�dks$�|�r|�qS)r-)rN)rg)�.0�p)r�rr�
<listcomp>�szVisitor.gen.<locals>.<listcomp>)�listdirr�r�r�r�r�r�)rr�entries�dirsZsubdirr�r)r�rr��s"


zVisitor.genN)rr>r?rr�rrrrr��sr�c@seZdZdd�Zdd�ZdS)rhcCs
||_dS)N)ri)rrirrrr�szFNMatcher.__init__cCs�|j}|�|j�dkr:tr:|�tj�dkr:|�tj|j�}|�|j�dkrR|j}n"t|�}tj	�
|�std|j|}t�||�S)Nrj�*)ri�findrk�iswin32�	posixpath�replacer!r)rnr�isabsr()rrrir9rrrr��szFNMatcher.__call__N)rr>r?rr�rrrrrh�srh)r�rnrVr�r(r	rmr/r�rrr�	Exceptionr@�objectrAr�rhrrrr�<module>sK
#