r-aHN v d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl m
Z
d Zd Zd Z
G d
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)Requirementc R t j j | v p| d S )N.)ospathsep
startswith)reqs s/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/requirements_detector/requirement.py_is_filepathr s"
7;#4!4!44 c ^ d| vrdS t j | }d|vrdS |d d S )zs
>>> _parse_egg_name('egg=fish&cake=lala')
fish
>>> _parse_egg_name('something_spurious')
None
=Neggr )r parse_qs)url_fragmentpartss r _parse_egg_namer sA ,tN<((EEt<?r c l | j | j | j | j | j d f}t j | S N)schemenetlocr
paramsqueryr
urlunparse)urlpartsnew_urlpartss r _strip_fragmentr! ( s8
L L)))r c e Zd Z ddedededefdZdefdZdefd Zd
Z d Z
d Zd
Zd Z
eddeded fd ZdS )DetectedRequirementNnameurlrequirementlocation_definedc |1|j | _ || _ d |j D | _ d | _ n|| _ g | _ || _ d | _ || _ d S )Nc * g | ]}|j |j fS )operatorversion).0ss r