h OUdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddlm Z ddlmZmZmZmZmZmZmZmZmZmZddlmZddlmZmZddlmZer dd l m!Z!dd l"m#Z#d gZ$eee%e&fZ'ee&gee&e ffZ(ej)d ej*Z+ej)d Z,ej)dZ-ej.ej/ej0ej1ej2ej3ej4ej5ej6ej7ej8ej9ej:ej;gZd<ej?ej@ejAgZBeedej=fe>d<ejAgZCeedej=fe>d<deBDZDdeCDZEejFdfejGdfejHdfejIdfejJdfejKdfejLdfgZMeeeNe&fe>d<ej)dZOdZPejQeRZSe dGd d!ZTe dGd"d#ZU dEd%e&d&d'd(ed)d*eej d+eVd,eeTddff d-ZWd.e&d,e'fd/ZX dFd0eUd*eej d,eTfd1ZY dGd2e d%e&d3e%d(ed)d*eej d&ed'd,dfd4ZZ dGd0eUd*eej d(ed)d&ed'd,eeTf d5Z[Gd6d7Z\d(ed)d,e(fd8Z]d0e&d,ee&e&ffd9Z^Gd:d;e_Z`d,ejafd<Zbd=e'd,e'fd>Zcd=e'd,e'fd?Zdd=e'd,e'fd@ZedAe&d&d'd,ee&e&ffdBZfdCeNdAe&d,e&fdDZgdS)Hz Requirements file parsing N) dataclass)Values) TYPE_CHECKINGAnyCallableDict GeneratorIterableListNoReturnOptionalTuple) cmdoptions)InstallationErrorRequirementsFileParseError) SearchScope) 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.2/opt/imunify360/venv/lib/python3.11/site-packages/pip/_internal/req/req_file.py r"Rs&KKKc!!##(mmKKKcFg|]}t|jSrrrs r!r"r"Ss3'''CMM'''r#zutf-8zutf-32z utf-32-bez utf-32-lezutf-16z utf-16-bez utf-16-leBOMSscoding[:=]\s*([-\w.]+)T)frozencxeZdZUdZeed<eed<eed<eed<eeee fed<eeed<dS) ParsedRequirement requirement is_editable comes_from constraintoptions line_sourcer*r+r,r-r.r/N) __name__ __module__ __qualname__ __slots__r__annotations__boolr rrrr#r!r(r(isqIOOO d38n %%%%#r#r(ceZdZUdZeed<eed<eed<eed<eed<e defdZ e de efd Z d S) ParsedLine)filenamelinenoargsoptsr-r8r9r:r;r-returnc4t|jjSN)r5r; editablesselfs r!r+zParsedLine.is_editablesDI'(((r#cT|jr|jS|jr|jjdSdS)Nr)r:r+r;r?r@s r!r*zParsedLine.requirements4 9 *9    *9&q) )tr#N) r0r1r2r3rr4intrr5propertyr+r r*rr#r!r7r7}sDIMMM KKK III LLL )T)))X)Xc]Xr#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.rFrEN)get_line_parserRequirementsFileParserparse handle_line) r8rErFr.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)rP lines_enums r! preprocessrZsO )););)=)=QGGGJJ''J ,,J%j11J r#linecxd|jrdnd|j|j}|jJ|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)) formatr-r8r9r*r+#SUPPORTED_OPTIONS_EDITABLE_REQ_DESTSUPPORTED_OPTIONS_REQ_DESTr;__dict__r()r[r.line_comes_fromsupported_dest req_optionsrr/s r!handle_requirement_linerfs (..)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_indexr]r^)source)hashesloggerwarningrequire_hashesriextendrlrm search_scopern index_urlextra_index_urlsospathdirnameabspathjoinexistsappendupdate_index_urlsrpreset_allow_all_prereleases prefer_binaryset_prefer_binary trusted_hostsadd_trusted_host)r;r8r9rFr.rErlrmrnvaluereq_dirrelative_to_reqs_fileruhostros ` 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~|jt||}|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*rfrr;r8r9)r[r.rFrErOs r!rKrK$sS: #,T7;;  I M K       tr#c eZdZdddeddfdZdededeeddffd Z deded e e ee efdeeddffd Z dededeeddffd ZdS) rIrErrLr<Nc"||_||_dSr>)_session _line_parser)rArErLs r!__init__zRequirementsFileParser.__init__Qs   'r#r8r-c#K|||tj|digEd{VdS)z*Parse a given file, yielding parsed lines.N)_parse_and_recurserxryr{)rAr8r-s r!rJzRequirementsFileParser.parseYse** jBGOOH$=$=t#D"E           r#parsed_files_stackc#.K|||D]z}|jk|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_REsearchurllibrJurljoinrxryr{r|rzrcopyr) rAr8r-rr[req_pathnested_constraint parsed_files initial_filetailnew_parsed_filess r!rz)RequirementsFileParser._parse_and_recurseas $$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_contentrrZrOptionParsingErrormsgrr7) rAr8r-_rPrY line_numberr[args_strr;ers r!rz"RequirementsFileParser._parse_files&h >> 7(( !+   K 6!%!2!24!8!8$$% 6 6 6=d==ae==0555 6        sA  A6A11A6)r0r1r2 LineParserrrr5r r7rJr rr rrrr#r!rIrIPs(( (  ((((  )- :tT) *    222!c8C=&8!9: 2 :tT) * 2222h)- :tT) *r#rIcTdtdtttfffd }|S)Nr[r<cFt}|}d|_ r j|_t |\}} t j|}n%#t$r}td||d}~wwxYw| ||\}}||fS)NzCould not split options: ) build_parserget_default_valuesrvformat_controlbreak_args_optionsshlexsplit ValueErrorr parse_args) r[rMdefaultsr options_strr.rr;rrFs 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)rrr)rFrs` r!rHrHs@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 startswithr~popr|)r[tokensr:r.tokens r!rrs ZZ__F DQQQiG   C  E$4$4T$:$:  E KK    KKNNNN 88D>>388G,, ,,r#ceZdZdeddfdZdS)rrr<Nc||_dSr>)rrArs r!rzOptionParsingError.__init__s r#)r0r1r2rrrr#r!rrs6CDr#rctjd}ttz}|D]!}|}||"dt dt ddfd}||_|S)z7 Return a parser for parsing requirement lines F)add_help_optionrArr<r c t|r>)rrs r! parser_exitz!build_parser..parser_exits %%%r#)optparse OptionParserrr add_optionrrexit)rMoption_factoriesoption_factoryoptionrs r!rrs "5 9 9 9F(+@@*""!!&!!!!&#&C&J&&&& FK Mr#rYc#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_REmatchr~r|strip)rYprimary_line_numbernew_linerr[s r!rVrVs?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)rYrr[s r!rWrWs`($$ 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_REfindallrxgetenvreplace)rYrr[env_varvar_namers r!rXrXs (   T!+!3!3D!9!9 0 0 GXIh''E <<//DD4  r#urlctj|j}|dvr4ddlm}||}|||j|jfS t|d5}| }dddn #1swxYwYn$#t$r}td|d}~wwxYwt||}||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: )rrJurlsplitschemepip._internal.network.utilsrgetrtextopenreadOSErrorr_decode_req_file) rrErrresprj raw_contentexcrPs r!rr7s4\ " "3 ' ' .F ***@@@@@@{{3x""L #t__ #&&((K # # # # # # # # # # # # # # # LLL JS J JKKKL{C00G <s<B.B BBBBB B<%B77B<datactD]F\}}||r,|t|d|cSG|dddD]p}|dddkr`t |}|D|dd}||cSq |tS#t$r\tj dptj }tjd|t||||cYSwxYw) N rrR#asciiFzunable to decode data from %s with default encoding %s, falling back to encoding from locale: %s. If this is intentional you should specify the encoding with a PEP-263 style comment, e.g. '# -*- coding: %s -*-')r%rlendecoderPEP263_ENCODING_RErgroupsDEFAULT_ENCODINGUnicodeDecodeErrorlocalegetpreferredencodingsysgetdefaultencodingloggingrr)rrbomencodingr[resultlocale_encodings r!rrUsu55 X ??3   5C #**844 4 4 4 5 5!!"1"%-- !9  '..t44F!!==??1-44W=={{8,,,,,,{{+,,,  , , , 5e<<X@V@X@X A     {{?+++++ ,sC88A#EE)NNFr>)NNN)h__doc__codecsrrrrxrerr urllib.parser dataclassesrrtypingrrrrr r r r r rpip._internal.clirpip._internal.exceptionsrr!pip._internal.models.search_scoper"pip._internal.index.package_finderrpip._internal.network.sessionr__all__rCr ReqFileLinesrcompileIrrrrvextra_index_urlrnrreditablerl no_binary only_binaryrrsr trusted_hostuse_new_featurerOptionr4global_optionshashconfig_settingsrrrar`BOM_UTF8 BOM_UTF32 BOM_UTF32_BE BOM_UTF32_LE BOM_UTF16 BOM_UTF16_BE BOM_UTF16_LEr%bytesrr getLoggerr0rqr(r7r5rrZrfrrKrIrHr ExceptionrrrrVrWrXrrrr#r!r,s  !!!!!!                        )(((((RRRRRRRR9999999@@@@@@888888  c3h( seU3;// 0 BJ-rt 4 4 RZ ' ' RZ> ? ? N;4ho!567&O?tHS(/%9:;HXc8?.B%C D LK5JKKK''9'''# _g x  +& +& x  +& +&!d5  RZ :;;  8 $ $ $& $4)-)-   _ %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# sCx<,5,s,s,,,,,,r#