Viewing File: /usr/lib64/python3.6/ensurepip/rewheel/__pycache__/__init__.cpython-36.pyc

3

sjM@sddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddZddZ
ddZdd	Zd
dZdS)NcCstjdd}|jddd|jdddd	tjjd
|j}d}yttft	|Wn4t
k
r}ztdj|d
}WYdd}~XnXtj
d
dS)Nz,Recreate wheel of package with given RECORD.)descriptionrecord_pathzPath to RECORD file)helpz-oz--output-dirz>Dir where to place the wheel, defaults to current working dir.outdir)rdestdefaultrz
Failed: {})argparseArgumentParseradd_argumentospathcurdir
parse_argsprintrewheel_from_recordvars
BaseExceptionformatsysexit)parsernsZretcodeer /usr/lib64/python3.6/__init__.pyrun
srcsg}tjtjtjg}dd|D}x|D]}d}xd|D]\tjj|djtj	fddtj
D}fdd|D}t|dkr8|d}q8W|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
    cSsg|]}tjj|r|qSr)rr
exists).0sprrr
<listcomp>(sz'find_system_records.<locals>.<listcomp>Nz-[^\{0}]+\.dist-infocsg|]}tjj|qSr)rr
join)rp)rrrr .scsg|]}tj|r|qSr)rematch)rc)dist_info_rerrr 0srrZRECORD)
sitegetsitepackagesrbase_prefixbase_exec_prefixrr
r!rseplistdirlenappend)ZprojectsZrecordsZsys_sitepackZprojectr
Z
candidatesZfilteredr)r&rrfind_system_recordss

r/cCstjjtjj|}|t|djtjj}t||\}}t|}tjj||d}t	j
|dt	jd}tj
}	tj|	}
x:|D]2\}}}
|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.whlw)modeZcompression)Zarcname)rr
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}
x&|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.ZWHEELzutf-8)encodingNZMETADATANameZVersionr2ZTag-r.r)rr
r!r3codecsopenemailrZParserZparsestrreadgetZget_allr.splitfilterlist)rZwheel_info_pathZwheel_info_fileZ
wheel_infoZ
metadata_pathZ
metadata_fileZmetadataZdistributionversionZ	build_tagZlang_tagtZabi_tagZplat_tagZto_joinrrrr6Vs 


r6c
Cstjj||}tj|dd}|j}WdQRXtjj|jtjj}|dt	dd}g}g}x|j
D]}|jd}	t	|	dkrntjj|	ds|	dj
d	s|	djd
s|	djds|	d|ks|	dj
|r|j|	q|j|	qnqnW||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)
    zutf-8)rFNz	dist-infodata,rJrz..z.pycz.pyo)rr
r!rKrLrNr3r4r+r-
splitlinesrPisabs
startswithendswithr.)
r@rAZrecord_file_pathZrecord_fileZrecord_contentsZdata_dirrBrClZsplrrrr5ns"
r5)r	rKr:Zemail.parserrMrr8r#r'
subprocessrr7rr/rr6r5rrrr<module>s
Back to Directory File Manager