Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 18.188.216.107
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : util.cpython-36.pyc
3

���ei��@s>ddlZddlmZddlZddlZddlmZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZyddlZWnek
r�dZYnXddlZddlZddlZddlZddlZyddlZWnek
r�ddlZYnXddlZddlmZddlmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/e
j0e1�Z2dZ3e
j4e3�Z5dZ6d	e6d
Z7e6dZ8dZ9d
e9de8de3d
e9de8dZ:dZ;de:de;de:dZ<e7d
e3e7dZ=de=dZ>de6de>de<dZ?e
j4e?�Z@de9de8d
ZAe
j4eA�ZBdd �ZCd!d"�ZDd#d$�ZEd%d&�ZFd�d'd(�ZGd)d*�ZHd+d,�ZId-d.�ZJejKd/d0��ZLejKd1d2��ZMejKd�d4d5��ZNGd6d7�d7eO�ZPd8d9�ZQGd:d;�d;eO�ZRd<d=�ZSGd>d?�d?eO�ZTe
j4d@e
jU�ZVdAdB�ZWd�dCdD�ZXdEdF�ZYdGdH�ZZdIdJ�Z[dKdL�Z\dMdN�Z]e
j4dOe
j^�Z_e
j4dP�Z`d�dQdR�Zae
j4dS�ZbdTdU�ZcdVdW�ZddXdY�ZedZZfd[d\�Zgd]d^�ZhGd_d`�d`eO�ZiGdadb�dbeO�ZjGdcdd�ddeO�Zkd�Zld�dmdn�Zmdodp�Znd�ZoGdwdx�dxeO�Zpe
j4dy�Zqe
j4dz�Zre
j4d{�Zsd|d}�Zd~d�Zte�r\dd�lmuZvmwZwmxZxGd�d��d�e$jy�ZyGd�d��d�ev�ZuGd�d��d�eue'�Zzej{dd��Z|e|d�k�r�Gd�d��d�e$j}�Z}e�r�Gd�d��d�e$j~�Z~Gd�d��d�e%j�Ze�r�Gd�d��d�e%j��Z�Gd�d��d�e%j��Z�d�d��Z�Gd�d��d�eO�Z�Gd�d��d�e��Z�Gd�d��d�e��Z�Gd�d��d�e(�Z�Gd�d��d�eO�Z�d�d��Z�dS)��N)�deque)�iglob�)�DistlibException)�string_types�	text_type�shutil�	raw_input�StringIO�cache_from_source�urlopen�urljoin�httplib�	xmlrpclib�	splittype�HTTPHandler�BaseConfigurator�valid_ident�	Container�configparser�URLError�ZipFile�fsdecode�unquotez\s*,\s*z
(\w|[.-])+z(\*|:(\*|\w+):|�)z\*?z([<>=!~]=)|[<>]�(z)?\s*(z)(z)\s*(z))*z(from\s+(?P<diref>.*))z\(\s*(?P<c1>�|z)\s*\)|(?P<c2>z\s*)z)*z\[\s*(?P<ex>z)?\s*\]z(?P<dn>z	\s*)?(\s*z)?$z(?P<op>z)\s*(?P<vn>cs�dd��d}tj|�}|r�|j�}|d}|dp8|d}|dsHd}nd}|dj�}|snd}d}|d}nL|dd	kr�d
|}tj|�}	�fdd�|	D�}d
|djdd�|D��f}|ds�d}
ntj|d�}
t	|||
|||d�}|S)NcSs|j�}|d|dfS)N�opZvn)�	groupdict)�m�d�r!�/usr/lib/python3.6/util.py�get_constraintYsz)parse_requirement.<locals>.get_constraintZdnZc1Zc2Zdiref�rz<>!=z~=csg|]}�|��qSr!r!)�.0r)r#r!r"�
<listcomp>qsz%parse_requirement.<locals>.<listcomp>z%s (%s)z, cSsg|]}d|�qS)z%s %sr!)r%Zconr!r!r"r&rsZex)�nameZconstraints�extrasZrequirement�source�url)
�REQUIREMENT_RE�matchr�strip�RELOP_IDENT_RE�finditer�join�COMMA_RE�splitr)�s�resultrr r'Zconsr*ZconstrZrs�iteratorr(r!)r#r"�parse_requirementWs4


r6cCs�dd�}i}x�|D]�\}}}tjj||�}x�t|�D]t}tjj||�}	x`t|	�D]T}
|||
�}|dkrt|j|d�qP|||
�}|jtjjd�jd�}
|
d|||<qPWq4WqW|S)z%Find destinations for resources filescSsD|jtjjd�}|jtjjd�}|j|�s.t�|t|�d�jd�S)N�/)�replace�os�path�sep�
startswith�AssertionError�len�lstrip)�baser:r!r!r"�get_rel_pathsz)get_resources_dests.<locals>.get_rel_pathNr7)r9r:r0r�popr8r;�rstrip)Zresources_rootZrulesrAZdestinationsr@�suffix�dest�prefixZabs_baseZabs_globZabs_pathZ
resource_fileZrel_pathZrel_destr!r!r"�get_resources_dests|s

rGcCs(ttd�rd}ntjttdtj�k}|S)NZreal_prefixT�base_prefix)�hasattr�sysrF�getattr)r4r!r!r"�in_venv�s
rLcCs$tjjtj�}t|t�s t|�}|S)N)r9r:�normcaserJ�
executable�
isinstancerr)r4r!r!r"�get_executable�s

rPcCsT|}xJt|�}|}|r |r |}|r|dj�}||kr:P|rd|||f}qW|S)Nrz	%c: %s
%s)r	�lower)�promptZ
allowed_charsZerror_prompt�default�pr3�cr!r!r"�proceed�s
rVcCs<t|t�r|j�}i}x |D]}||kr||||<qW|S)N)rOrr2)r �keysr4�keyr!r!r"�extract_by_key�s

rYcCs�tjddkrtjd�|�}|j�}t|�}yrtj|�}|ddd}xR|j�D]F\}}x<|j�D]0\}}d||f}t	|�}	|	dk	s�t
�|	||<qdWqRW|Stk
r�|jdd�YnXdd	�}
t
j�}y|
||�Wn<t
jk
�r|j�tj|�}t|�}|
||�YnXi}xb|j�D]V}i||<}xB|j|�D]4\}
}d|
|f}t	|�}	|	dk	�spt
�|	||
<�qFW�q*W|S)
Nr�zutf-8�
extensionszpython.exports�exportsz%s = %scSs$t|d�r|j|�n
|j|�dS)N�	read_file)rIr]Zreadfp)�cp�streamr!r!r"�read_stream�s
z!read_exports.<locals>.read_stream)rJ�version_info�codecs�	getreader�readr
�json�load�items�get_export_entryr=�	Exception�seekr�ConfigParserZMissingSectionHeaderError�close�textwrap�dedentZsections)r_�dataZjdatar4�groupZentries�k�vr3�entryr`r^rXr'�valuer!r!r"�read_exports�sD

rucCs�tjddkrtjd�|�}tj�}x||j�D]p\}}|j|�x\|j�D]P}|j	dkr`|j
}nd|j
|j	f}|jr�d|dj|j�f}|j
||j|�qJWq.W|j|�dS)NrrZzutf-8z%s:%sz%s [%s]z, )rJrarb�	getwriterrrkrgZadd_section�valuesrDrF�flagsr0�setr'�write)r\r_r^rqrrrsr3r!r!r"�
write_exports�s

r{ccs$tj�}z
|VWdtj|�XdS)N)�tempfile�mkdtempr�rmtree)Ztdr!r!r"�tempdirs
rccs.tj�}ztj|�dVWdtj|�XdS)N)r9�getcwd�chdir)r �cwdr!r!r"r�s


r��ccs.tj�}ztj|�dVWdtj|�XdS)N)�socketZgetdefaulttimeoutZsetdefaulttimeout)ZsecondsZctor!r!r"�socket_timeouts


r�c@seZdZdd�Zddd�ZdS)�cached_propertycCs
||_dS)N)�func)�selfr�r!r!r"�__init__)szcached_property.__init__NcCs,|dkr|S|j|�}tj||jj|�|S)N)r��object�__setattr__�__name__)r��obj�clsrtr!r!r"�__get__.s

zcached_property.__get__)N)r��
__module__�__qualname__r�r�r!r!r!r"r�(sr�cCs�tjdkr|S|s|S|ddkr.td|��|ddkrFtd|��|jd�}xtj|krj|jtj�qRW|svtjStjj|�S)a�Return 'pathname' as a name that will work on the native filesystem.

    The path is split on '/' and put back together again using the current
    directory separator.  Needed because filenames in the setup script are
    always supplied in Unix style, and have to be converted to the local
    convention before we can actually use them in the filesystem.  Raises
    ValueError on non-Unix-ish systems if 'pathname' either starts or
    ends with a slash.
    r7rzpath '%s' cannot be absoluterzpath '%s' cannot end with '/'���)r9r;�
ValueErrorr2�curdir�remover:r0)�pathname�pathsr!r!r"�convert_path6s


r�c@s�eZdZd$dd�Zdd�Zdd�Zdd	�Zd%dd�Zd&dd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
d'dd�Zdd�Zdd�Zd d!�Zd"d#�Zd
S)(�FileOperatorFcCs||_t�|_|j�dS)N)�dry_runry�ensured�_init_record)r�r�r!r!r"r�RszFileOperator.__init__cCsd|_t�|_t�|_dS)NF)�recordry�
files_written�dirs_created)r�r!r!r"r�WszFileOperator._init_recordcCs|jr|jj|�dS)N)r�r��add)r�r:r!r!r"�record_as_written\szFileOperator.record_as_writtencCsHtjj|�s tdtjj|���tjj|�s0dStj|�jtj|�jkS)a�Tell if the target is newer than the source.

        Returns true if 'source' exists and is more recently modified than
        'target', or if 'source' exists and 'target' doesn't.

        Returns false if both exist and 'target' is the same age or younger
        than 'source'. Raise PackagingFileError if 'source' does not exist.

        Note that this test is not very accurate: files created in the same
        second will have the same "age".
        zfile '%r' does not existT)r9r:�existsr�abspath�stat�st_mtime)r�r)�targetr!r!r"�newer`szFileOperator.newerTcCs�|jtjj|��tjd||�|js�d}|rftjj|�rDd|}n"tjj|�rftjj	|�rfd|}|rvt
|d��tj||�|j
|�dS)z8Copy a file respecting dry-run and force flags.
        zCopying %s to %sNz%s is a symlinkz%s is a non-regular filez which would be overwritten)�
ensure_dirr9r:�dirname�logger�infor��islinkr��isfiler�rZcopyfiler�)r�Zinfile�outfile�check�msgr!r!r"�	copy_filets
zFileOperator.copy_fileNc
Cs�tjj|�st�|jtjj|��tjd||�|jsx|dkrLt	|d�}nt
j	|d|d�}ztj||�Wd|j
�X|j|�dS)NzCopying stream %s to %s�wb�w)�encoding)r9r:�isdirr=r�r�r�r�r��openrbrZcopyfileobjrlr�)r�Zinstreamr�r�Z	outstreamr!r!r"�copy_stream�s
zFileOperator.copy_streamc	CsF|jtjj|��|js8t|d��}|j|�WdQRX|j|�dS)Nr�)r�r9r:r�r�r�rzr�)r�r:ro�fr!r!r"�write_binary_file�s
zFileOperator.write_binary_filec
CsL|jtjj|��|js>t|d��}|j|j|��WdQRX|j|�dS)Nr�)	r�r9r:r�r�r�rz�encoder�)r�r:ror�r�r!r!r"�write_text_file�s
zFileOperator.write_text_filecCsrtjdkstjdkrntjdkrnxN|D]F}|jr<tjd|�q$tj|�j|B|@}tjd||�tj||�q$WdS)N�posix�javazchanging mode of %szchanging mode of %s to %o)	r9r'�_namer�r�r�r��st_mode�chmod)r��bits�mask�filesr��moder!r!r"�set_mode�s
zFileOperator.set_modecCs|jdd|�S)Nimi�)r�)r3r�r!r!r"�<lambda>�szFileOperator.<lambda>cCs~tjj|�}||jkrztjj|�rz|jj|�tjj|�\}}|j|�tj	d|�|j
shtj|�|jrz|j
j|�dS)NzCreating %s)r9r:r�r�r�r�r2r�r�r�r��mkdirr�r�)r�r:r r�r!r!r"r��s

zFileOperator.ensure_dircCsvt||�}tjd||�|jsh|s0|j||�rX|s:d}n|j|�sHt�|t|�d�}tj	|||d�|j
|�|S)NzByte-compiling %s to %sT)rr�r�r�r�r<r=r>�
py_compile�compiler�)r�r:�optimize�forcerFZdpathZdiagpathr!r!r"�byte_compile�s
zFileOperator.byte_compilecCs�tjj|�r�tjj|�r`tjj|�r`tjd|�|jsBtj	|�|j
r�||jkr�|jj|�nPtjj|�rrd}nd}tjd||�|js�tj|�|j
r�||j
kr�|j
j|�dS)NzRemoving directory tree at %s�link�filezRemoving %s %s)r9r:r�r�r�r��debugr�rr~r�r�r�r�)r�r:r3r!r!r"�ensure_removed�s"



zFileOperator.ensure_removedcCsHd}x>|sBtjj|�r&tj|tj�}Ptjj|�}||kr<P|}qW|S)NF)r9r:r��access�W_OKr�)r�r:r4�parentr!r!r"�is_writable�szFileOperator.is_writablecCs"|js
t�|j|jf}|j�|S)zV
        Commit recorded changes, turn off recording, return
        changes.
        )r�r=r�r�r�)r�r4r!r!r"�commit�s
zFileOperator.commitcCs�|js�x(t|j�D]}tjj|�rtj|�qWt|jdd�}xN|D]F}tj	|�}|r�|dgksdt
�tjj||d�}tj|�tj|�qDW|j
�dS)NT)�reverse�__pycache__r)r��listr�r9r:r�r��sortedr��listdirr=r0�rmdirr�)r�r��dirsr �flistZsdr!r!r"�rollback�s


zFileOperator.rollback)F)T)N)FFN)r�r�r�r�r�r�r�r�r�r�r�r�Zset_executable_moder�r�r�r�r�r�r!r!r!r"r�Qs 




r�cCsb|tjkrtj|}nt|�}|dkr,|}n2|jd�}t||jd��}x|D]}t||�}qLW|S)N�.r)rJ�modules�
__import__r2rKrB)Zmodule_nameZdotted_path�modr4�partsrTr!r!r"�resolves


r�c@s6eZdZdd�Zedd��Zdd�Zdd�Zej	Z	d	S)
�ExportEntrycCs||_||_||_||_dS)N)r'rFrDrx)r�r'rFrDrxr!r!r"r�szExportEntry.__init__cCst|j|j�S)N)r�rFrD)r�r!r!r"rtszExportEntry.valuecCsd|j|j|j|jfS)Nz<ExportEntry %s = %s:%s %s>)r'rFrDrx)r�r!r!r"�__repr__!s
zExportEntry.__repr__cCsDt|t�sd}n0|j|jko>|j|jko>|j|jko>|j|jk}|S)NF)rOr�r'rFrDrx)r��otherr4r!r!r"�__eq__%s
zExportEntry.__eq__N)
r�r�r�r�r�rtr�r�r��__hash__r!r!r!r"r�s

r�z�(?P<name>(\w|[-.+])+)
                      \s*=\s*(?P<callable>(\w+)([:\.]\w+)*)
                      \s*(\[\s*(?P<flags>\w+(=\w+)?(,\s*\w+(=\w+)?)*)\s*\])?
                      c
Cs�tj|�}|s0d}d|ks"d|kr�td|��n�|j�}|d}|d}|jd�}|dkrf|d}}n"|dkrztd|��|jd�\}}|d	}	|	dkr�d|ks�d|kr�td|��g}	nd
d�|	jd�D�}	t||||	�}|S)
N�[�]zInvalid specification '%s'r'�callable�:rrrxcSsg|]}|j��qSr!)r-)r%r�r!r!r"r&Qsz$get_export_entry.<locals>.<listcomp>�,)�ENTRY_RE�searchrr�countr2r�)
Z
specificationrr4r r'r:ZcolonsrFrDrxr!r!r"rh7s2


rhcCs�|dkrd}tjdkr.dtjkr.tjjd�}ntjjd�}tjj|�rftj|tj�}|s�t	j
d|�n<ytj|�d}Wn(tk
r�t	j
d	|dd
�d}YnX|s�t
j�}t	j
d|�tjj||�S)
a�
    Return the default base location for distlib caches. If the directory does
    not exist, it is created. Use the suffix provided for the base directory,
    and default to '.distlib' if it isn't provided.

    On Windows, if LOCALAPPDATA is defined in the environment, then it is
    assumed to be a directory, and will be the parent directory of the result.
    On POSIX, and on Windows if LOCALAPPDATA is not defined, the user's home
    directory - using os.expanduser('~') - will be the parent directory of
    the result.

    The result is just the directory '.distlib' in the parent directory as
    determined above, or with the name specified with ``suffix``.
    Nz.distlib�ntZLOCALAPPDATAz
$localappdata�~z(Directory exists but is not writable: %sTzUnable to create %s)�exc_infoFz#Default location unusable, using %s)r9r'�environr:�
expandvars�
expanduserr�r�r�r��warning�makedirs�OSErrorr|r}r0)rDr4Zusabler!r!r"�get_cache_baseVs&

r�cCsBtjjtjj|��\}}|r(|jdd�}|jtjd�}||dS)a
    Convert an absolute path to a directory name for use in a cache.

    The algorithm used is:

    #. On Windows, any ``':'`` in the drive is replaced with ``'---'``.
    #. Any occurrence of ``os.sep`` is replaced with ``'--'``.
    #. ``'.cache'`` is appended.
    r�z---z--z.cache)r9r:�
splitdriver�r8r;)r:r rTr!r!r"�path_to_cache_dirs

r�cCs|jd�s|dS|S)Nr7)�endswith)r3r!r!r"�ensure_slash�s
r�cCsHd}}d|kr>|jdd�\}}d|kr.|}n|jdd�\}}|||fS)N�@rr�)r2)ZnetlocZusernameZpasswordrFr!r!r"�parse_credentials�srcCstjd�}tj|�|S)N�)r9�umask)r4r!r!r"�get_process_umask�s

rcCs>d}d}x$t|�D]\}}t|t�sd}PqW|dk	s:t�|S)NTF)�	enumeraterOrr=)�seqr4�ir3r!r!r"�is_string_sequence�s
rz3([a-z0-9_]+([.-][a-z_][a-z0-9_]*)*)-([a-z0-9_.+-]+)z
-py(\d\.?\d?)cCs�d}d}t|�jdd�}tj|�}|r@|jd�}|d|j��}|r�t|�t|�dkr�tjtj	|�d|�}|r�|j
�}|d|�||dd�|f}|dkr�tj|�}|r�|jd�|jd�|f}|S)zw
    Extract name, version, python version from a filename (no extension)

    Return name, version, pyver or None
    N� �-rz\brZ)rr8�PYTHON_VERSIONr�rp�startr>�rer,�escape�end�PROJECT_NAME_AND_VERSION)�filenameZproject_namer4Zpyverr�nr!r!r"�split_filename�s"


rz-(?P<name>[\w .-]+)\s*\(\s*(?P<ver>[^\s)]+)\)$cCs:tj|�}|std|��|j�}|dj�j�|dfS)z�
    A utility method used to get name and version from a string.

    From e.g. a Provides-Dist value.

    :param p: A value in a form 'foo (1.0)'
    :return: The name and version as a tuple.
    z$Ill-formed name/version string: '%s'r'Zver)�NAME_VERSION_REr,rrr-rQ)rTrr r!r!r"�parse_name_and_version�s
	
rcCs�t�}t|pg�}t|pg�}d|kr8|jd�||O}x�|D]x}|dkrV|j|�q>|jd�r�|dd�}||kr�tjd|�||kr�|j|�q>||kr�tjd|�|j|�q>W|S)N�*r
rzundeclared extra: %s)ryr�r�r<r�r�)Z	requestedZ	availabler4�rZunwantedr!r!r"�
get_extras�s&


rcCs�i}yNt|�}|j�}|jd�}|jd�s8tjd|�ntjd�|�}tj	|�}Wn0t
k
r�}ztjd||�WYdd}~XnX|S)NzContent-Typezapplication/jsonz(Unexpected response for JSON request: %szutf-8z&Failed to get external data for %s: %s)rr��getr<r�r�rbrcrerfri�	exception)r*r4ZrespZheadersZct�reader�er!r!r"�_get_external_data�s

 rz'https://www.red-dove.com/pypi/projects/cCs*d|dj�|f}tt|�}t|�}|S)Nz%s/%s/project.jsonr)�upperr
�_external_data_base_urlr)r'r*r4r!r!r"�get_project_datas
r cCs(d|dj�||f}tt|�}t|�S)Nz%s/%s/package-%s.jsonr)rr
rr)r'�versionr*r!r!r"�get_package_datas
r"c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�Cachez�
    A class implementing a cache for resources that need to live in the file system
    e.g. shared libraries. This class was moved from resources to here because it
    could be used by other modules, e.g. the wheel module.
    cCsPtjj|�stj|�tj|�jd@dkr6tjd|�tjjtjj	|��|_
dS)zu
        Initialise an instance.

        :param base: The base directory where the cache should be located.
        �?rzDirectory '%s' is not privateN)r9r:r�r�r�r�r�r�r��normpathr@)r�r@r!r!r"r�"s

zCache.__init__cCst|�S)zN
        Converts a resource prefix to a directory name in the cache.
        )r�)r�rFr!r!r"�
prefix_to_dir0szCache.prefix_to_dircCs�g}x�tj|j�D]r}tjj|j|�}y>tjj|�s@tjj|�rLtj|�ntjj|�rbt	j
|�Wqtk
r�|j|�YqXqW|S)z"
        Clear the cache.
        )
r9r�r@r:r0r�r�r�r�rr~ri�append)r�Znot_removed�fnr!r!r"�clear6szCache.clearN)r�r�r��__doc__r�r&r)r!r!r!r"r#sr#c@s:eZdZdZdd�Zddd�Zdd�Zd	d
�Zdd�Zd
S)�
EventMixinz1
    A very simple publish/subscribe system.
    cCs
i|_dS)N)�_subscribers)r�r!r!r"r�KszEventMixin.__init__TcCsD|j}||krt|g�||<n"||}|r6|j|�n
|j|�dS)a`
        Add a subscriber for an event.

        :param event: The name of an event.
        :param subscriber: The subscriber to be added (and called when the
                           event is published).
        :param append: Whether to append or prepend the subscriber to an
                       existing subscriber list for the event.
        N)r,rr'�
appendleft)r��event�
subscriberr'�subsZsqr!r!r"r�Ns
zEventMixin.addcCs,|j}||krtd|��||j|�dS)z�
        Remove a subscriber for an event.

        :param event: The name of an event.
        :param subscriber: The subscriber to be removed.
        zNo subscribers: %rN)r,r�r�)r�r.r/r0r!r!r"r�bszEventMixin.removecCst|jj|f��S)z�
        Return an iterator for the subscribers for an event.
        :param event: The event to return subscribers for.
        )�iterr,r)r�r.r!r!r"�get_subscribersnszEventMixin.get_subscriberscOspg}xT|j|�D]F}y||f|�|�}Wn"tk
rJtjd�d}YnX|j|�qWtjd||||�|S)a^
        Publish a event and return a list of values returned by its
        subscribers.

        :param event: The event to publish.
        :param args: The positional arguments to pass to the event's
                     subscribers.
        :param kwargs: The keyword arguments to pass to the event's
                       subscribers.
        z"Exception during event publicationNz/publish %s: args = %s, kwargs = %s, result = %s)r2rir�rr'r�)r�r.�args�kwargsr4r/rtr!r!r"�publishus

zEventMixin.publishN)T)	r�r�r�r*r�r�r�r2r5r!r!r!r"r+Gs
r+c@s^eZdZdd�Zdd�Zddd�Zdd	�Zd
d�Zdd
�Zdd�Z	e
dd��Ze
dd��ZdS)�	SequencercCsi|_i|_t�|_dS)N)�_preds�_succsry�_nodes)r�r!r!r"r��szSequencer.__init__cCs|jj|�dS)N)r9r�)r��noder!r!r"�add_node�szSequencer.add_nodeFcCs�||jkr|jj|�|r�x&t|jj|f��D]}|j||�q.Wx&t|jj|f��D]}|j||�qVWx&t|jj��D]\}}|sz|j|=qzWx&t|jj��D]\}}|s�|j|=q�WdS)N)r9r�ryr7rr8r�rg)r�r:ZedgesrTr3rqrrr!r!r"�remove_node�s
zSequencer.remove_nodecCs<||kst�|jj|t��j|�|jj|t��j|�dS)N)r=r7�
setdefaultryr�r8)r��pred�succr!r!r"r��sz
Sequencer.addcCs�||kst�y|j|}|j|}Wn tk
rDtd|��YnXy|j|�|j|�Wn$tk
r�td||f��YnXdS)Nz%r not a successor of anythingz%r not a successor of %r)r=r7r8�KeyErrorr�r�)r�r>r?�predsZsuccsr!r!r"r��s

zSequencer.removecCs||jkp||jkp||jkS)N)r7r8r9)r��stepr!r!r"�is_step�szSequencer.is_stepcCs�|j|�std|��g}g}t�}|j|�xd|r�|jd�}||krd||kr�|j|�|j|�q0|j|�|j|�|jj|f�}|j	|�q0Wt
|�S)NzUnknown: %rr)rCr�ryr'rBr�r�r7r�extend�reversed)r��finalr4Ztodo�seenrBrAr!r!r"�	get_steps�s"





zSequencer.get_stepscsVdg�g�i�i�g�|j��������fdd��x�D]}|�kr:�|�q:W�S)Nrc
s��d�|<�d�|<�dd7<�j|�y�|}Wntk
rVg}YnXxR|D]J}|�kr��|�t�|�|��|<q^|�kr^t�|�|��|<q^W�|�|kr�g}x �j�}|j|�||kr�Pq�Wt|�}�j|�dS)Nrr)r'ri�minrB�tuple)r:Z
successorsZ	successorZconnected_componentZ	component)�graph�index�
index_counter�lowlinksr4�stack�
strongconnectr!r"rP�s.



z3Sequencer.strong_connections.<locals>.strongconnect)r8)r�r:r!)rKrLrMrNr4rOrPr"�strong_connections�s"
zSequencer.strong_connectionscCsrdg}x8|jD].}|j|}x|D]}|jd||f�q"WqWx|jD]}|jd|�qHW|jd�dj|�S)Nzdigraph G {z  %s -> %s;z  %s;�}�
)r7r'r9r0)r�r4r?rAr>r:r!r!r"�dot
s


z
Sequencer.dotN)F)
r�r�r�r�r;r<r�r�rCrH�propertyrQrTr!r!r!r"r6�s

3r6�.tar.gz�.tar.bz2�.tar�.zip�.tgz�.tbz�.whlTc
sf��fdd�}tjj���t���d}|dkr�|jd�r>d}nH|jd�rRd}d	}n4|jd�rfd}d
}n |jd�rzd}d}ntd|��z�|dkr�t|d�}|r�|j�}xD|D]}||�q�Wn.tj	||�}|r�|j
�}x|D]}||�q�W|dk�r6tjddk�r6x.|j
�D]"}	t|	jt��s|	jjd�|	_�qWdd�}
|
|_|j��Wd|�r`|j�XdS)NcsTt|t�s|jd�}tjjtjj�|��}|j��sD|�tjkrPt	d|��dS)Nzutf-8zpath outside destination: %r)
rOr�decoder9r:r�r0r<r;r�)r:rT)�dest_dir�plenr!r"�
check_paths


zunarchive.<locals>.check_path�.zip�.whl�zip�.tar.gz�.tgzZtgzzr:gz�.tar.bz2�.tbzZtbzzr:bz2z.tarZtarrzUnknown format for %rrrZzutf-8cSsBytj||�Stjk
r<}ztt|���WYdd}~XnXdS)z:Run tarfile.tar_fillter, but raise the expected ValueErrorN)�tarfileZ
tar_filterZFilterErrorr��str)�memberr:�excr!r!r"�extraction_filterPsz$unarchive.<locals>.extraction_filter)rarb)rdre)rfrg)r9r:r�r>r�r�rZnamelistrhr�ZgetnamesrJraZ
getmembersrOr'rr]rlZ
extractallrl)Zarchive_filenamer^�formatr�r`�archiver��namesr'Ztarinforlr!)r^r_r"�	unarchivesL






rpcCs�tj�}t|�}t|d��b}xZtj|�D]L\}}}x@|D]8}tjj||�}||d�}	tjj|	|�}
|j||
�q8Wq(WWdQRX|S)z*zip a directory tree into a BytesIO objectr�N)	�io�BytesIOr>rr9�walkr:r0rz)Z	directoryr4ZdlenZzf�rootr�r�r'ZfullZrelrEr!r!r"�zip_dir`s
rur$�K�M�G�T�Pc@sreZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Ze	dd��Z
e	dd��Zdd�Ze	dd��Z
e	dd��ZdS)�ProgressZUNKNOWNr�dcCs<|dks||kst�||_|_||_d|_d|_d|_dS)NrF)r=rI�cur�max�started�elapsed�done)r�ZminvalZmaxvalr!r!r"r�wszProgress.__init__cCsV|j|kst�|jdks&||jks&t�||_tj�}|jdkrF||_n||j|_dS)N)rIr=r~r}�timerr�)r�ZcurvalZnowr!r!r"�updates
zProgress.updatecCs |dkst�|j|j|�dS)Nr)r=r�r})r�Zincrr!r!r"�	increment�szProgress.incrementcCs|j|j�|S)N)r�rI)r�r!r!r"r�szProgress.startcCs |jdk	r|j|j�d|_dS)NT)r~r�r�)r�r!r!r"�stop�s
z
Progress.stopcCs|jdkr|jS|jS)N)r~�unknown)r�r!r!r"�maximum�szProgress.maximumcCsD|jrd}n4|jdkrd}n$d|j|j|j|j}d|}|S)Nz100 %z ?? %gY@z%3d %%)r�r~r}rI)r�r4rrr!r!r"�
percentage�s
zProgress.percentagecCs:|dkr|jdks|j|jkr$d}ntjdtj|��}|S)Nrz??:??:??z%H:%M:%S)r~r}rIr�ZstrftimeZgmtime)r�Zdurationr4r!r!r"�format_duration�szProgress.format_durationcCs�|jrd}|j}n^d}|jdkr&d}nJ|jdks<|j|jkrBd}n.t|j|j�}||j|j}|d|j}d||j|�fS)NZDonezETA rrz%s: %sr�)r�r�r~r}rI�floatr�)r�rF�tr!r!r"�ETA�s
zProgress.ETAcCsN|jdkrd}n|j|j|j}xtD]}|dkr6P|d}q(Wd||fS)Nrgi�g@�@z%d %sB/s)r�r}rI�UNITS)r�r4Zunitr!r!r"�speed�s

zProgress.speedN)rr|)r�r�r�r�r�r�r�rr�rUr�r�r�r�r�r!r!r!r"r{ts

	r{z\{([^}]*)\}z[^/\\,{]\*\*|\*\*[^/\\,}]z^[^{]*\}|\{[^}]*$cCs<tj|�rd}t||��tj|�r4d}t||��t|�S)zAExtended globbing function that supports ** and {opt1,opt2,opt3}.z7invalid glob %r: recursive glob "**" must be used alonez2invalid glob %r: mismatching set marker '{' or '}')�_CHECK_RECURSIVE_GLOBr�r��_CHECK_MISMATCH_SET�_iglob)�	path_globr�r!r!r"r�s

rccstj|d�}t|�dkrpt|�dks,t|��|\}}}x�|jd�D](}x"tdj|||f��D]
}|Vq\WqBWn�d|kr�x�t|�D]
}|Vq�Wn�|jdd�\}}|dkr�d}|dkr�d}n|jd�}|jd	�}xHtj	|�D]:\}}}	tj
j|�}x"ttj
j||��D]}
|
V�qWq�WdS)
NrrZr�r$z**r�rr7�\)�	RICH_GLOBr2r>r=r�r0�	std_iglobr?r9rsr:r%)r�Zrich_path_globrFryrD�itemr:Zradical�dirr�r(r!r!r"r��s*


r�)�HTTPSHandler�match_hostname�CertificateErrorc@seZdZdZdZdd�ZdS)�HTTPSConnectionNTcCsPtj|j|jf|j�}t|dd�r0||_|j�tt	d�sp|j
rHt	j}nt	j}t	j
||j|j|t	j|j
d�|_nxt	jt	j�}|jt	jO_|jr�|j|j|j�i}|j
r�t	j|_|j|j
d�tt	dd�r�|j|d<|j
|f|�|_|j
o�|j�rLy$t|jj�|j�tjd|j�Wn0tk
�rJ|jjtj�|jj��YnXdS)	NZ_tunnel_hostF�
SSLContext)�	cert_reqsZssl_version�ca_certs)ZcafileZHAS_SNIZserver_hostnamezHost verified: %s) r�Zcreate_connection�host�port�timeoutrK�sockZ_tunnelrI�sslr�Z
CERT_REQUIREDZ	CERT_NONEZwrap_socketZkey_fileZ	cert_fileZPROTOCOL_SSLv23r�ZoptionsZOP_NO_SSLv2Zload_cert_chainZverify_modeZload_verify_locations�check_domainr�Zgetpeercertr�r�r�ZshutdownZ	SHUT_RDWRrl)r�r�r��contextr4r!r!r"�connect
s>


zHTTPSConnection.connect)r�r�r�r�r�r�r!r!r!r"r�sr�c@s&eZdZd	dd�Zdd�Zdd�ZdS)
r�TcCstj|�||_||_dS)N)�BaseHTTPSHandlerr�r�r�)r�r�r�r!r!r"r�0s
zHTTPSHandler.__init__cOs$t||�}|jr |j|_|j|_|S)a
            This is called to create a connection instance. Normally you'd
            pass a connection class to do_open, but it doesn't actually check for
            a class, and just expects a callable. As long as we behave just as a
            constructor would have, we should be OK. If it ever changes so that
            we *must* pass a class, we'll create an UnsafeHTTPSConnection class
            which just sets check_domain to False in the class definition, and
            choose which one to pass to do_open.
            )r�r�r�)r�r3r4r4r!r!r"�_conn_maker5s


zHTTPSHandler._conn_makercCsVy|j|j|�Stk
rP}z&dt|j�kr>td|j��n�WYdd}~XnXdS)Nzcertificate verify failedz*Unable to verify server certificate for %s)Zdo_openr�rri�reasonr�r�)r��reqrr!r!r"�
https_openEszHTTPSHandler.https_openN)T)r�r�r�r�r�r�r!r!r!r"r�/s
r�c@seZdZdd�ZdS)�HTTPSOnlyHandlercCstd|��dS)NzAUnexpected HTTP request on what should be a secure connection: %s)r)r�r�r!r!r"�	http_openYszHTTPSOnlyHandler.http_openN)r�r�r�r�r!r!r!r"r�Xsr���c@seZdZddd�ZdS)�HTTPr$NcKs&|dkrd}|j|j||f|��dS)Nr)�_setup�_connection_class)r�r�r�r4r!r!r"r�esz
HTTP.__init__)r$N)r�r�r�r�r!r!r!r"r�dsr�c@seZdZddd�ZdS)�HTTPSr$NcKs&|dkrd}|j|j||f|��dS)Nr)r�r�)r�r�r�r4r!r!r"r�mszHTTPS.__init__)r$N)r�r�r�r�r!r!r!r"r�lsr�c@seZdZddd�Zdd�ZdS)�	TransportrcCs||_tjj||�dS)N)r�rr�r�)r�r��use_datetimer!r!r"r�tszTransport.__init__cCsb|j|�\}}}tdkr(t||jd�}n6|js>||jdkrT||_|tj|�f|_|jd}|S)Nr�r�)r�rr)r�r�)�
get_host_info�	_ver_infor�r��_connection�_extra_headersrZHTTPConnection)r�r��h�ehZx509r4r!r!r"�make_connectionxs
zTransport.make_connectionN)r)r�r�r�r�r�r!r!r!r"r�ss
r�c@seZdZddd�Zdd�ZdS)�
SafeTransportrcCs||_tjj||�dS)N)r�rr�r�)r�r�r�r!r!r"r��szSafeTransport.__init__cCsz|j|�\}}}|si}|j|d<tdkr:t|df|�}n<|jsP||jdkrl||_|tj|df|�f|_|jd}|S)Nr�r�r�rr)r�r�)r�r�r�r�r�r�rr�)r�r�r�r�r4r4r!r!r"r��s


zSafeTransport.make_connectionN)r)r�r�r�r�r�r!r!r!r"r��s
r�c@seZdZdd�ZdS)�ServerProxyc	Kst|jdd�|_}|dk	r^t|�\}}|jdd�}|dkr@t}nt}|||d�|d<}||_tjj	||f|�dS)Nr�r�rZhttps)r��	transport)
rBr�rrr�r�r�rr�r�)	r�Zurir4r��scheme�_r�Ztclsr�r!r!r"r��szServerProxy.__init__N)r�r�r�r�r!r!r!r"r��sr�cKs.tjddkr|d7}nd|d<t||f|�S)NrrZ�br$�newline)rJrar�)r(r�r4r!r!r"�	_csv_open�s
r�c@s4eZdZed�ed�ed�d�Zdd�Zdd�Zd	S)
�CSVBaser��"rS)Z	delimiterZ	quotecharZlineterminatorcCs|S)Nr!)r�r!r!r"�	__enter__�szCSVBase.__enter__cGs|jj�dS)N)r_rl)r�r�r!r!r"�__exit__�szCSVBase.__exit__N)r�r�r�ri�defaultsr�r�r!r!r!r"r��s
r�c@s(eZdZdd�Zdd�Zdd�ZeZdS)�	CSVReadercKs\d|kr4|d}tjddkr,tjd�|�}||_nt|dd�|_tj|jf|j�|_dS)Nr_rrZzutf-8r:r)	rJrarbrcr_r��csvrr�)r�r4r_r!r!r"r��szCSVReader.__init__cCs|S)Nr!)r�r!r!r"�__iter__�szCSVReader.__iter__cCsJt|j�}tjddkrFx,t|�D] \}}t|t�s"|jd�||<q"W|S)NrrZzutf-8)�nextrrJrarrOrr])r�r4rr�r!r!r"r��s

zCSVReader.nextN)r�r�r�r�r�r��__next__r!r!r!r"r��sr�c@seZdZdd�Zdd�ZdS)�	CSVWritercKs$t|d�|_tj|jf|j�|_dS)Nr�)r�r_r��writerr�)r�r(r4r!r!r"r��szCSVWriter.__init__cCsRtjddkrBg}x*|D]"}t|t�r0|jd�}|j|�qW|}|jj|�dS)NrrZzutf-8)rJrarOrr�r'r��writerow)r��rowrr�r!r!r"r��s


zCSVWriter.writerowN)r�r�r�r�r�r!r!r!r"r��sr�csHeZdZeej�Zded<d�fdd�	Zdd�Zdd	�Zd
d�Z	�Z
S)
�Configurator�inc_convertZincNcs"tt|�j|�|ptj�|_dS)N)�superr�r�r9r�r@)r��configr@)�	__class__r!r"r��szConfigurator.__init__c
s���fdd���jd�}t|�s*�j|�}�jdd�}�jdf�}|r\t�fdd�|D��}��fdd��D�}t|�}|||�}|r�x$|j�D]\}}	t||�|	��q�W|S)	Ncszt|ttf�r*t|��fdd�|D��}nLt|t�rld|krH�j|�}qvi}x(|D]}�||�||<qRWn
�j|�}|S)Ncsg|]}�|��qSr!r!)r%r)�convertr!r"r&�szBConfigurator.configure_custom.<locals>.convert.<locals>.<listcomp>z())rOr�rJ�type�dict�configure_customr�)�or4rq)r�r�r!r"r��s


z.Configurator.configure_custom.<locals>.convertz()r�z[]csg|]}�|��qSr!r!)r%r�)r�r!r"r&sz1Configurator.configure_custom.<locals>.<listcomp>cs$g|]}t|�r|��|�f�qSr!)r)r%rq)r�r�r!r"r&s)rBr�r�rJr�rg�setattr)
r�r�rUZpropsr3rgr4r4rrrr!)r�r�r�r"r��s


zConfigurator.configure_customcCs4|j|}t|t�r0d|kr0|j|�|j|<}|S)Nz())r�rOr�r�)r�rXr4r!r!r"�__getitem__s
zConfigurator.__getitem__c	CsFtjj|�stjj|j|�}tj|ddd��}tj|�}WdQRX|S)z*Default converter for the inc:// protocol.rzutf-8)r�N)	r9r:�isabsr0r@rbr�rerf)r�rtr�r4r!r!r"r�s
zConfigurator.inc_convert)N)r�r�r�r�rZvalue_convertersr�r�r�r��
__classcell__r!r!)r�r"r��s
r�c@s&eZdZd	dd�Zdd�Zdd�ZdS)
�SubprocessMixinFNcCs||_||_dS)N)�verbose�progress)r�r�r�r!r!r"r�+szSubprocessMixin.__init__cCsn|j}|j}xT|j�}|sP|dk	r0|||�q|sBtjjd�ntjj|jd��tjj�qW|j�dS)z�
        Read lines from a subprocess' output stream and either pass to a progress
        callable (if specified) or write progress information to sys.stderr.
        Nr�zutf-8)	r�r��readlinerJ�stderrrzr]�flushrl)r�r_r�r�r�r3r!r!r"r/szSubprocessMixin.readercKs�tj|ftjtjd�|��}tj|j|jdfd�}|j�tj|j|jdfd�}|j�|j	�|j
�|j
�|jdk	r�|jdd�n|jr�t
jjd�|S)N)�stdoutr�r�)r�r3r�zdone.�mainzdone.
)�
subprocess�Popen�PIPE�	threadingZThreadrr�rr��waitr0r�r�rJrz)r��cmdr4rTZt1Zt2r!r!r"�run_commandDs
zSubprocessMixin.run_command)FN)r�r�r�r�rr�r!r!r!r"r�*s
r�cCstjdd|�j�S)z,Normalize a python package name a la PEP 503z[-_.]+r
)r
�subrQ)r'r!r!r"�normalize_nameUsr�)NN)r�)N)N)rVrWrXrYrZr[r\)NT)r$rvrwrxryrz)r�r�)�rb�collectionsr�
contextlibr�Zglobrr�rqreZloggingr9r�r
rr�r��ImportErrorr�rJrhr|rmr�Zdummy_threadingr�r$r�compatrrr	r
rrr
rrrrrrrrrrrrZ	getLoggerr�r��COMMAr�r1ZIDENTZEXTRA_IDENTZVERSPECZRELOPZBARE_CONSTRAINTSZ
DIRECT_REFZCONSTRAINTSZ
EXTRA_LISTZEXTRASZREQUIREMENTr+ZRELOP_IDENTr.r6rGrLrPrVrYrur{�contextmanagerrr�r�r�r�r�r�r�r��VERBOSEr�rhr�r�r�rrr�Irrrrrrrrr r"r#r+r6ZARCHIVE_EXTENSIONSrprur�r{r�r�r�r�r�r�r�r�r�r�rar�r�r�r�r�r�r�r�r�r�r�r�r�r!r!r!r"�<module>s�
X

,

%

	/
	7

)



,H
C]


*)	
:+
© 2025 GrazzMean