7f6dZddlZddlZddlZddlZddlmZmZmZm Z m Z m Z m Z ddl mZmZddlmZddlmZddlmZddlmZmZejZe d eZerd nd Zd Zed ddddZejej ej!ej"ej#fZ$ej ejej!fZ%ee&Z'dedefdZ(dede efdZ)deee effdZ*GddZ+dS)a Configuration management setup Some terminology: - name As written in config files. - value Value associated with a name - key Name combined with it's section (section.name) - variant A single word describing where the configuration key-value pair came from N)AnyDictIterableListNewTypeOptionalTuple)ConfigurationError!ConfigurationFileCouldNotBeLoaded)appdirs)WINDOWS) getLogger) ensure_direnumKindzpip.inizpip.conf)versionhelpuserglobalsiteenvzenv-var)USERGLOBALSITEENVENV_VARnamereturnc|dd}|dr |dd}|S)zAMake a name consistent regardless of source (environment or file)_-z--N)lowerreplace startswith)rs {/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_internal/configuration.py_normalize_namer'2sE ::<<  S ) )D tABBx Kc`d|vrd|d}t||ddS)N.zVKey does not contain dot separated section and key. Perhaps you wanted to use 'global.z ' instead?)r split)r error_messages r&_disassemble_keyr.:sO $ B15 B B B !/// ::c1  r(cdtjdD}tjt jt}tjtjdtrdndt}tjtj dt}tj |tj |gtj||giS)NcXg|]'}tj|t(S)ospathjoinCONFIG_BASENAME).0r3s r& z+get_configuration_files..Es504 T?++r(pip~z.pip)r site_config_dirsr2r3r4sysprefixr5 expanduserr user_config_dirkindsrrr)global_config_filessite_config_filelegacy_config_filenew_config_files r&get_configuration_filesrDDs8?8PQV8W8Ww||CJ@@ 3$f gll7#:5#A#A?SSO ) %& '9 r(c"eZdZdZd"dedeeddffd Zd#dZdee fdZ de e e e ffd Zd e de fd Zd e d e ddfd Zd e ddfdZd#dZd#dZedee e ffdZd#dZdede defdZde defdZd#dZde de e e e fdee e ffdZde e e e ffdZde e eee ffdZdedee e ffdZ de e effdZ!de deddfd Z"de fd!Z#xZ$S)$ ConfigurationaHandles management of configuration. Provides an interface to accessing and managing configuration files. This class converts provides an API that takes "section.key-name" style keys and stores the value associated with it as "key-name" under the section "section". This allows for a clean interface wherein the both the section and the key-name are preserved in an easy to manage form in the configuration files and the data stored is also nice. Nisolated load_onlyrc zt|V|tvrMtddt tt||_||_ dtD|_ dtD|_ g|_ dS)Nz5Got invalid value for load_only - should be one of {}z, ci|]}|gSr1r1r6variants r& z*Configuration.__init__..rs-H H H #GRH H H r(ci|]}|iSr1r1rKs r&rMz*Configuration.__init__..us'4 4 4 #GR4 4 4 r()super__init__VALID_LOAD_ONLYr formatr4mapreprrGrHOVERRIDE_ORDER_parsers_config_modified_parsers)selfrGrH __class__s r&rPzConfiguration.__init__es   Yo%E%E$GNNIIc$8899  ! "H H '5H H H  4 4 '54 4 4  EGr(ch||js|dSdS)z2 2 2$%@h%@%@AA A2244 v  ,S11MGT""7++ 060D0DWd0S0S )J <<(( /%%g...  " "5& 1 1 1 L ( - - -r(c||jD]\}}td|t t j| t|d5}| |dddn #1swxYwY#t$r}td|d|d}~wwxYwdS)z!Save the current in-memory state.z Writing to %swNz:An error occurred while writing to the configuration file z: ) rorXloggerinforr2r3dirnameopenwriteOSErrorr )rYrtruferrors r&savezConfiguration.saves- ##%%%!3  ME6 KK / / / rwu-- . . . %%%$LLOOO$$$$$$$$$$$$$$$   (((( %((   s<)B'9B B'B B'"B #B'' C 1CC cr|jtdtd|jdS)Nz'Needed a specific file to be modifying.z$Will be working with %s variant only)rHr r~debugr^s r&roz$Configuration._ensure_have_load_onlys6 > !$%NOO O ;T^LLLLLr(c^i}tD]"}||j|#|S)z3A dictionary representing the loaded configuration.)rUupdaterW)rYretvalrLs r&rezConfiguration._dictionarys9 % 1 1G MM$,w/ 0 0 0 0 r(ct|}|tjddtjgkrt ddS|D]q\}}|D]i}|j (||j krt d||1| ||}|j | ||fjrdS)z,Loads configuration from configuration filesrr+zZSkipping loading configuration files due to environment's PIP_CONFIG_FILE being os.devnullNz Skipping file '%s' (variant: %s)) dictiter_config_filesr?rr2devnullr~rrfrH _load_filerVappend)rY config_filesrLfilesrtrus r&r\z Configuration._load_config_filessD224455  "1Q3 'BJ< 7 7 LLA    F*0022 ? ?NGU ? ?>-'T^2K2KLL!CUGTTT%88 g&--ufo>>>> ? ? ?r(rLrtc(td||||}|D]K}||}|j||||L|S)Nz'For variant '%s', will try loading '%s')r~verbose_construct_parsersectionsrfrWr_normalized_keys)rYrLrtrurvrfs r&rzConfiguration._load_file s@'5QQQ''..(( P PGLL))E L ! ( ()>)>w)N)N O O O O r(cNtj}tj|rrt jd} |||nE#t$rtd|d|tj $r}t|d}~wwxYw|S)NF)encodingzcontains invalid z characters)reasonrt)r) configparserRawConfigParserr2r3existslocalegetpreferredencodingreadUnicodeDecodeErrorr Error)rYrtrulocale_encodingrs r&rzConfiguration._construct_parsers-// 7>>% E$9%@@O E EO <<<<%   7KKKK % E E E7eDDDD E sA -B" BB"c|jtj|d|dS)z.Loads configuration from environment variablesz:env:N)rWr?rrrget_environ_varsr^s r&r]z$Configuration._load_environment_vars*sL U]#**  ! !'4+@+@+B+B C C     r(rvrfcNi}|D]\}}|dzt|z}|||< |S)zNormalizes items to construct a dictionary with normalized keys. This routine is where the names become keys and are made the same regardless of source - configuration files or environment. r*)r')rYrvrf normalizedrvalrgs r&rzConfiguration._normalized_keys0sC  " "ID#C-/$"7"77C!JsOOr(c#KtjD]E\}}|dr+|dd}|t vr||fVFdS)z@Returns a generator with all environmental vars with prefix PIP_PIP_N)r2environrfr%r#ENV_NAMES_IGNORED)rYrgrrs r&rzConfiguration.get_environ_vars>st ((** $ $HC~~f%% $122w}}000)OOO  $ $r(c#Ktjdd}t}tj|tjfV|j o!|otj| }|r tj |tj fVtj |tj fV|tj |gfVdStj gfVdS)aYields variant and configuration files associated with it. This should be treated like items of a dictionary. The order here doesn't affect what gets overridden. That is controlled by OVERRIDE_ORDER. However this does control the order they are displayed to the user. It's probably most ergononmic to display things in the same order as OVERRIDE_ORDER PIP_CONFIG_FILEN) r2rgetrDr?rrGr3rrrr)rYenv_config_filershould_load_user_configs r&rzConfiguration.iter_config_filesGs*..):DAA.00 lL66666'+m"3#  ? ? ?9  # 7*l5:66 6 6 6j,uz22222  &)o.. . . . . .)R-     r(c|j|S)z#Get values present in a config file)rW)rYrLs r&get_values_in_configz"Configuration.get_values_in_configgs|G$$r(cj|jsJ|j|j}|std|dS)Nz4Fatal Internal error [id=2]. Please report as a bug.)rHrVr )rYparserss r&raz#Configuration._get_parser_to_modifyksF~~-/ $F  r{r(rucX||f}||jvr|j|dSdSN)rXr)rYrtrufile_parser_tuples r&rszConfiguration._mark_as_modifiedys@"FO D$: : :  " ) )*; < < < < < ; :r(c0|jjd|jdS)N())rZ__name__rer^s r&__repr__zConfiguration.__repr__~s!.)AAD,<AAAAr(r)rN)%r __module__ __qualname____doc__boolrrrPr_strrcrr rrfrlrwr{rropropertyrrer\rrrr]rrrrrrarsr __classcell__)rZs@r&rFrFWs>  GGG(4.GDGGGGGG***** (3-(xc3h0(((( BS BS B B B B.S......&.s.t....:0MMMM  T#s(^   X ????.$ss*     #+E#s(O#<  c3h    $(5c?";$$$$ 8E$S /,B#C    @%D%T#s(^%%%% uS/-A'B    =s=O===== B#BBBBBBBBr(rF),rrrr2r;typingrrrrrrr pip._internal.exceptionsr r pip._internal.utilsr pip._internal.utils.compatr pip._internal.utils.loggingrpip._internal.utils.miscrrrrrr5rr?rrrrrrUrQrr~r'r.rDrFr1r(r&rs-   FFFFFFFFFFFFFFFFFF('''''......11111155555555.wvs&6))J%         uz5:uy%-O*elEJ6 8  ##349dDIo!6&hBhBhBhBhBhBhBhBhBhBr(