Qg@IUdZddlZddlZddlZddlZddlZddlZddlmZddl m Z m Z m Z m Z mZmZmZmZmZmZddlmZddlmZmZddlmZddlmZe r dd lmZdd lm Z d gZ!eee"e#fZ$e e#gee#effZ%ej&d ej'Z(ej&d Z)ej&dZ*ej+ej,ej-ej.ej/ej0ej1ej2ej3ej4ej5ej6ej7ej8gZ9ee dej:fe;d<ej<ej=ej>gZ?ee dej:fe;d<ej>gZ@ee dej:fe;d<de?DZAde@DZBejCeDZEGddZFGddZG d8de#dddeddeejd eHd!eeFddff d"ZId#e#d!e$fd$ZJ d9d%eGdeejd!eFfd&ZK d:d'ede#d(e"deddeejdedd!dfd)ZL d:d%eGdeejdeddedd!eeFf d*ZMGd+d,ZNdedd!e%fd-ZOd%e#d!ee#e#ffd.ZPGd/d0eQZRd!ejSfd1ZTd2e$d!e$fd3ZUd2e$d!e$fd4ZVd2e$d!e$fd5ZWd6e#ddd!ee#e#ffd7ZXdS);z Requirements file parsing N)Values) TYPE_CHECKINGAnyCallableDict GeneratorIterableListNoReturnOptionalTuple) cmdoptions)InstallationErrorRequirementsFileParseError) SearchScope) auto_decode) PackageFinder) PipSessionparse_requirementsz^(http|https|file):z (^|\s+)#.*$z#(?P\$\{(?P[A-Z0-9_]+)\}).SUPPORTED_OPTIONSSUPPORTED_OPTIONS_REQSUPPORTED_OPTIONS_EDITABLE_REQcFg|]}t|jSstrdest.0os z/builddir/build/BUILD/imunify360-venv-2.5.0/opt/imunify360/venv/lib/python3.11/site-packages/pip/_internal/req/req_file.py r"Os&KKKc!!##(mmKKKcFg|]}t|jSrrrs r!r"r"Ps3'''CMM'''r#c`eZdZ d dededededeeeefdeeddfd ZdS) ParsedRequirementN requirement is_editable comes_from constraintoptions line_sourcereturncZ||_||_||_||_||_||_dSN)r'r(r)r+r*r,)selfr'r(r)r*r+r,s r!__init__zParsedRequirement.__init__Xs7'&$ $&r#)NN) __name__ __module__ __qualname__rboolr rrr1rr#r!r&r&Ws-1%)'''' '  ' $sCx.) 'c]' ''''''r#r&c .eZdZdedededededdf dZdS) ParsedLinefilenamelinenoargsoptsr*r-Nc||_||_||_||_|rd|_d|_||_dS|jr"d|_d|_|jd|_dSd|_dS)NTFr)r8r9r;r*is_requirementr(r' editables)r0r8r9r:r;r*s r!r1zParsedLine.__init__js!   $  ("&D $D #D    ^ ("&D #D #~a0D   "'D   r#)r2r3r4rintrr5r1rr#r!r7r7isb((( (  (  ( ((((((r#r7Fr8sessionrfinderrr+r*r-c#Kt|}t||}|||D]}t||||}||VdS)aqParse a requirements file and yield ParsedRequirement instances. :param filename: Path or url of requirements file. :param session: PipSession instance. :param finder: Instance of pip.index.PackageFinder. :param options: cli options. :param constraint: If true, parsing a constraint file rather than requirements file. )r+rAr@N)get_line_parserRequirementsFileParserparse handle_line) r8r@rAr+r* line_parserparser parsed_line parsed_reqs r!rrs} "&))K #G[ 9 9F||Hj99       !    r#contentct|d}t|}t|}t |}|S)zxSplit, filter, and join lines, and return a line iterator :param content: the content of the requirements file )start) enumerate splitlines join_linesignore_commentsexpand_env_variables)rK lines_enums r! preprocessrUsO )););)=)=QGGGJJ''J ,,J%j11J r#linecxd|jrdnd|j|j}|jsJ|jrt }nt}i}|D]7}||jj vr'|jj |r|jj |||<8d|jd|j}t|j |j||j||S)Nz{} {} (line {})z-cz-rline  of )r'r(r)r*r+r,) formatr*r8r9r=r(#SUPPORTED_OPTIONS_EDITABLE_REQ_DESTSUPPORTED_OPTIONS_REQ_DESTr;__dict__r&r')rVr+line_comes_fromsupported_dest req_optionsrr,s r!handle_requirement_lineras (..)T  O    4<3K99 49% % %$)*%s line %s has --hash but no requirement, and will be ignored.c3.K|]}|jv |VdSr/)features_enabled)rfr+s r! z%handle_option_line..s9,,AW=U4U4U4U4U4U4U,,r#Tr) find_links index_urlsno_indexrXrY)source)hashesloggerwarningrequire_hashesrdextendrgrh search_scoperi index_urlextra_index_urlsospathdirnameabspathjoinexistsappendupdate_index_urlsrpreset_allow_all_prereleases prefer_binaryset_prefer_binary trusted_hostsadd_trusted_host)r;r8r9rAr+r@rgrhrivaluereq_dirrelative_to_reqs_filerphostrjs ` r!handle_option_liners {  L        9%)%8G "     $ + +,,,,0,,,    *>& & &/ =D HJ > *( *.)J   5 5   d3 4 4 4 ? %OA&Egoobgooh&?&?@@G$&GLL%$@$@ !w~~344 .-   e $ $ $  2  % %j 1 1 1"!!   + 8 /  , , . . .   '  $ $ & & &  >*0b > >777X77((f(====U*>*>N > > > >r#c~|jrt||}|St|j|j|j|||dS)aHandle a single parsed requirements line; This can result in creating/yielding requirements, or updating the finder. :param line: The parsed line to be processed. :param options: CLI options. :param finder: The finder - updated by non-requirement lines. :param session: The session - updated by non-requirement lines. Returns a ParsedRequirement object if the line is a requirement line, otherwise returns None. For lines that contain requirements, the only options that have an effect are from SUPPORTED_OPTIONS_REQ, and they are scoped to the requirement. Other options from SUPPORTED_OPTIONS may be present, but are ignored. For lines that do not contain requirements, the only options that have an effect are from SUPPORTED_OPTIONS. Options from SUPPORTED_OPTIONS_REQ may be present, but are ignored. These lines may contain multiple options (although our docs imply only one is supported), and all our parsed and affect the finder. N)r=rarr;r8r9)rVr+rAr@rJs r!rFrFsU:  ,T7;;  I M K       tr#c eZdZdddeddfdZdededeeddffd Z deded e e ee efdeeddffd Z dededeeddffd ZdS) rDr@rrGr-Nc"||_||_dSr/)_session _line_parser)r0r@rGs r!r1zRequirementsFileParser.__init__@s   'r#r8r*c#K|||tj|digEd{VdS)z*Parse a given file, yielding parsed lines.N)_parse_and_recursersrtrv)r0r8r*s r!rEzRequirementsFileParser.parseHse** jBGOOH$=$=t#D"E           r#parsed_files_stackc#.K|||D]z}|jsk|jjs |jjrR|jjr|jjd}d}n|jjd}d}t |r!tj ||}ntt |sZtj tj tj ||}|d}||vr'||}|d|nd} t|d|| |} || |<|||| g|Ed{Vv|V|dS)NrFTz and again in z" recursively references itself in ) _parse_filer=r; requirements constraints SCHEME_REsearchurllibrEurljoinrsrtrvrwrurcopyr) r0r8r*rrVreq_pathnested_constraint parsed_files initial_filetailnew_parsed_filess r!rz)RequirementsFileParser._parse_and_recursePs $$Xz::, , D&+  &+ *.)*?+ 9)-#y5a8H(-%%#y4Q7H(,%##H-- %|33HhGGHH"))(33 "w GOOH55$  H 2!4 |++#/#9L(38777 5#WWxWQUWW$0#4#4#6#6 -5 *22/2B1XEW1X Y, , r#c#"Kt||j\}}t|}|D]b\}} ||\}} n.#t$r!} d|d| j} t | d} ~ wwxYwt|||| |VcdS)NzInvalid requirement:  )get_file_contentrrUrOptionParsingErrormsgrr7) r0r8r*_rKrT line_numberrVargs_strr;ers r!rz"RequirementsFileParser._parse_files&h >> 7(( !+   K 6!%!2!24!8!8$$% 6 6 6=d==ae==0555 6        sA  A6A11A6)r2r3r4 LineParserr1rr5rr7rEr rr rrrr#r!rDrD?s(( (  ((((  )- :tT) *    222!c8C=&8!9: 2 :tT) * 2222h)- :tT) *r#rDcTdtdtttfffd }|S)NrVr-cFt}|}d|_ r j|_t |\}} t j|}n%#t$r}td||d}~wwxYw| ||\}}||fS)NzCould not split options: ) build_parserget_default_valuesrqformat_controlbreak_args_optionsshlexsplit ValueErrorr parse_args) rVrHdefaultsr options_strr+rr;rrAs r! parse_linez#get_line_parser..parse_lines,,..!  <&,&;H # 24 8 8+ Wk+..GG W W W$%N%N%NOOUV V W##GX66a~s A!! B+A>>B)rr r)rArs` r!rCrCs@sF{!3( r#cN|d}g}|dd}|D]X}|ds|drn+|||dYd|d|fS)zBreak up the line into an args and options string. We only want to shlex (and then optparse) the options, not the args. args can contain markers which are corrupted by shlex.  N-z--r)r startswithrypoprw)rVtokensr:r+tokens r!rrs ZZ__F DQQQiG   C  E$4$4T$:$:  E KK    KKNNNN 88D>>388G,, ,,r#ceZdZdeddfdZdS)rrr-Nc||_dSr/)rr0rs r!r1zOptionParsingError.__init__s r#)r2r3r4rr1rr#r!rrs6CDr#rctjd}ttz}|D]!}|}||"dt dt ddfd}||_|S)z7 Return a parser for parsing requirement lines F)add_help_optionr0rr-r c t|r/)rrs r! parser_exitz!build_parser..parser_exits %%%r#)optparse OptionParserrr add_optionrrexit)rHoption_factoriesoption_factoryoptionrs r!rrs "5 9 9 9F(+@@*""!!&!!!!&#&C&J&&&& FK Mr#rTc#Kd}g}|D]\}}|drt|r]t|rd|z}|r5|||J|d|fVg}||fV|s|}||d|r|J|d|fVdSdS)zJoins a line ending in '' with the previous line (except when following comments). The joined line takes on the index of the first line. N\rr)endswith COMMENT_REmatchryrwstrip)rTprimary_line_numbernew_linerrVs r!rQrQs?H'.. T}}T"" .j&6&6t&<&< .%% "Tz (%%%*666)2778+<+<<<<<!4''''' 2&1# OODJJt,, - - - -5"...!2778#4#444444455r#c#K|D]<\}}td|}|}|r||fV=dS)z1 Strips comments and filter empty lines. rN)rsubr)rTrrVs r!rRrRs`($$ T~~b$''zz||  $t# # # # $$r#c#K|D]X\}}t|D]2\}}tj|}|s|||}3||fVYdS)aReplace all environment variables that can be retrieved via `os.getenv`. The only allowed format for environment variables defined in the requirement file is `${MY_VARIABLE_1}` to ensure two things: 1. Strings that contain a `$` aren't accidentally (partially) expanded. 2. Ensure consistency across platforms for requirement files. These points are the result of a discussion on the `github pull request #3514 `_. Valid characters in variable names follow the `POSIX standard `_ and are limited to uppercase letter, digits and the `_` (underscore). N) ENV_VAR_REfindallrsgetenvreplace)rTrrVenv_varvar_namers r!rSrS s (   T!+!3!3D!9!9 0 0 GXIh''E <<//DD4  r#urlctj|j}|dvr4ddlm}||}|||j|jfS t|d5}t| }dddn #1swxYwYn$#t$r}td|d}~wwxYw||fS)aGets the content of a file; it may be a filename, file: URL, or http: URL. Returns (location, content). Content is unicode. Respects # -*- coding: declarations on the retrieved files. :param url: File path or url. :param session: PipSession instance. )httphttpsfiler)raise_for_statusrbNz"Could not open requirements file: )rrEurlsplitschemepip._internal.network.utilsrgetrtextopenrreadOSErrorr)rr@rrresprerKexcs r!rr&s+\ " "3 ' ' .F ***@@@@@@{{3x""L #t__ ,!!&&((++G , , , , , , , , , , , , , , , LLL JS J JKKKL <s<B(."B B(B  B(#B $B(( C 2CC )NNFr/)NNN)Y__doc__loggingrrsrer urllib.parserrtypingrrrrrr r r r r pip._internal.clirpip._internal.exceptionsrr!pip._internal.models.search_scoperpip._internal.utils.encodingr"pip._internal.index.package_finderrpip._internal.network.sessionr__all__r?r ReqFileLinesrcompileIrrrrqextra_index_urlrirreditablerg no_binary only_binaryr}rnr{ trusted_hostuse_new_featurerOption__annotations__global_optionshashconfig_settingsrrr\r[ getLoggerr2rlr&r7r5rrUrarrFrDrCr ExceptionrrrrQrRrSrrr#r!rs~                         )(((((RRRRRRRR9999994444449@@@@@@888888  c3h( seU3;// 0 BJ-rt 4 4 RZ ' ' RZ> ? ? N;4ho!567&O?tHS(/%9:;HXc8?.B%C D LK5JKKK''9'''#  8 $ $''''''''$((((((((<)-)-   _ %ho &     $,- 6      *.  ho &L)-)-&* C>C> C>C> C> _ % C> ho & C> l # C> C>C>C>C>P*.(,&* )) ) ho &) _ %)l # )  ))))XZZZZZZZZzH_5*0-S-U38_----" h+.5<5L5555>$ $$$$$ \ l    6# sCxr#