Viewing File: /opt/alt/python35/lib64/python3.5/ensurepip/rewheel/__pycache__/__init__.cpython-35.opt-1.pyc



YfL@sddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddZddZ
ddZdd	Zd
dZdS)NcCstjdd}|jddd|jddddd	d
dtjj|j}d}yttt	|Wn>t
k
r}ztd
j|d}WYdd}~XnXtj
ddS)NZdescriptionz,Recreate wheel of package with given RECORD.record_pathhelpzPath to RECORD filez-oz--output-dirz>Dir where to place the wheel, defaults to current working dir.destoutdirdefaultrz
Failed: {})argparseArgumentParseradd_argumentospathcurdir
parse_argsprintrewheel_from_recordvars
BaseExceptionformatsysexit)parsernsZretcodeer?/opt/alt/python35/lib64/python3.5/ensurepip/rewheel/__init__.pyrun
s
rcsg}tjtjtjg}dd|D}x|D]}d}x|D]tjj|djtj	fddtj
D}fdd|D}t|dkrN|d}qNW|dk	r|jtjj|d	q;|jdq;W|S)
zReturn 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).0sprrr
<listcomp>(s	z'find_system_records.<locals>.<listcomp>Nz-[^\{0}]+\.dist-infocs%g|]}tjj|qSr)rrjoin)rp)rrrr.s	cs(g|]}tj|r|qSr)rematch)rc)dist_info_rerrr0s	rrZRECORD)
sitegetsitepackagesrbase_prefixbase_exec_prefixrrr rseplistdirlenappend)ZprojectsZrecordsZsys_sitepackZprojectrZ
candidatesZfilteredr)r%rrfind_system_recordss

%"r.cCsEtjjtjj|}|t|djtjj}t||\}}t|}tjj||d}t	j
|dddt	j}tj
}	tj|	}
xO|D]G\}}}
|jtjj||d||
j|||
gqW|
j|ddg|j||	j|j|jS)zcRecreates a whee of package with given record_path and returns path
    to the newly created wheel.Nz.whlmodewZcompressionZarcname)rrdirnamer,stripr*get_records_to_packget_wheel_namer zipfileZZipFileZZIP_DEFLATEDioStringIOcsvwriterwriteZwriterowZwritestrgetvalueclosefilename)rrsite_dirrecord_relpathto_writeto_omitZnew_wheel_nameZnew_wheel_pathZ	new_wheelZ
new_recordr:fZsha_hashsizerrrr:s%"
rcCstjjtjj|d}tj|dd%}tjjj	|j
}WdQRXtjjtjj|d}tj|dd%}tjjj	|j
}WdQRX|jd}|jd}d}	g}
x1|jd	D] }|
j
|jd
dqWdj|
}
|jd	jd
d
d\}}
td|||	|
||
g}d
jt|S)z.Return proper name of the wheel, without .whl.ZWHEELencodingzutf-8NZMETADATANameZVersionr1ZTag-r.r)rrr r2codecsopenemailrZParserZparsestrreadgetZget_allr-splitfilterlist)rZwheel_info_pathZwheel_info_fileZ
wheel_infoZ
metadata_pathZ
metadata_fileZmetadataZdistributionversionZ	build_tagZlang_tagtZabi_tagZplat_tagZto_joinrrrr5Vs !%!%(!r5c
Cs\tjj||}tj|dd}|j}WdQRXtjj|jtjj}|dt	dd}g}g}x|j
D]}|jd}	t	|	dkrtjj|	ds.|	dj
d	s.|	djd
s.|	djds.|	d|ks.|	dj
|r>|j|	qN|j|	qqW||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-infodata,rIrz..z.pycz.pyo)rrr rJrKrMr2r3r*r,
splitlinesrOisabs
startswithendswithr-)
r?r@Zrecord_file_pathZrecord_fileZrecord_contentsZdata_dirrArBlZsplrrrr4ns"!)&#r4)rrJr9Zemail.parserrLrr7r"r&
subprocessrr6rr.rr5r4rrrr<module>s
Back to Directory File Manager