bgvdZddlZddlZddlmZddlmZddlmZddl m Z dZ dZ d Z Gd d ZdS) aF This module represents the various types of requirement that can be specified for a project. It is somewhat redundant to re-implement here as we could use `pip.req.InstallRequirement`, but that would require depending on pip which is not easy to do since it will usually be installed by the user at a specific version. Additionally, the pip implementation has a lot of extra features that we don't need - we don't expect relative file paths to exist, for example. Note that the parsing here is also intentionally more lenient - it is not our job to validate the requirements list. N)Path)Optional)parse) RequirementcRtjj|vp|dS)N.)ospathsep startswith)reqs r/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/requirements_detector/requirement.py _is_filepathrs" 7;#  4!4!44c^d|vrdStj|}d|vrdS|ddS)zs >>> _parse_egg_name('egg=fish&cake=lala') fish >>> _parse_egg_name('something_spurious') None =Neggr)rparse_qs) url_fragmentpartss r_parse_egg_namersA ,t N< ( (E Et <?rcl|j|j|j|j|jdf}t j|SN)schemenetlocr paramsqueryr urlunparse)urlparts new_urlpartss r_strip_fragmentr!(s8  L  L ) ))rc eZdZ ddedededefdZdefdZdefd Zd Z d Z d Z d Z dZ eddededfdZdS)DetectedRequirementNnameurl requirementlocation_definedc|1|j|_||_d|jD|_d|_n||_g|_||_d|_||_dS)Nc*g|]}|j|jfS)operatorversion).0ss r z0DetectedRequirement.__init__..;s!!Y!Y!Ya1:qy"9!Y!Y!Yr)r$r& specifier version_specsr%r')selfr$r%r&r's r__init__zDetectedRequirement.__init__5sj  "#(DI*D !Y!Y;CX!Y!Y!YD DHHDI!#D DH#D  0rreturncJdd|jDS)N,c g|] \}}|| Sr*r*)r-compr,s rr/z5DetectedRequirement._format_specs..Es%ZZZmdG441ZZZr)joinr1r2s r _format_specsz!DetectedRequirement._format_specsDs&xxZZtGYZZZ[[[rc|jr|jr|jd|jS|jS|jr+|jr|j|S|jSt d|d)Nz#egg=zCannot convert z to pip format, no name or URL)r%r$r1r; ValueErrorr:s r pip_formatzDetectedRequirement.pip_formatGs 8 y ;&*hhh ::8O 9 ! B!%D,>,>,@,@,@AA9 O4OOOPPPrc|jpd}|jr*dd|jD}||}|jr |d|jd}|S)NUnknownr6c g|] \}}|| Sr*r*)r-r8vers rr/z/DetectedRequirement.__str__..Us%WWWytScc2WWWrz ())r$r1r9r%)r2repspecss r__str__zDetectedRequirement.__str__Rsmi$9   (HHWWDDVWWWXXEC'C 8 ."ssDHHH-C rctt|jt|jzt|jzSr)hashstrr$r%r1r:s r__hash__zDetectedRequirement.__hash__[s5C NNS]]2S9K5L5LLMMMrc&dt|zS)Nz)rIr:s r__repr__zDetectedRequirement.__repr__^s)CII55rcb|j|jko|j|jko|j|jkSr)r$r%r1r2others r__eq__zDetectedRequirement.__eq__as0yEJ&n48uy+@nTEW[`[nEnnrc*|jpd|jpdkS)N)r$rNs r__gt__zDetectedRequirement.__gt__ds REJ$4"55rc6|}|drdStjd|}|r|d|}tjdd|}|dd}tj|}d}d|j vs |j dvrW|j d krd }n|j }tjtjd tj |j zd|}|L|j dkrAt|s2 t|}t|| S#t$rYdSwxYwt|j}t#|}|r|d |}t|||S)Nz--hash=sha256:z\s#z^(-e|--editable) rR;r+)gitrWzgit+gitz^%s://)r&r'z://)r$r%r')stripr researchstartsubsplitrurlparserescaperrr#r=rfragmentr!)liner' comment_posr% vcs_schemer r$s rrzDetectedRequirement.parsegszz|| ??+ , , 4i--  /-+++---.Dv)2t44zz#q!nT"" #*   h 6 6zU""&  Z . BIcj4I4I(I2t!T!TUUC  #*"2"2<;M;M"2 _!$'' +sM]^^^^    tt s|,,c""  0)zz33/C"#HXYYYYs,E EE)NNNNr)__name__ __module__ __qualname__rIrrr3r;r>rFrJrLrPrS staticmethodrrr*rrr#r#4s#ko 1 1 1%( 1>I 1dh 1 1 1 1\s\\\\ QC Q Q Q QNNN666ooo6669Z9Zd9Zh?T6U9Z9Z9Z\9Z9Z9Zrr#)__doc__r rYpathlibrtypingrurllibrpackaging.requirementsrrrr!r#r*rrrms   ......555    * * *mZmZmZmZmZmZmZmZmZmZr