Your IP : 3.146.37.242


Current Path : /opt/alt/python34/lib64/python3.4/ensurepip/rewheel/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/ensurepip/rewheel/__pycache__/__init__.cpython-34.pyc

�
e fL�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZdd�Zdd�Z
dd�Zdd	�Zd
d�ZdS)�NcCs�tjdd�}|jddd�|jddddd	d
dtjj�|j�}d}yttt	|���Wn>t
k
r�}ztd
j|��d}WYdd}~XnXtj
d�dS)NZdescriptionz,Recreate wheel of package with given RECORD.�record_path�helpzPath to RECORD filez-oz--output-dirz>Dir where to place the wheel, defaults to current working dir.�dest�outdir�defaultrz
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/python34/lib64/python3.4/ensurepip/rewheel/__init__.py�run
s
rcsg}tjtjtjg�}dd�|D�}x�|D]�}d}x�|D]��tjj�|�djtj	���fdd�tj
��D�}�fdd�|D�}t|�dkrN|d}qNqNW|dk	r|jtjj|d	��q;|j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
    cSs(g|]}tjj|�r|�qSr)rr�exists)�.0�sprrr�
<listcomp>(s	z'find_system_records.<locals>.<listcomp>Nz-[^\{0}]+\.dist-infocs%g|]}tjj�|��qSr)rr�join)r�p)rrrr.s	cs(g|]}tj�|�r|�qSr)�re�match)r�c)�dist_info_rerrr0s	rrZRECORD)
�site�getsitepackagesr�base_prefix�base_exec_prefixrrr r�sep�listdir�len�append)ZprojectsZrecordsZsys_sitepackZprojectrZ
candidatesZfilteredr)r%rr�find_system_recordss

%"r.cCsEtjjtjj|��}|t|�d�jtjj�}t||�\}}t|�}tjj||d�}t	j
|dddt	j�}tj
�}	tj|	�}
xO|D]G\}}}
|jtjj||�d|�|
j|||
g�q�W|
j|ddg�|j||	j��|j�|jS)zcRecreates a whee of package with given record_path and returns path
    to the newly created wheel.Nz.whl�mode�wZcompressionZarcname�)rr�dirnamer,�stripr*�get_records_to_pack�get_wheel_namer �zipfileZZipFileZZIP_DEFLATED�io�StringIO�csv�writer�writeZwriterowZwritestr�getvalue�close�filename)rr�site_dir�record_relpath�to_write�to_omitZnew_wheel_nameZnew_wheel_pathZ	new_wheelZ
new_recordr:�fZsha_hash�sizerrrr:s%"
rcCs�tjjtjj|�d�}tj|dd��%}tjj�j	|j
��}WdQXtjjtjj|�d�}tj|dd��%}tjj�j	|j
��}WdQX|jd�}|jd�}d}	g}
x1|jd	�D] }|
j
|jd
�d�q�Wdj|
�}
|jd	�jd
�d
d�\}}
td|||	|
||
g�}d
jt|��S)z.Return proper name of the wheel, without .whl.ZWHEEL�encodingzutf-8NZMETADATA�NameZVersionr1ZTag�-r�.r�)rrr r2�codecs�open�emailrZParserZparsestr�read�getZget_allr-�split�filter�list)rZwheel_info_pathZwheel_info_fileZ
wheel_infoZ
metadata_pathZ
metadata_fileZmetadataZdistribution�versionZ	build_tagZlang_tag�tZabi_tagZplat_tagZto_joinrrrr5Vs !$!$(!r5c

Cs[tjj||�}tj|dd��}|j�}WdQXtjj|�jtjj�}|dt	d��d}g}g}x�|j
�D]�}|jd�}	t	|	�dkr�tjj|	d�s-|	dj
d	�s-|	djd
�s-|	djd�s-|	d|ks-|	dj
|�r=|j|	�qM|j|	�q�q�W||fS)aAccepts 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)
    rEzutf-8Nz	dist-info�data�,rIrz..z.pycz.pyo)rrr rJrKrMr2r3r*r,�
splitlinesrO�isabs�
startswith�endswithr-)
r?r@Zrecord_file_pathZrecord_fileZrecord_contentsZdata_dirrArB�lZsplrrrr4ns"!)&#r4)rrJr9Zemail.parserrLrr7r"r&�
subprocessrr6rr.rr5r4rrrr�<module>s

?>