Re"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)ConfigurationCommandaa 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 name - set: Set the name=value - unset: Unset the value associated with name - debug: List the configuration files and values defined under them 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 name %prog [] set name value %prog [] unset name %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/BUILDROOT/alt-python311-pip-21.3.1-3.el8.x86_64/opt/alt/python311/lib/python3.11/site-packages/pip/_internal/commands/configuration.py add_optionsz ConfigurationCommand.add_options4s   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.runZs$'=&_,    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}|td t j||gdS#tj$r,}td|jd}~wwxYw)Nz%Could not determine appropriate file.z*Editor Subprocess exited with exit code {}) _determine_editorrBget_file_to_editr subprocess check_callCalledProcessErrorformat returncode)r%r)r*rrprEs r&r7z#ConfigurationCommand.open_in_editors''00"3355 =BCC C   !65/ 2 2 2 2 2,   <CCALQQ  sAB('BBexampler\ct||kr2d|t|}t||dkr|dS|S)zAHelper to make sure the command got the right number of argumentszJGot unexpected number of arguments, expected {}. (example: "{} config {}")r5r)rXrrr)r%r*rr\msgs r&r^z ConfigurationCommand._get_n_argssU t99>>,fQ G,, 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&rrsS$ E$:$:$:$:L+6+c+s++++Z v 4 HTN    <.6.c.t.... ""d3i"D"""" #f#DI#$#### #&#S #d#### ?&?S ?d???? 444444 6666 f DI $     S C C C     . . . .AACAAAAAAr(r)loggingrOr}optparsertypingrrrpip._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 $ $tAtAtAtAtA7tAtAtAtAtAr(