Your IP : 3.22.68.228


Current Path : /usr/lib64/python3.6/site-packages/cffi/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/cffi/__pycache__/verifier.cpython-36.opt-1.pyc

3

M��Z�+�@s�ddlZddlZddlZddlZddlZddlmZddlmZddlm	Z	ej
dkrhddlZdd�Z
nddlZd	d�Z
ej
dkr�ejZnGd
d�dej�ZGdd
�d
e�ZdZdd�Zdadd�Zdd�Zddd�Zdd�Zdd�ZdS)�N�)�__version_verifier_modules__)�ffiplatform)�VerificationError�cCstjjdd�S)N)�	importlib�	machinery�EXTENSION_SUFFIXES�r
r
� /usr/lib64/python3.6/verifier.py�_extension_suffixessrcCsdd�tj�D�S)NcSs g|]\}}}|tjkr|�qSr
)�impZC_EXTENSION)�.0�suffix�_�typer
r
r�
<listcomp>sz'_extension_suffixes.<locals>.<listcomp>)r
Zget_suffixesr
r
r
rrscseZdZ�fdd�Z�ZS)�NativeIOcs(t|t�r|jd�}tt|�j|�dS)N�ascii)�
isinstanceZunicode�encode�superr�write)�self�s)�	__class__r
rrs

zNativeIO.write)�__name__�
__module__�__qualname__r�
__classcell__r
r
)rrrsrc@szeZdZddd�Zd dd�Zd	d
�Zdd�Zd
d�Zdd�Zdd�Z	dd�Z
dd�Zdd�Zd!dd�Z
dd�Zdd�ZdS)"�VerifierN�F�.ccKsv|jjrtd|jjf��||_||_|s4tj|�}t||�}
|
|�|_|jj	|�|	|_
|j||
�|_|rz|rxt
d��n�djtjdd�t||g|j�}tjdkr�|jd�}ttj|ddd��d@�}|jd	�jd
�}ttj|ddd��d@�}|jd�jd
�}d
||jj||f}t�d}|�p0t�|_tjj|j||�|_ tjj|j||�|_!||_"d|_#d|_$dS)NzKfeature not supported with ffi.verify(), but only with ffi.set_source(): %sz)can't specify both 'modulename' and 'tag'�rzutf-8r�l��Z0x�Lr�0z_cffi_%s_%s%s%sF)r)%Z_parserZ_uses_new_featurer�ffi�preamblerZflatten�_locate_engine_class�_vengineZpatch_extension_kwds�flags�make_relative_to�kwds�	TypeError�join�sys�versionrZ_cdefsources�version_infor�hex�binasciiZcrc32�lstrip�rstripZ
_class_key�_get_so_suffixes�_caller_dir_pycache�tmpdir�os�path�sourcefilename�modulefilename�ext_package�_has_source�_has_module)rr'r(r9Z
modulenamer>�tag�force_generic_engineZsource_extensionr+�relative_tor-Zflattened_kwdsZ
vengine_class�keyZk1Zk2rr
r
r�__init__ sD









zVerifier.__init__c	Cs8|jj�&|jr |dkr td��|j|�WdQRXdS)zkWrite the C source code.  It is produced in 'self.sourcefilename',
        which can be tweaked beforehand.Nzsource code already written)r'�_lockr?r�
_write_source)r�filer
r
r�write_sourceHs

zVerifier.write_sourcec	Cs<|jj�*|jrtd��|js&|j�|j�WdQRXdS)z�Write the C source code (if not done already) and compile it.
        This produces a dynamic link library in 'self.modulefilename'.zmodule already compiledN)r'rFr@rr?rG�_compile_module)rr
r
r�compile_moduleQs
zVerifier.compile_modulec	CsF|jj�4|js4|j�|js4|js,|j�|j�|j�SQRXdS)a"Get a C module from this Verifier instance.
        Returns an instance of a FFILibrary class that behaves like the
        objects returned by ffi.dlopen(), but that delegates all
        operations to the C module.  If necessary, the C code is written
        and compiled first.
        N)r'rFr@�_locate_moduler?rGrJ�
_load_library)rr
r
r�load_library[s
zVerifier.load_librarycCsBtjj|j�}|jdd�d}|jd�r>ttd�r>|dd�}|S)N�.rrZ_d�gettotalrefcountr$���)r:r;�basenamer=�split�endswith�hasattrr0)rrRr
r
r�get_module_nameks
zVerifier.get_module_namec
CsVtj�|js0|jj�|js&|j�WdQRXtj|j�}|j�}tj	||f|j
�S)N)rZ_hack_at_distutilsr?r'rFrGZmaybe_relative_pathr<rV�
get_extensionr-)rZ
sourcename�modnamer
r
rrWvs
zVerifier.get_extensioncCs|jjS)N)r*Z_gen_python_module)rr
r
r�generates_python_module�sz Verifier.generates_python_modulecs~|rztjj|�rztjj|��|j�}xTtjD]J}||kr,||}t|ttf�s\t	d|f���fdd�|D�}|||<q,W|S)Nz&keyword '%s' should be a list or tuplecsg|]}tjj�|��qSr
)r:r;r/)r�fn)�dirnamer
rr�sz-Verifier.make_relative_to.<locals>.<listcomp>)
r:r;r[�copyrZLIST_OF_FILE_NAMESr�list�tupler.)rr-rCrDZlstr
)r[rr,�s
zVerifier.make_relative_tocCs�tjj|j�st|jrHyt|jdddg�}Wntk
r>dSX|j}nd}|jj	|j
�|t��}|dkrndS||_|jj�d|_
dS)N�__doc__T)r:r;�isfiler=r>�
__import__�ImportError�__path__r*�find_modulerVr7Z
collect_typesr@)rZpkgr;�filenamer
r
rrL�s
zVerifier._locate_modulec
Cs$||j_z|jj�Wd|j`XdS)N)r*Z_fZwrite_source_to_f)rrHr
r
r�_write_source_to�szVerifier._write_source_tocCs�|dk	r|j|�n�t�}|j|�|j�}tjj|j�rbt|jd��}|j�|k}WdQRXnd}|r�t	|j�t|jd��}|j
|�WdQRXd|_dS)N�rT�w)rfr�getvaluer:r;�existsr<�open�read�_ensure_dirrr?)rrH�fZsource_data�fpZ
needs_writtenr
r
rrG�s

zVerifier._write_sourcecCsptjj|j�}tj||j��}ytj||j�}Wnt	k
rHd}YnX|sft
|j�tj||j�d|_
dS)NFT)r:r;r[r<r�compilerW�samefiler=�OSErrorrm�shutilZmover@)rr9ZoutputfilenameZsamer
r
rrJ�s

zVerifier._compile_modulecCs&|jdk	r|jj|j�S|jj�SdS)N)r+r*rN)rr
r
rrM�s
zVerifier._load_library)NNNr!Fr"NN)N)N)rrrrErIrKrNrVrWrYr,rLrfrGrJrMr
r
r
rr s
&
	



r FcCs|trd}|sPdtjkrd}n4yddl}Wntk
r@d}YnX|j|k	rPd}|rfddlm}|jSddlm	}|j
SdS)NTZ__pypy__r�?r)�vengine_gen)�vengine_cpy)�_FORCE_GENERIC_ENGINEr0�builtin_module_names�
_cffi_backendrbZ_backendr!ruZVGenericEnginervZVCPythonEngine)r'rBryrurvr
r
rr)�s 


r)cCsHtrtStjjd�}|r|Stjd�jj}tjj	tjj
tjj|�d��S)NZCFFI_TMPDIRr$�__pycache__)�_TMPDIRr:�environ�getr0�	_getframe�f_code�co_filenamer;�abspathr/r[)�resultrer
r
rr8�sr8cCs|adS)z:Set the temporary directory to use instead of __pycache__.N)r{)r[r
r
r�
set_tmpdirsr�cCs0|pt�}ytj|�}Wntk
r,dSX|r8d}nt�dj�}xd|D]\}|j�jd�rL|j�j|�sz|j�jd�rLytjtj	j
||��WqLtk
r�YqLXqLWtj	j
|d�g}xn|D]f}yJxDtj|�D]6}tj	j
||�}tj	j|��r|j|�q�tj|�q�WWq�tk
�r&Yq�Xq�WdS)z}Clean up the temporary directory by removing all files in it
    called `_cffi_*.{c,so}` as well as the `build` subdirectory.Nz.crZ_cffi_Zbuild)
r8r:�listdirrrr7�lower�
startswithrT�unlinkr;r/�isdir�append)r9Zkeep_soZfilelistrrZZ	clean_dir�dirr
r
r�cleanup_tmpdirs2



r�cCs&t�}|s"tjdkrdg}ndg}|S)NZwin32z.pydz.so)rr0�platform)�suffixesr
r
rr7$s
r7cCs,tjj|�}|r(tjj|�r(tj|�dS)N)r:r;r[r��makedirs)rer[r
r
rrm/srm)rr)r)NF)r0r:r4rs�ior!rr�errorrr2Zimportlib.machineryrrr
�StringIOr�BytesIO�objectr rwr)r{r8r�r�r7rmr
r
r
r�<module>s*(


?



?>