abc@sdZddlmZddlZddlmZddlZddlZddlZddl m Z m Z ddl m Z mZmZddlmZdd lmZmZdd lmZmZejeZd e fd YZd e fdYZde fdYZde fdYZdddgZdZ dZ!ej"dZ#ej"dZ$ddddddd d!d"d#d$f Z%ddddd%ddd d!d"d#d$d&d'd(d)d*fZ&d(d)d*d&d'fZ'ddddd%ddd d!d"d#d+d,d$d&d'd-d.d/d0d1d2fZ(d/d0d1d-d2d+d,d.fZ)ddddd%ddd d!d"d#d+d,d$d&d'd-d.d/d0d1d2d3d4d5d6d7fZ*d3d7d4d5d6fZ+e,Z-e-j.e%e-j.e&e-j.e(e-j.e*ej"d8Z/d9Z0d:Z1idd;6dd<6dd=6dd>6d%d?6dd@6ddA6d dB6d!dC6d"dD6d#dE6d+dF6d,dG6d$dH6d&dI6d'dJ6d-dK6d/dL6d0dM6d5dN6d1dO6d2dP6d*dQ6d)dR6d(dS6d.dT6d3dU6d4dV6d6dW6d7dX6Z2d0d-d/fZ3d1fZ4dfZ5dd&d(d*d)d-d/d0d2d.d%d5d7d6fZ6d.fZ7d fZ8d"d+ddfZ9e:Z;ej"dYZ<e=dZZ>d[e:fd\YZ?d]Z@d^ZAd_e:fd`YZBdS(auImplementation of the Metadata for Python packages PEPs. Supports all metadata formats (1.0, 1.1, 1.2, and 2.0 experimental). i(tunicode_literalsN(tmessage_from_filei(tDistlibExceptiont __version__(tStringIOt string_typest text_type(t interpret(textract_by_keyt get_extras(t get_schemetPEP440_VERSION_REtMetadataMissingErrorcBseZdZRS(uA required metadata is missing(t__name__t __module__t__doc__(((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyR stMetadataConflictErrorcBseZdZRS(u>Attempt to read or write metadata fields that are conflictual.(R RR(((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyR st MetadataUnrecognizedVersionErrorcBseZdZRS(u Unknown metadata version number.(R RR(((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyR$stMetadataInvalidErrorcBseZdZRS(uA metadata value is invalid(R RR(((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyR(suMetadatauPKG_INFO_ENCODINGuPKG_INFO_PREFERRED_VERSIONuutf-8u1.1u \|u uMetadata-VersionuNameuVersionuPlatformuSummaryu DescriptionuKeywordsu Home-pageuAuthoru Author-emailuLicenseuSupported-Platformu Classifieru Download-URLu ObsoletesuProvidesuRequiresu MaintaineruMaintainer-emailuObsoletes-Distu Project-URLu Provides-Distu Requires-DistuRequires-PythonuRequires-ExternaluPrivate-Versionu Obsoleted-ByuSetup-Requires-Distu ExtensionuProvides-Extrau"extra\s*==\s*("([^"]+)"|'([^']+)')cCsP|dkrtS|dkr tS|dkr0tS|dkr@tSt|dS(Nu1.0u1.1u1.2u2.0(t _241_FIELDSt _314_FIELDSt _345_FIELDSt _426_FIELDSR(tversion((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyt_version2fieldlistgs    c Csd}g}xB|jD]4\}}|gdd fkrCqn|j|qWddddg}x|D]}|tkrd|kr|jdn|tkrd|kr|jdn|tkrd|kr|jdn|tkrmd|krm|jdqmqmWt|dkr1|dSt|dkrRt d nd|koj||t }d|ko||t }d|ko||t }t |t |t |dkrt d n| r| r| rt|krtSn|r dS|rdSdS( u5Detect the best version depending on the fields used.cSs%x|D]}||krtSqWtS(N(tTruetFalse(tkeystmarkerstmarker((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyt _has_markerus  uUNKNOWNu1.0u1.1u1.2u2.0iiuUnknown metadata setu(You used incompatible 1.1/1.2/2.0 fieldsN(titemstNonetappendRtremoveRRRtlenRt _314_MARKERSt _345_MARKERSt _426_MARKERStinttPKG_INFO_PREFERRED_VERSION( tfieldsRRtkeytvaluetpossible_versionstis_1_1tis_1_2tis_2_0((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyt _best_versionssB  & umetadata_versionunameuversionuplatformusupported_platformusummaryu descriptionukeywordsu home_pageuauthoru author_emailu maintainerumaintainer_emailulicenseu classifieru download_urluobsoletes_distu provides_distu requires_distusetup_requires_disturequires_pythonurequires_externalurequiresuprovidesu obsoletesu project_urluprivate_versionu obsoleted_byu extensionuprovides_extrau[^A-Za-z0-9.]+cCsG|r9tjd|}tjd|jdd}nd||fS(uhReturn the distribution name with version. If for_filename is true, return a filename-escaped form.u-u u.u%s-%s(t _FILESAFEtsubtreplace(tnameRt for_filename((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyt_get_name_and_versions!tLegacyMetadatacBs4eZdZdddddZdZdZdZdZdZ dZ d Z d Z d Z d Zed ZdZdZdZdZedZedZddZdZedZedZedZdZdZdZdZ dZ!dZ"RS( uaThe legacy metadata of a release. Supports versions 1.0, 1.1 and 1.2 (auto-detected). You can instantiate the class with one of these arguments (or none): - *path*, the path to a metadata file - *fileobj* give a file-like object with metadata as content - *mapping* is a dict-like object - *scheme* is a version scheme name udefaultcCs|||gjddkr-tdni|_g|_d|_||_|dk rm|j|nB|dk r|j|n&|dk r|j ||j ndS(Niu'path, fileobj and mapping are exclusive( tcountR t TypeErrort_fieldstrequires_filest _dependenciestschemetreadt read_filetupdatetset_metadata_version(tselftpathtfileobjtmappingR=((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyt__init__s        cCst|j|jdJscCst|}|d|jdtj|ddd}z|j||Wd|jXdS(u&Write the metadata fields to filepath.uwRbuutf-8N(RcRdt write_fileRe(RBRft skip_unknownRg((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyRGhscCs<|jx+t|dD]}|j|}|rT|dgdgfkrTqn|tkr|j||dj|qn|tkr|dkr|jd kr|jdd}q|jdd }n|g}n|t krg|D]}dj|^q}nx!|D]}|j|||qWqWd S( u0Write the PKG-INFO format data to a file object.uMetadata-VersionuUNKNOWNu,u Descriptionu1.0u1.1u u u |N(u1.0u1.1( RARRIRVRHtjoinRURXR3Ri(RBt fileobjectRqRnRoR+((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyRpps$      % c sfd}|sn^t|drRxL|jD]}||||q4Wn$x!|D]\}}|||qYW|rx*|jD]\}}|||qWndS(uSet metadata values from the given iterable `other` and kwargs. Behavior is like `dict.update`: If `other` has a ``keys`` method, they are looped over and ``self[key]`` is assigned ``other[key]``. Else, ``other`` is an iterable of ``(key, value)`` iterables. Keys that don't match a metadata field or that have an empty value are dropped. cs2|tkr.|r.jj||ndS(N(RTRKRM(R*R+(RB(s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyt_setsukeysN(thasattrRR(RBtothertkwargsRttktv((RBs@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyR@s cCs|j|}|tks'|dkrt|ttf rt|trwg|jdD]}|j^q\}qg}nF|tkrt|ttf rt|tr|g}qg}nt j t j r|d}t |j}|tkrR|d k rRx|D];}|j|jddst jd|||qqWq|tkr|d k r|j|st jd|||qq|tkr|d k r|j|st jd|||qqn|tkr|dkr|j|}qn||j|d?d@f }i}x;|D]3\}}| sf||jkrD|||||D]3\}}| sk||jkrI||||(t __class__R R4R(RB((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyt__repr__msN(#R RRR RFRARHRJRLRPRQRMRWR[R]RR_R`RaR>R?RGRpR@RKRRIRRRRRRoRR(((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyR7s>                     ,  , ;    u pydist.jsonu metadata.jsontMetadatacBseZdZejdZejdejZeZ ejdZ dZ de Z id>d6d?d6d@d 6Zd Zd ZiedAfd 6edBfd6e dCfd6e dDfd 6ZdEZdFdFdFddZedGZdFefZdFefZi defd6defd6ed6ed6ed6defd6ed6ed6ed6ed 6d!efd"6dHd$6dId 6Z[[d&ZdFd'Zd(Zed)Z ed*Z!e!j"d+Z!dFdFd,Z#ed-Z$ed.Z%e%j"d/Z%d0Z&d1Z'd2Z(d3Z)id4d6d5d6d6d6d7d 6d8d96d!d"6Z*d:Z+dFdFe,e-d;Z.d<Z/d=Z0RS(Ju The metadata of a release. This implementation uses 2.0 (JSON) metadata where possible. If not possible, it wraps a LegacyMetadata instance which handles the key-value metadata format. u ^\d+(\.\d+)*$u!^[0-9A-Z]([0-9A-Z_.-]*[0-9A-Z])?$u .{1,2047}u2.0u distlib (%s)unameuversionulegacyusummaryuqname version license summary description author author_email keywords platform home_page classifiers download_urluwextras run_requires test_requires build_requires dev_requires provides meta_requires obsoleted_by supports_environmentsumetadata_versionu_legacyu_datauschemeudefaultcCs|||gjddkr-tdnd|_d|_||_|dk ry|j||||_Wqtk rtd|d||_|j qXnd}|rt |d}|j }WdQXn|r|j }n|dkri|j d6|j d6|_nt|ts?|jd}ny)tj||_|j|j|Wn9tk rtd t|d||_|j nXdS( Niu'path, fileobj and mapping are exclusiveRER=urbumetadata_versionu generatoruutf-8RD(R8R R9t_legacyt_dataR=t_validate_mappingRR7tvalidateRdR>tMETADATA_VERSIONt GENERATORRzRtdecodetjsontloadst ValueErrorR(RBRCRDRER=Rtf((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyRFs>          ulicenseukeywordsu Requires-Distu run_requiresuSetup-Requires-Distubuild_requiresu dev_requiresu test_requiresu meta_requiresuProvides-Extrauextrasumodulesu namespacesuexportsucommandsu Classifieru classifiersu Download-URLu source_urluMetadata-Versionc Cstj|d}tj|d}||kr||\}}|jr|dkrs|dkrgdn|}q|jj|}q|dkrdn|}|d kr|jj||}qt}|}|jjd} | r|dkr| jd |}q|dkrH| jd } | r| j||}qq| jd } | sr|jjd } n| r| j||}qn||kr|}qnQ||krtj||}n0|jr|jj|}n|jj|}|S( Nu common_keysu mapped_keysucommandsuexportsumodulesu namespacesu classifiersu extensionsupython.commandsupython.detailsupython.exports(ucommandsuexportsumodulesu namespacesu classifiers(tobjectt__getattribute__RR RIR( RBR*tcommontmappedtlktmakertresultR+tsentineltd((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyRsF           cCso||jkrk|j|\}}|p.|j|krk|j|}|shtd||fqhqkndS(Nu.'%s' is an invalid value for the '%s' property(tSYNTAX_VALIDATORSR=tmatchR(RBR*R+R=tpatternt exclusionstm((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyt_validate_valuescCs|j||tj|d}tj|d}||kr||\}}|jr~|dkrntn||j|               cCst|j|jtS(N(R6R4RR(RB((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pytname_and_version@scCsd|jr|jd}n|jjdg}d|j|jf}||kr`|j|n|S(Nu Provides-Distuprovidesu%s (%s)(RRRR4RR!(RBRts((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pytprovidesDs  cCs*|jr||jd}||krL|dkrsd }n|}||||d|kr>|}Pq>q>W|dkri|d6}|jd|n*t|dt|B}t||d(R4RRR RX(RBR4R((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyR(s (((ulegacy((ulegacy(ulegacy(ulegacy(u_legacyu_datauschemeN(unameuversionulicenseukeywordsusummary(u Download-URLN(uMetadata-VersionN(1R RRtretcompiletMETADATA_VERSION_MATCHERtIt NAME_MATCHERR tVERSION_MATCHERtSUMMARY_MATCHERRRRRRRRt __slots__R RFRKt common_keysR{t none_listtdictt none_dictt mapped_keysRRRtpropertyRRtsetterRRRRRRRRRRRRGRR(((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyRvs       ,         + ' *     % (CRt __future__RRctemailRRRRtRRtcompatRRRRRtutilRR RR R t getLoggerR R}R RRRt__all__tPKG_INFO_ENCODINGR(RRZRYRRR$RR%RR&RKRRR@tEXTRA_RERR0RTRRRRURiRVRRRR1RR6R7tMETADATA_FILENAMEtWHEEL_METADATA_FILENAMER(((s@/usr/lib/python2.7/site-packages/pip/_vendor/distlib/metadata.pyt s                                         8