OwlCyberSecurity - MANAGER
Edit File: verifier.cpython-36.opt-1.pyc
3 M��Z�+������������������@���s����d�dl�Z�d�dlZd�dlZd�dlZd�dlZddlmZ�ddlmZ�ddlm Z �e�j dkrhd�dlZdd��Z nd�dlZd d��Z e�j dkr�ejZnG�d d��dej�ZG�dd ��d e�ZdZdd��Zdadd��Zdd��Zddd�Zdd��Zdd��ZdS�)�����N����)�__version_verifier_modules__)�ffiplatform)�VerificationError����c���������������C���s���t�jjd�d���S�)N)� importlib� machinery�EXTENSION_SUFFIXES��r ���r ���� /usr/lib64/python3.6/verifier.py�_extension_suffixes���s����r���c���������������C���s���dd��t�j��D��S�)Nc�������������S���s ���g�|�]\}}}|t�jkr|�qS�r ���)�impZC_EXTENSION)�.0�suffix�_�typer ���r ���r���� <listcomp>���s����z'_extension_suffixes.<locals>.<listcomp>)r ���Zget_suffixesr ���r ���r ���r���r������s����c�������������������s���e�Zd�Z��fdd�Z���ZS�)�NativeIOc����������������s(���t�|t�r|jd�}tt|��j|��d�S�)N�ascii)� isinstanceZunicode�encode�superr����write)�self�s)� __class__r ���r���r������s���� zNativeIO.write)�__name__� __module__�__qualname__r���� __classcell__r ���r ���)r���r���r������s���r���c���������������@���sz���e�Zd�Zddd�Zd dd�Zd d ��Zdd��Zd d��Zdd��Zdd��Z dd��Z dd��Zdd��Zd!dd�Z dd��Zdd��ZdS�)"�VerifierN��F�.cc�������������K���sv��|j�jrtd|j�jf���||�_||�_|s4tj|�}t||�} | |��|�_|�jj |��| |�_ |�j|| �|�_|rz|rxt d��n�djtjd�d��t||g|j��}tjdkr�|jd�}ttj|dd�d���d@��}|jd �jd �}ttj|dd�d���d@��}|jd�jd �}d ||�jj||f�}t��d�}|�p0t��|�_tjj|�j||��|�_ tjj|�j||��|�_!||�_"d|�_#d|�_$d�S�)NzKfeature not supported with ffi.verify(), but only with ffi.set_source(): %sz)can't specify both 'modulename' and 'tag'��r���zutf-8r�������l������Z0x�Lr����0z_cffi_%s_%s%s%sF)r���)%Z_parserZ_uses_new_featurer����ffi�preambler���Zflatten�_locate_engine_class�_vengineZpatch_extension_kwds�flags�make_relative_to�kwds� TypeError�join�sys�versionr���Z_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)r���r'���r(���r9���Z modulenamer>����tag�force_generic_engineZsource_extensionr+����relative_tor-���Zflattened_kwdsZ vengine_class�keyZk1Zk2r���r ���r ���r����__init__ ���sD���� zVerifier.__init__c���������� ���C���s8���|�j�j�&�|�jr |dkr td��|�j|��W�dQ�R�X�dS�)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_sourceH���s ���� zVerifier.write_sourcec���������� ���C���s<���|�j�j�*�|�jrtd��|�js&|�j���|�j���W�dQ�R�X�dS�)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'���rF���r@���r���r?���rG����_compile_module)r���r ���r ���r����compile_moduleQ���s���� zVerifier.compile_modulec���������� ���C���sF���|�j�j�4�|�js4|�j���|�js4|�js,|�j���|�j���|�j��S�Q�R�X�dS�)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'���rF���r@����_locate_moduler?���rG���rJ���� _load_library)r���r ���r ���r����load_library[���s���� zVerifier.load_libraryc�������������C���sB���t�jj|�j�}|jdd�d�}|jd�r>ttd�r>|d�d��}|S�)N�.r���r���Z_d�gettotalrefcountr$������)r:���r;����basenamer=����split�endswith�hasattrr0���)r���rR���r ���r ���r����get_module_namek���s ����zVerifier.get_module_namec���������� ���C���sV���t�j���|�js0|�jj��|�js&|�j���W�d�Q�R�X�t�j|�j�}|�j��}t�j ||f|�j �S�)N)r���Z_hack_at_distutilsr?���r'���rF���rG���Zmaybe_relative_pathr<���rV���� get_extensionr-���)r���Z sourcename�modnamer ���r ���r���rW���v���s���� zVerifier.get_extensionc�������������C���s���|�j�jS�)N)r*���Z_gen_python_module)r���r ���r ���r����generates_python_module����s����z Verifier.generates_python_modulec����������������s~���|rzt�jj|�rzt�jj|���|j��}xTtjD�]J}||kr,||�}t|ttf�s\t d|f�����fdd�|D��}|||<�q,W�|S�)Nz&keyword '%s' should be a list or tuplec����������������s���g�|�]}t�jj��|��qS�r ���)r:���r;���r/���)r����fn)�dirnamer ���r���r�������s����z-Verifier.make_relative_to.<locals>.<listcomp>) r:���r;���r[����copyr���ZLIST_OF_FILE_NAMESr����list�tupler.���)r���r-���rC���rD���Zlstr ���)r[���r���r,�������s���� zVerifier.make_relative_toc�������������C���s����t�jj|�j�st|�jrHyt|�jd�d�dg�}W�n�tk r>���d�S�X�|j}nd�}|�jj |�j ��|t���}|d�krnd�S�||�_|�jj���d|�_ d�S�)N�__doc__T)r:���r;����isfiler=���r>���� __import__�ImportError�__path__r*����find_modulerV���r7���Z collect_typesr@���)r���Zpkgr;����filenamer ���r ���r���rL�������s���� zVerifier._locate_modulec���������� ���C���s$���||�j�_z|�j�j���W�d�|�j�`X�d�S�)N)r*���Z_fZwrite_source_to_f)r���rH���r ���r ���r����_write_source_to����s����zVerifier._write_source_toc�������������C���s����|d�k r|�j�|��n�t��}|�j�|��|j��}tjj|�j�rbt|�jd��}|j��|k�}W�d�Q�R�X�nd}|r�t |�j��t|�jd��}|j |��W�d�Q�R�X�d|�_d�S�)N�rT�w)rf���r����getvaluer:���r;����existsr<����open�read�_ensure_dirr���r?���)r���rH����fZsource_data�fpZ needs_writtenr ���r ���r���rG�������s���� zVerifier._write_sourcec�������������C���sp���t�jj|�j�}tj||�j���}ytj||�j�}W�n�t k rH���d}Y�nX�|sft |�j��tj||�j��d|�_ d�S�)NFT)r:���r;���r[���r<���r����compilerW����samefiler=����OSErrorrm����shutilZmover@���)r���r9���ZoutputfilenameZsamer ���r ���r���rJ�������s���� zVerifier._compile_modulec�������������C���s&���|�j�d�k r|�jj|�j��S�|�jj��S�d�S�)N)r+���r*���rN���)r���r ���r ���r���rM�������s���� zVerifier._load_library)NNNr!���Fr"���NN)N)N)r���r���r���rE���rI���rK���rN���rV���rW���rY���r,���rL���rf���rG���rJ���rM���r ���r ���r ���r���r ������s����� & r ���Fc�������������C���s|���t�rd}|sPdtjkrd}n4ydd�l}W�n�tk r@���d}Y�nX�|�j|k rPd}|rfddlm}�|jS�ddlm }�|j S�d�S�)NTZ__pypy__r����?r���)�vengine_gen)�vengine_cpy)�_FORCE_GENERIC_ENGINEr0����builtin_module_names� _cffi_backendrb���Z_backendr!���ru���ZVGenericEnginerv���ZVCPythonEngine)r'���rB���ry���ru���rv���r ���r ���r���r)�������s ���� r)���c��������������C���sH���t�rt�S�tjjd�}�|�r|�S�tjd�jj}tjj tjj tjj|�d��S�)NZCFFI_TMPDIRr$����__pycache__)�_TMPDIRr:����environ�getr0���� _getframe�f_code�co_filenamer;����abspathr/���r[���)�resultre���r ���r ���r���r8�������s����r8���c�������������C���s���|�a�dS�)z:Set the temporary directory to use instead of __pycache__.N)r{���)r[���r ���r ���r���� set_tmpdir���s����r����c�������������C���s0��|�pt���}�ytj|��}W�n�tk r,���dS�X�|r8d}nt��d�j��}xd|D�]\}|j��jd�rL|j��j|�sz|j��jd�rLytjtj j |�|���W�qL�tk r����Y�qLX�qLW�tj j |�d�g}xn|D�]f}yJxDtj|�D�]6}tj j ||�}tj j|��r�|j|��q�tj|��q�W�W�q��tk �r&���Y�q�X�q�W�dS�)z}Clean up the temporary directory by removing all files in it called `_cffi_*.{c,so}` as well as the `build` subdirectory.Nz.cr���Z_cffi_Zbuild) r8���r:����listdirrr���r7����lower� startswithrT����unlinkr;���r/����isdir�append)r9���Zkeep_soZfilelistr���rZ���Z clean_dir�dirr ���r ���r����cleanup_tmpdir��s2���� r����c��������������C���s&���t���}�|�s"tjdkrdg}�ndg}�|�S�)NZwin32z.pydz.so)r���r0����platform)�suffixesr ���r ���r���r7���$��s���� r7���c�������������C���s,���t�jj|��}|r(t�jj|��r(t�j|��d�S�)N)r:���r;���r[���r�����makedirs)re���r[���r ���r ���r���rm���/��s����rm���)r���r���)r���)NF)r0���r:���r4���rs����ior!���r���r����errorr���r2���Zimportlib.machineryr���r���r ����StringIOr����BytesIO�objectr ���rw���r)���r{���r8���r����r����r7���rm���r ���r ���r ���r����<module>���s*���( �?