ó â\e[c@s®dZddlZddlZddlZddlmZddlZddlm Z ej dƒZ eddƒZ d „Z d „Zd „Zd „Zd„Zd„ZdS(s2 Tools for converting old- to new-style metadata. iÿÿÿÿN(t namedtuplei(t read_pkg_infosF^(?P.*?)(;\s*(?P.*?)(extra == '(?P.*?)')?)$tMayRequiresKeyt conditiontextracCsRg}x(|jD]\}}|j||ƒqW|s;dSddjt|ƒƒS(sBCompose the version predicates for requirement in PEP 345 fashion.ts (%s)t,(tspecstappendtjointsorted(t requirementt requires_disttoptver((s//tmp/pip-install-0xiv62/wheel/wheel/metadata.pytrequires_to_requires_dists ccshxa|D]Y}tjj|ƒ}t|ƒ}dj|jƒ}|rPd|}n|j||VqWdS(s=Yield Requires-Dist: strings for parsed requirements strings.Rs[%s]N(t pkg_resourcest RequirementtparseRR textrast project_name(t requirementstreqtparsed_requirementtspecR((s//tmp/pip-install-0xiv62/wheel/wheel/metadata.pytconvert_requirementss   ccsÕxÎ|jƒD]À\}}d}|r[d|kr[|jddƒ\}}tj|ƒ}n|r”d|fV|rƒd|d}n|d|7}n|r§d|}nx#t|ƒD]}d ||fVq´Wq Wd S( s, 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. Rt:isProvides-Extrat(s) and s extra == '%s's; s Requires-DistN(titemstsplitRt safe_extraR(textras_requireRtdependsRtnew_req((s//tmp/pip-install-0xiv62/wheel/wheel/metadata.pytgenerate_requirements*s  c Cs÷t|ƒ}|jddƒtjj|dƒ}tjj|ƒrÆt|ƒ}|jƒ}WdQXx_tt j |ƒdd„ƒD]<\}}x-t i||6ƒD]}|d||dMsiit Description(Rtreplace_headertostpathR texiststopentreadR Rtsplit_sectionsR"t set_payloadtdedent_description( t egg_info_patht pkginfo_pathtpkg_infot requires_patht requires_filetrequiresRtreqstitemt description((s//tmp/pip-install-0xiv62/wheel/wheel/metadata.pytpkginfo_to_metadataBs   cCs•||}|jƒ}t|tƒs‘t|dƒs>t|ƒSxP|jƒD]?}|djƒ|krK|djddƒjdƒ}PqKqKWn|S(s<Hack to coax Unicode out of an email Message() - Python 3.3+t raw_itemsiitasciitsurrogateescapesutf-8(tlowert isinstancetstrthasattrR:tencodetdecode(R2tfieldttextR7((s//tmp/pip-install-0xiv62/wheel/wheel/metadata.pytpkginfo_unicodeYs     cCs£|d}t}t|tƒs7t}t|dƒ}n|jƒ}dj|djƒtj dj|dƒƒdfƒ}|rŸ|j dƒj ddƒ}n|S(s@ Dedent and convert pkg_info['Description'] to Unicode. R&s iitutf8R;R<( tFalseR>R?tTrueREt splitlinesR tlstripttextwraptdedentRARB(R2R8t surrogatestdescription_linestdescription_dedent((s//tmp/pip-install-0xiv62/wheel/wheel/metadata.pyR/is     (s conditionsextra(t__doc__tos.pathR(treRKt collectionsRRtpkginfoRtcompiletEXTRA_RERRRR"R9RER/(((s//tmp/pip-install-0xiv62/wheel/wheel/metadata.pyts