Edit File: __init__.cpython-37.opt-1.pyc
B m}�cL � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl Z d dl Z d dlZdd� Zdd� Z dd� Zdd � Zd d� ZdS )� Nc C s� t jdd�} | jddd� | jdddd tjjd � | �� }d}yttf t |��� W n4 t k r� } ztd�|�� d }W d d }~X Y nX t� d � d S )Nz,Recreate wheel of package with given RECORD.)Zdescription�record_pathzPath to RECORD file)�helpz-oz--output-dirz>Dir where to place the wheel, defaults to current working dir.�outdir)r �dest�defaultr z Failed: {}� )�argparse�ArgumentParser�add_argument�os�path�curdir� parse_args�print�rewheel_from_record�vars� BaseException�format�sys�exit)�parser�nsZretcode�e� r �?/opt/alt/python37/lib64/python3.7/ensurepip/rewheel/__init__.py�run s r c s� g }t �tjtjg�}dd� |D �}x�| D ]�}d}xd|D ]\�tj��|�d�tj � � �fdd�t� ��D �}� fdd�|D �}t|�dkr8|d }q8W |dk r�|�tj�|d �� q*|�d� q*W |S ) z�Return list of paths to RECORD files for system-installed projects. If a project is not installed, the resulting list contains None instead of a path to its RECORD c S s g | ]}t j�|�r|�qS r )r r �exists)�.0�spr r r � <listcomp>( s z'find_system_records.<locals>.<listcomp>Nz-[^\{0}]+\.dist-infoc s g | ]}t j�� |��qS r )r r �join)r �p)r r r r . s c s g | ]}t �� |�r|�qS r )�re�match)r �c)�dist_info_rer r r 0 s r r ZRECORD) �site�getsitepackagesr �base_prefix�base_exec_prefixr r r r �sep�listdir�len�append)ZprojectsZrecordsZsys_sitepackZprojectr Z candidatesZfilteredr )r% r r �find_system_records s r. c C s� t j�t j�| ��}| t|�d� �t jj�}t||�\}}t| �}t j�||d �}t j |dt jd�}t� � } t�| �} x:|D ]2\}}} |jt j�||�|d� | �||| g� q�W | �|ddg� |�|| �� � |�� |jS )zcRecreates a whee of package with given record_path and returns path to the newly created wheel.Nz.whl�w)�modeZcompression)Zarcname� )r r �dirnamer, �stripr* �get_records_to_pack�get_wheel_namer �zipfileZZipFileZZIP_DEFLATED�io�StringIO�csv�writer�writeZwriterowZwritestr�getvalue�close�filename)r r �site_dir�record_relpath�to_write�to_omitZnew_wheel_nameZnew_wheel_pathZ new_wheelZ new_recordr: �fZsha_hash�sizer r r r : s r c C s t j�t j�| �d�}tj|dd��}tj�� � |� � �}W dQ R X t j�t j�| �d�}tj|dd��}tj�� � |� � �}W dQ R X |�d�}|�d�}d} g } x&|�d �D ]}| � |�d �d � q�W d�| �} |�d ��d �d d� \}} td||| | || g�}d �t|��S )z.Return proper name of the wheel, without .whl.ZWHEELzutf-8)�encodingNZMETADATA�NameZVersionr1 ZTag�-r �.r � )r r r r2 �codecs�open�emailr ZParserZparsestr�read�getZget_allr- �split�filter�list)r Zwheel_info_pathZwheel_info_fileZ wheel_infoZ metadata_pathZ metadata_fileZmetadataZdistribution�versionZ build_tagZlang_tag�tZabi_tagZplat_tagZto_joinr r r r5 V s r5 c C s t j�| |�}tj|dd��}|�� }W dQ R X t j�|��t jj�}|dt d� � d }g }g }x�|� � D ]�}|�d�} t | �dkrnt j�| d �s�| d � d �s�| d �d �s�| d �d�s�| d |ks�| d � |�r�|�| � q�|�| � qnqnW ||fS )a Accepts path of sitedir and path of RECORD file relative to it. Returns two lists: - list of files that can be written to new RECORD straight away - list of files that shouldn't be written or need some processing (pyc and pyo files, scripts) zutf-8)rE Nz dist-info�data�,rI r z..z.pycz.pyo)r r r rJ rK rM r2 r3 r* r, � splitlinesrO �isabs� startswith�endswithr- ) r? r@ Zrecord_file_pathZrecord_fileZrecord_contentsZdata_dirrA rB �lZsplr r r r4 n s"