h&&ddlZddlZddlZddlmZddlmZmZmZddl m Z ddl m Z m Z ddlmZmZmZmZddlmZddlmZdd lmZmZejeZGd d e ZdS) N)Values)AnyListOptional)Command)ERRORSUCCESS) ConfigurationKindget_configuration_fileskinds)PipError) indent_log)get_prog write_outputcveZdZdZdZdZddZdedee de fd Z ded e de efd Zdedee ddfd Zdedee ddfd Zdedee ddfdZdedee ddfdZdedee ddfdZdeddfdZddZdedee ddfdZdee de de defdZddZdede fdZdS)ConfigurationCommanda Manage local and global configuration. Subcommands: - list: List the active configuration (or from the file specified) - edit: Edit the configuration file in an editor - get: Get the value associated with command.option - set: Set the command.option=value - unset: Unset the value associated with command.option - debug: List the configuration files and values defined under them Configuration keys should be dot separated command and option name, with the special prefix "global" affecting any command. For example, "pip config set global.index-url https://example.org/" would configure the index url for all commands, but "pip config set download.timeout 10" would configure a 10 second timeout only for "pip download" commands. If none of --user, --global and --site are passed, a virtual environment configuration file is used if one is active and the file exists. Otherwise, all modifications happen to the user file by default. Ta$ %prog [] list %prog [] [--editor ] edit %prog [] get command.option %prog [] set command.option value %prog [] unset command.option %prog [] debug returnNc>|jddddd|jdddd d |jd d dd d |jdddd d|jd|jdS)Nz--editoreditorstorez\Editor to use to edit the file. Uses VISUAL or EDITOR environment variables if not provided.)destactiondefaulthelpz--global global_file store_trueFz+Use the system-wide configuration file onlyz--user user_filez$Use the user configuration file onlyz--site site_filez3Use the current environment configuration file onlyr)cmd_opts add_optionparserinsert_option_groupselfs /builddir/build/BUILD/imunify360-venv-2.5.2/opt/imunify360/venv/lib/python3.11/site-packages/pip/_internal/commands/configuration.py add_optionsz ConfigurationCommand.add_options:s   9 !    > !      7 !      F !    ''4=99999optionsargsc|j|j|j|j|j|jd}|r |d|vrBt ddt|tS|d} | ||dv}nC#t$r6}t |j dtcYd}~Sd}~wwxYwt|j||_|j ||||ddnC#t$r6}t |j dtcYd}~Sd}~wwxYwt$S) N)listeditgetsetunsetdebugrzNeed an action (%s) to perform.z, )r.r/r0r-) need_value)isolated load_only) list_valuesopen_in_editorget_nameset_name_value unset_namelist_config_valuesloggererrorjoinsortedr_determine_filerr*r isolated_mode configurationloadr )r%r)r*handlersrr4es r&runzConfigurationCommand.run`s$'=&_,    tAwh.. LL1 &**++   La ,,V/N%N-II    LL # # #LLLLLL  +*i    !!!  HV Wd122h / / / /    LL # # #LLLLLL s<?B C#+CCCD,, E,6+E'!E,'E,r2cdtj|jftj|jftj|jffD}|sQ|sdStdttjDr tjStjSt|dkr|dStd)Ncg|] \}}|| SrI).0keyvalues r& z8ConfigurationCommand._determine_file..s4   U     r(c3TK|]#}tj|V$dS)N)ospathexists)rJsite_config_files r& z7ConfigurationCommand._determine_file..sE$/00r(r5rzLNeed exactly one file to operate upon (--user, --site, --global) to perform.) r USERrGLOBALrSITEranyr lenr)r%r)r2 file_optionss r&r@z$ConfigurationCommand._determine_files  W./w23W./    # "t(?(A(A%*(M "z!z!   ! # #? " 5   r(c||ddt|jD]\}}t d||dS)Nr,rn%s=%r) _get_n_argsr?rBitemsrr%r)r*rKrLs r&r6z ConfigurationCommand.list_valuessf v+++ !3!9!9!;!;<< . .JC #u - - - - . .r(c||dd}|j|}td|dS)Nz get [name]r5r[z%s)r^rB get_valuerr`s r&r8zConfigurationCommand.get_namesHt\Q77",,S11T5!!!!!r(c||dd\}}|j|||dS)Nzset [name] [value]r[)r^rB set_value_save_configurationr`s r&r9z#ConfigurationCommand.set_name_valuesR%%d,@A%FF U $$S%000   """""r(c||dd}|j||dS)Nz unset [name]r5r[)r^rB unset_valuerf)r%r)r*rKs r&r:zConfigurationCommand.unset_namesKt^q99 &&s+++   """""r(c||dd|t|jD]\}}t d||D]o}t 5tj |}t d|||r| |dddn #1swxYwYpdS)z9List config key-value pairs across different config filesr1rr[%s:z%s, exists: %rN) r^print_env_var_valuesr?rBiter_config_filesrrrOrPrQprint_config_file_values)r%r)r*variantfilesfname file_existss r&r;z'ConfigurationCommand.list_config_valuess+ w!,,, !!###%T%7%I%I%K%KLL ? ?NGU  ( ( ( ? ?\\??"$'.."7"7K !15+FFF"?55g>>> ??????????????? ? ? ?s:ACC C rnc|j|D]<\}}t5t d||dddn #1swxYwY=dS)z.Get key-value pairs from the file of a variantz%s: %sN)rBget_values_in_configr_rr)r%rnnamerLs r&rmz-ConfigurationCommand.print_config_file_valuess-BB7KKQQSS 4 4KD% 4 4XtU333 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4sAA" %A" ctddt5t|jD]-\}}d|}td||. ddddS#1swxYwYdS)z5Get key-values pairs present as environment variablesrjenv_varPIP_r]N)rrr?rBget_environ_varsupper)r%rKrLrvs r&rkz)ConfigurationCommand.print_env_var_valuessUI&&& \\ 6 6$T%7%H%H%J%JKK 6 6 U...Wgu5555 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6sABB Bc~||}|j}|tdd|vrtd| t j|d|dddS#t $r}|js||_d}~wtj$r}td|j d}~wwxYw)Nz%Could not determine appropriate file."z4Can not open an editor for a file name containing " z "T)shellz(Editor Subprocess exited with exit code ) _determine_editorrBget_file_to_editr subprocess check_callFileNotFoundErrorfilenameCalledProcessError returncode)r%r)r*rrprEs r&r7z#ConfigurationCommand.open_in_editors''00"3355 =BCC C E\\OOO  V  !V"7"7u"7"7"7t D D D D D D    : $# , V V VTalTTUU U Vs$A55 B<?BB< B77B<exampler\ct||kr'd|dtd|d}t||dkr|dS|S)zAHelper to make sure the command got the right number of argumentsz-Got unexpected number of arguments, expected z . (example: "z config z")r5r)rXrr)r%r*rr\msgs r&r^z ConfigurationCommand._get_n_argsso t99>>>>>&jj>>29>>> 3--  667NKr(c |jdS#t$r*tdt dwxYw)Nz:Unable to save configuration. Please report this as a bug.zInternal Error.)rBsave Exceptionr< exceptionrr$s r&rfz(ConfigurationCommand._save_configurationsi .   # # % % % % % . . .   L   ,-- -  .s 4Ac|j|jSdtjvrtjdSdtjvrtjdStd)NVISUALEDITORz"Could not determine editor to use.)rrOenvironr)r%r)s r&r}z&ConfigurationCommand._determine_editorsU > %> !  # #:h' '  # #:h' '?@@ @r()rN)__name__ __module__ __qualname____doc__ignore_require_venvusager'rrstrintrFboolrr r@r6r8r9r:r;rmrkr7rr^rfr}rIr(r&rrsZ0 E$:$:$:$:L+6+c+s++++Z v 4 HTN    <.6.c.t.... ""d3i"D"""" #f#DI#$#### #&#S #d#### ?&?S ?d???? 444444 6666VfVDIV$VVVV, S C C C     . . . .AACAAAAAAr(r)loggingrOroptparsertypingrrrpip._internal.cli.base_commandrpip._internal.cli.status_codesrr pip._internal.configurationr r r r pip._internal.exceptionsrpip._internal.utils.loggingrpip._internal.utils.miscrr getLoggerrr<rrIr(r&rsQ &&&&&&&&&&22222299999999 .-----222222;;;;;;;;  8 $ $BABABABABA7BABABABABAr(