HEX
Server: LiteSpeed
System: Linux standart9.isimtescil.net 3.10.0-962.3.2.lve1.5.26.7.el7.x86_64 #1 SMP Wed Oct 2 07:53:12 EDT 2019 x86_64
User: karalev (5310)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //opt/alt/python35/lib/python3.5/site-packages/setuptools/__pycache__/sandbox.cpython-35.opt-1.pyc


i�Re�8�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZddlZejjd�r�ddljjjjZnejejZy
eZWnek
rdZYnXeZddlm Z ddlm!Z!ddd	d
gZ"ddd�Z#ej$dd
d��Z%ej$dd��Z&ej$dd��Z'ej$dd��Z(Gdd�de)�Z*Gdd�d�Z+ej$dd��Z,dd�Z-ej$dd��Z.ej$dd ��Z/d!d"�Z0d#d$�Z1d%d
�Z2Gd&d�d�Z3e4ed'�rsej5gZ6ngZ6Gd(d�de3�Z7ej8ej9d)d*�d+j:�D��Z;Gd,d	�d	e �Z<dS)-�N)�six)�builtins�map�java)�DistutilsError)�working_set�AbstractSandbox�DirectorySandbox�SandboxViolation�	run_setupcCs�d}t||��}|j�}WdQRXtjdd�dksvtjdd�dkr�tjdd�d
kr�|jdd�}|jd	d�}|dkr�|}t||d
�}t|||�dS)z.
    Python 3 implementation of execfile.
    �rbN���rs
s
s
�exec)r
r)rr)rr
)�open�read�sys�version_info�replace�compiler)�filename�globals�locals�mode�streamZscript�code�r�/sandbox.py�	_execfile#sKrc
csVtjdd�}|dk	r2|tjdd�<z	|VWd|tjdd�<XdS)N)r�argv)�repl�savedrrr�	save_argv4s	r#c
cs7tjdd�}z	|VWd|tjdd�<XdS)N)r�path)r"rrr�	save_path?s	r%ccsBtjj|dd�tj}|t_z	dVWd|t_XdS)zL
    Monkey-patch tempfile.tempdir with replacement, ensuring it exists
    �exist_okTN)�
pkg_resourcesZ
py31compat�makedirs�tempfile�tempdir)Zreplacementr"rrr�
override_tempHs			r+ccs7tj�}tj|�z	|VWdtj|�XdS)N)�os�getcwd�chdir)�targetr"rrr�pushdYs

	r0c@s(eZdZdZedd��ZdS)�UnpickleableExceptionzP
    An exception representing another Exception that could not be pickled.
    cCsey tj|�tj|�fSWn>tk
r`ddlm}|j||t|���SYnXdS)z�
        Always return a dumped (pickled) type and exc. If exc can't be pickled,
        wrap it in UnpickleableException first.
        r)r1N)�pickle�dumps�	Exception�setuptools.sandboxr1�dump�repr)�type�exc�clsrrrr6hs
 
zUnpickleableException.dumpN)�__name__�
__module__�__qualname__�__doc__�staticmethodr6rrrrr1csr1c@s:eZdZdZdd�Zdd�Zdd�ZdS)	�ExceptionSaverz^
    A Context Manager that will save an exception, serialized, and restore it
    later.
    cCs|S)Nr)�selfrrr�	__enter__|szExceptionSaver.__enter__cCs,|s
dStj||�|_||_dS)NT)r1r6�_saved�_tb)rAr8r9�tbrrr�__exit__s
	zExceptionSaver.__exit__cCsKdt|�krdSttj|j�\}}tj|||j�dS)z"restore and re-raise any exceptionrCN)�varsrr2�loadsrCrZreraiserD)rAr8r9rrr�resume�szExceptionSaver.resumeN)r;r<r=r>rBrFrIrrrrr@vsr@c
#sktjj��t��}�VWdQRXtjj���fdd�tjD�}t|�|j�dS)z�
    Context in which imported modules are saved.

    Translates exceptions internal to the context into the equivalent exception
    outside the context.
    Nc3s1|]'}|�kr|jd�r|VqdS)z
encodings.N)�
startswith)�.0�mod_name)r"rr�	<genexpr>�szsave_modules.<locals>.<genexpr>)r�modules�copyr@�update�_clear_modulesrI)�	saved_excZdel_modulesr)r"r�save_modules�s
rScCs%xt|�D]}tj|=q
WdS)N)�listrrN)�module_namesrLrrrrQ�srQccs*tj�}z	|VWdtj|�XdS)N)r'�__getstate__�__setstate__)r"rrr�save_pkg_resources_state�s	rXc,cs�tjj|d�}t��vt��et�t��Mt��<t|��(t	|��t
d�dVWdQRXWdQRXWdQRXWdQRXWdQRXWdQRXdS)NZtempZ
setuptools)r,r$�joinrXrS�hide_setuptoolsr%r#r+r0�
__import__)�	setup_dirZtemp_dirrrr�
setup_context�s






r]cCs"tjd�}t|j|��S)aH
    >>> _needs_hiding('setuptools')
    True
    >>> _needs_hiding('pkg_resources')
    True
    >>> _needs_hiding('setuptools_plugin')
    False
    >>> _needs_hiding('setuptools.__init__')
    True
    >>> _needs_hiding('distutils')
    True
    >>> _needs_hiding('os')
    False
    >>> _needs_hiding('Cython')
    True
    z1(setuptools|pkg_resources|distutils|Cython)(\.|$))�rer�bool�match)rL�patternrrr�
_needs_hiding�srbcCs tttj�}t|�dS)a%
    Remove references to setuptools' modules from sys.modules to allow the
    invocation to import the most appropriate setuptools. This technique is
    necessary to avoid issues such as #315 where setuptools upgrading itself
    would fail to find a function declared in the metadata.
    N)�filterrbrrNrQ)rNrrrrZ�srZcCs.tjjtjj|��}t|���y�|gt|�tjdd�<tjjd|�t	j
�t	jjdd��t
|t�r�|n|jtj��}t|��'td|dd�}t||�WdQRXWn>tk
r"}z|jr|jdr�WYdd}~XnXWdQRXdS)z8Run a distutils setup script, sandboxed in its directoryNrcSs
|j�S)N)Zactivate)Zdistrrr�<lambda>�szrun_setup.<locals>.<lambda>�__file__r;�__main__)r,r$�abspath�dirnamer]rTrr �insertr�__init__Z	callbacks�append�
isinstance�str�encode�getfilesystemencodingr	�dictr�
SystemExit�args)Zsetup_scriptrrr\Zdunder_file�ns�vrrrr�s
 

c@s�eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
x9dddgD](Zee
e�rpe
e�e�e<qpWddd�Zer�ede�Zede�Zxiddddddddddd d!d"d#d$d%d&d'd(gD](Zee
e�ree�e�e<qWd)d*�Zx6d+d,gD](Zee
e�rTee�e�e<qTWd-d.�Zx6d/d0gD](Zee
e�r�ee�e�e<q�Wd1d2�Zd3d4�Zd5d6�Zd7d8�ZdS)9rzDWrap 'os' module and 'open()' builtin for virtualizing setup scriptsFcs&�fdd�tt�D��_dS)Ncs5g|]+}|jd�rt�|�r|�qS)�_)rJ�hasattr)rK�name)rArr�
<listcomp>s	z,AbstractSandbox.__init__.<locals>.<listcomp>)�dir�_os�_attrs)rAr)rArrj
szAbstractSandbox.__init__cCs1x*|jD]}tt|t||��q
WdS)N)r{�setattrr,�getattr)rA�sourcerwrrr�_copyszAbstractSandbox._copycCs8|j|�tr|jt_|jt_d|_dS)NT)r�_filer�file�_openr�_active)rArrrrBs

zAbstractSandbox.__enter__cCs2d|_trtt_tt_|jt�dS)NF)r�r�rr�r�rrrz)rA�exc_type�	exc_value�	tracebackrrrrFs
			zAbstractSandbox.__exit__c	Cs|�|�SWdQRXdS)zRun 'func' under os sandboxingNr)rA�funcrrr�run"szAbstractSandbox.runcs(tt�����fdd�}|S)Ncs=|jr*|j�||||�\}}�||||�S)N)r��_remap_pair)rA�src�dstrr�kw)rw�originalrr�wrap*s	!z3AbstractSandbox._mk_dual_path_wrapper.<locals>.wrap)r}rz)rwr�r)rwr�r�_mk_dual_path_wrapper'sz%AbstractSandbox._mk_dual_path_wrapper�rename�link�symlinkNcs.�ptt�����fdd�}|S)Ncs1|jr!|j�|||�}�|||�S)N)r��_remap_input)rAr$rrr�)rwr�rrr�8s	z5AbstractSandbox._mk_single_path_wrapper.<locals>.wrap)r}rz)rwr�r�r)rwr�r�_mk_single_path_wrapper5sz'AbstractSandbox._mk_single_path_wrapperr�r�stat�listdirr.�chmod�chown�mkdir�remove�unlink�rmdir�utime�lchown�chroot�lstatZ	startfile�mkfifo�mknod�pathconf�accesscs(tt�����fdd�}|S)NcsM|jr=|j�|||�}|j��|||��S�|||�S)N)r�r��
_remap_output)rAr$rrr�)rwr�rrr�Ms	z4AbstractSandbox._mk_single_with_return.<locals>.wrap)r}rz)rwr�r)rwr�r�_mk_single_with_returnJsz&AbstractSandbox._mk_single_with_return�readlink�tempnamcs(tt�����fdd�}|S)Ncs,�||�}|jr(|j�|�S|S)N)r�r�)rArrr�Zretval)rwr�rrr�\s	z'AbstractSandbox._mk_query.<locals>.wrap)r}rz)rwr�r)rwr�r�	_mk_queryYszAbstractSandbox._mk_queryr-�tmpnamcCs|S)z=Called to remap or validate any path, whether input or outputr)rAr$rrr�_validate_pathhszAbstractSandbox._validate_pathcOs
|j|�S)zCalled for path inputs)r�)rA�	operationr$rrr�rrrr�lszAbstractSandbox._remap_inputcCs
|j|�S)zCalled for path outputs)r�)rAr�r$rrrr�pszAbstractSandbox._remap_outputcOs6|j|d|||�|j|d|||�fS)z?Called for path pairs like rename, link, and symlink operationsz-fromz-to)r�)rAr�r�r�rrr�rrrr�tszAbstractSandbox._remap_pair)r;r<r=r>r�rjrrBrFr�r�rwrvrzrr�r�r�r�r�r�r�r�r�rrrrrsB

�devnullc@s�eZdZdZejdddddddd	d
ddd
dg
�ZdgZedd�Z	dd�Z
er�ddd�Zddd�Zdd�Z
dd�Zdd�Zdd �Zd!d"�Zd#d$d%�Zd&S)'r	z<Restrict operations to a single subdirectory - pseudo-chrootrr�r�r�r�r�r�r�r�r�r�r�r�z.*lib2to3.*\.pickle$cCsctjjtjj|��|_tjj|jd�|_dd�|D�|_tj	|�dS)N�cSs.g|]$}tjjtjj|���qSr)r,r$�normcase�realpath)rKr$rrrrx�s	z-DirectorySandbox.__init__.<locals>.<listcomp>)
r,r$r�r��_sandboxrY�_prefix�_exceptionsrrj)rAZsandbox�
exceptionsrrrrj�s
!	
zDirectorySandbox.__init__cOs&ddlm}||||��dS)Nr)r
)r5r
)rAr�rrr�r
rrr�
_violation�szDirectorySandbox._violation�rcOsH|dkr5|j|�r5|jd||||�t||||�S)Nr��rtr�rU�Ur�)r�r�rr�r�)�_okr�r�)rAr$rrrr�rrrr��szDirectorySandbox._filecOsH|dkr5|j|�r5|jd||||�t||||�S)Nr�r�rr�r�r)r�r�rr�r�)r�r�r�)rAr$rrrr�rrrr��szDirectorySandbox._opencCs|jd�dS)Nr�)r�)rArrrr��szDirectorySandbox.tmpnamcCss|j}zYd|_tjjtjj|��}|j|�p`||jkp`|j|j�SWd||_XdS)NF)	r�r,r$r�r��	_exemptedr�rJr�)rAr$Zactiver�rrrr��s		zDirectorySandbox._okcsT�fdd�|jD�}�fdd�|jD�}tj||�}t|�S)Nc3s|]}�j|�VqdS)N)rJ)rK�	exception)�filepathrrrM�sz-DirectorySandbox._exempted.<locals>.<genexpr>c3s!|]}tj|��VqdS)N)r^r`)rKra)r�rrrM�s)r��_exception_patterns�	itertools�chain�any)rAr�Z
start_matchesZpattern_matchesZ
candidatesr)r�rr��s

zDirectorySandbox._exemptedcOsE||jkrA|j|�rA|j|tjj|�||�|S)zCalled for path inputs)�	write_opsr�r�r,r$r�)rAr�r$rrr�rrrr��s"zDirectorySandbox._remap_inputcOsC|j|�s |j|�r9|j|||||�||fS)z?Called for path pairs like rename, link, and symlink operations)r�r�)rAr�r�r�rrr�rrrr��s zDirectorySandbox._remap_pairi�cOsO|t@r6|j|�r6|jd|||||�tj|||||�S)zCalled for low-level os.open()zos.open)�WRITE_FLAGSr�r�rzr)rAr��flagsrrrr�rrrr�szDirectorySandbox.openN)r;r<r=r>rp�fromkeysr�r��_EXCEPTIONSrjr�r�r�r�r�r�r�r�rrrrrr	�s 		
cCs"g|]}tt|d��qS)r)r}rz)rK�arrrrx�s	rxz4O_WRONLY O_RDWR O_APPEND O_CREAT O_TRUNC O_TEMPORARYc@s7eZdZdZejd�j�Zdd�ZdS)r
zEA setup script attempted to modify the filesystem outside the sandboxa
        SandboxViolation: {cmd}{args!r} {kwargs}

        The package setup script has attempted to modify files on your system
        that are not within the EasyInstall build area, and has been aborted.

        This package cannot be safely installed by EasyInstall, and may not
        support alternate installation locations even if you run its setup
        script by hand.  Please inform the package's author and the EasyInstall
        maintainers to find out if a fix or workaround is available.
        cCs%|j\}}}|jjt��S)N)rr�tmpl�formatr)rA�cmdrr�kwargsrrr�__str__�szSandboxViolation.__str__N)	r;r<r=r>�textwrap�dedent�lstripr�r�rrrrr
�s
)=r,rr)�operator�	functoolsr�r^�
contextlibr2r�Zsetuptools.externrZsetuptools.extern.six.movesrrZpkg_resources.py31compatr'�platformrJZ$org.python.modules.posix.PosixModule�pythonrN�posixZPosixModulerzrwr�r��	NameErrorrr�Zdistutils.errorsrr�__all__r�contextmanagerr#r%r+r0r4r1r@rSrQrXr]rbrZrrrvr�r�r	�reduce�or_�splitr�r
rrrr�<module>s^


	
	wV