a æÀ-^¥ã@sndZddlZddlZddlZddlZddlmZe d¡Z dd„Z dd „Z d d „Z d d „Z dd„Zdd„ZdS)z2 Tools for converting old- to new-style metadata. éNé)Ú read_pkg_infozF^(?P.*?)(;\s*(?P.*?)(extra == '(?P.*?)')?)$cCsRt|ddƒrd|jSg}|jD]\}}| ||¡q |s@dSdd t|ƒ¡S)zFReturn the version specifier for a requirement in PEP 345/566 fashion.ÚurlNz @ Úz (%s)ú,)ÚgetattrrZspecsÚappendÚjoinÚsorted)Z requirementZ requires_distÚopZver©r ú0/usr/lib/python3/dist-packages/wheel/metadata.pyÚrequires_to_requires_dists  rccsN|D]D}tj |¡}t|ƒ}d t|jƒ¡}|r8d|}|j||VqdS)z=Yield Requires-Dist: strings for parsed requirements strings.rz[%s]N)Ú pkg_resourcesZ RequirementÚparserr r ÚextrasZ project_name)Z requirementsZreqZparsed_requirementÚspecrr r r Úconvert_requirementss rccs–| ¡D]ˆ\}}d}|pd}d|vr4| dd¡\}}t |¡}|rhd|fV|r\d|d}|d|7}|rtd|}t|ƒD]}d ||fVq|qd S) a, Convert requirements from a setup()-style dictionary to ('Requires-Dist', 'requirement') and ('Provides-Extra', 'extra') tuples. extras_require is a dictionary of {extra: [requirements]} as passed to setup(), using the empty extra {'': [requirements]} to hold install_requires. rú:rúProvides-Extraú(z) and z extra == '%s'z ; ú Requires-DistN)ÚitemsÚsplitrZ safe_extrar)Zextras_requireÚextraZdependsZ conditionZnew_reqr r r Úgenerate_requirements*s     rc Csàt|ƒ}| dd¡|d=|d=tj |d¡}tj |¡r¼t|ƒ}| ¡}Wdƒn1s`0Ytt   |¡dd„d }|D]6\}}t ||iƒD] \} } | | f|  ¡vr˜| || <q˜q„|d } | rÜ|  t|ƒ¡|d =|S) zN Convert .egg-info directory with PKG-INFO to the Metadata 2.1 format zMetadata-Versionz2.1rrz requires.txtNcSs |dp dS)Nrrr )Úxr r r ÚUóz%pkginfo_to_metadata..)ÚkeyÚ Description)rZreplace_headerÚosÚpathr ÚexistsÚopenÚreadr rZsplit_sectionsrrZ set_payloadÚdedent_description) Z egg_info_pathZ pkginfo_pathÚpkg_infoZ requires_pathZ requires_fileZrequiresZparsed_requirementsrZreqsrÚvalueÚ descriptionr r r Úpkginfo_to_metadataFs(   & ÿ  r*cCsV||}| ¡}t|tƒsR| ¡D].}|d ¡|kr"|d dd¡ d¡}qRq"|S)zs ÿ