Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib/python3.4/site-packages/wheel/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib/python3.4/site-packages/wheel/__pycache__/metadata.cpython-34.pyc

�
�/6R�&�@s�dZddlmZmZddlmZddlZddlZddl	Z	ddl
Z
ddlZddl
Z
dZidd6d	d
6dd6Ze�Zid
d6dd6dfidd6dd6dffZed,�Zejd�Zejd�Zedd-�Zdd�Zdd�Zddd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Ze d+kr�ddl!Z!ddl"Z"e"j"ee!j#d��ndS).z2
Tools for converting old- to new-style metadata.
�)�defaultdict�
namedtuple�)�
read_pkg_infoNz2.0�classifiers�
classifier�providesZ
provides_dist�extras�provides_extra�author_email�email�author�name�maintainer_email�
maintainer�platform�	home_page�licensezF^(?P<package>.*?)(;\s*(?P<condition>.*?)(extra == '(?P<extra>.*?)')?)$z[-,]+�MayRequiresKey�	condition�extraccs?t�}x/|D]'}||kr|j|�|VqqWdS)z<
    Yield unique values in iterable, preserving order.
    N)�set�add)�iterable�seen�value�r�?/opt/alt/python34/lib/python3.4/site-packages/wheel/metadata.py�unique's
	

rcCs}tt�}x�|j|�D]�}tj|�}|r�|j�}|d}|d}|d}	|jd�r�|dd
�}q�nd\}}|}	t||�}||j|	�qW|ryg|d<xj|j	�D]\\}}i|d6}
|j
r|j
|
d<n|jr$|j|
d	<n|dj|
�q�Wd
|krRg|d
<n|d
jdd�|j
�D��ndS)zF
    Place the runtime requirements from pkg_info into metadata. 
    rr�packagez and N�Zrun_requires�requiresZenvironmentr	cSs"g|]}|jr|j�qSr)r)�.0�keyrrr�
<listcomp>Rs	z#handle_requires.<locals>.<listcomp>���)NN)r�list�get_all�EXTRA_RE�search�	groupdict�endswithr�append�itemsrr�extend�keys)�metadata�pkg_infor#Zmay_requiresrZextra_matchr*rrrZmay_requirementrrr�handle_requires2s4




		
r2cCs�idtjdd6}ytt|�}WnBtk
rptjj�jt	|d�j
�jd��}YnXd}|dr�t|d�|d<|d=n|d	r�t
|�}|d	=n<|j�}t|t�r�|jd�}n|r�|}n|r
||d
<nx+tdd�|j�D��D]
}|jd
d�}|tkrWq-n|tkr~|j|�dkr~q-n|tkr�|j|�|t|<q-|dkr�t|||�q-|dkrd|kr�g|d<n|dj|j|��q-|dkr)i||d6|d<q-||||<q-Wt|d<d|krntt|d��|d<n|r�xwd'D]l\}}	yKt||	�}
t|
t�r�tt |
��}i|d6g||<nWq{t!k
r�Yq{Xq{Wng}xut"D]m\}
}i}x8|
D]0}|
||kr|j#|
|�||<qqW|r�||d<|j$|�q�q�W|r||d<ny�t	t%j&j't%j&j(|�d�d��}t)j*j+|j
��}WdQXi}xg|j,�D]Y\}}i||<x@|j-�D]2}t.|�j/dd�\}}||||<qWq�W|rP||d <nWnt0k
reYnXd |kr�xVd*D]K\}}||d kry|jd%i�|d%<|d ||d%|<qyqyWn|S)+a
    Convert PKG-INFO to a prototype Metadata 2.0 (PEP 426) dict.
    
    The description is included under the key ['description'] rather than 
    being written to a separate file.
    
    path: path to PKG-INFO file
    distribution: optional distutils Distribution()
    z
bdist_wheel (�)�	generator�rbzutf-8NZSummary�summary�Description�descriptioncss|]}|j�VqdS)N)�lower)r"�krrr�	<genexpr>{sz"pkginfo_to_dict.<locals>.<genexpr>�-�_�UNKNOWN�
requires_distr
r	rZHomeZproject_urls�metadata_version�
test_requires�
tests_requirer!�role�contactszentry_points.txt�rz = r�exports�console_scripts�wrap_console�gui_scripts�wrap_gui�commands�rAz
tests_require)rL�rGrH�rIrJ)rMrN)1�wheel�__version__�unicoder�	NameErrorr�parser�Parser�parsestr�open�read�decode�pkginfo_unicode�dedent_description�get_payload�
isinstance�bytesrr/�replace�SKIP_FIELDS�UNKNOWN_FIELDS�get�
PLURAL_FIELDSr'r2r.�METADATA_VERSION�sortedr�getattrr&�convert_requirements�AttributeError�CONTACT_FIELDS�popr,�os�path�join�dirname�
pkg_resources�
EntryPoint�	parse_mapr-�values�str�split�IOError)rk�distributionr0r1r8�payloadr#Zlow_keyr!�attr�requirementsZnew_requirementsrDZcontact_typerC�contactZep_file�ep_maprF�groupr-�itemrZexportZ	ep_scriptZwrap_scriptrrr�pkginfo_to_dictUs�
5



	
&!





-

 r}cCsLg}x(|jD]\}}|j||�qW|s;dSddj|�S)zBCompose the version predicates for requirement in PEP 345 fashion.�z (%s)�,)�specsr,rl)�requirementr?�op�verrrr�requires_to_requires_dist�sr�ccshxa|D]Y}tjj|�}t|�}dj|j�}|rPd|}n|j||VqWdS)z=Yield Requires-Dist: strings for parsed requirements strings.rz[%s]N)rn�Requirement�parser�rlr	�project_name)rx�reqZparsed_requirement�specr	rrrrf�s

rfc
Cs�t|�}|jdd�tjj|d�}tjj|�r�t|�j�}xntj	|�D]Z\}}d}|r�||d<dt
|�}nx"t|�D]}|||d<q�WqeWn|d}	|	r�|jt
|��|d=n|S)	zn
    Convert .egg-info directory with PKG-INFO to the Metadata 1.3 aka
    old-draft Metadata 2.0 format.
    zMetadata-Versionz2.0zrequires.txtr~zProvides-Extraz
; extra == %sz
Requires-Distr7)r�replace_headerrjrkrl�existsrVrWrn�split_sections�reprrf�set_payloadrZ)
Z
egg_info_pathZpkginfo_pathr1Z
requires_pathr!r�reqsrZnew_reqr8rrr�pkginfo_to_metadata�s"


r�cCs�||}|j�}t|t�s�t|d�s>t|�SxP|j�D]?}|dj�|krK|djdd�jd�}PqKqKWn|S)z<Hack to coax Unicode out of an email Message() - Python 3.3+�	raw_itemsrr�ascii�surrogateescapezutf-8)r9r\rr�hasattrr��encoderX)r1�field�textr|rrrrY�s

	rYcCs�|d}d}t|t�s7d}t|d�}n|j�}dj|dj�tjdj|dd���df�}|r�|jd�j	d	d
�}n|S)z@
    Dedent and convert pkg_info['Description'] to Unicode.
    r7FT�
rrN�utf8r�r�)
r\rrrY�
splitlinesrl�lstrip�textwrap�dedentr�rX)r1r8Z
surrogatesZdescription_linesZdescription_dedentrrrrZs

	rZ�__main__)zauthorzauthor_emailzplatformz	home_pagezlicense)z	conditionzextra)$�__doc__�collectionsrrZpkginfor�re�os.pathrjr�rn�email.parserrrOrcrbrr_rhr`�compiler(ZKEYWORDS_RErrr2r}r�rfr�rYrZ�__name__�sys�pprint�argvrrrr�<module>sB

		#v