I iy'ddlmZddlZddlZddlZddlmZddlmZm Z ddl m Z ddl m Z mZddlmZmZmZmZddlmZdd lmZdd lmZmZej6eZGd d e Zy) ) annotationsN)Values)AnyCallable)Command)ERRORSUCCESS) ConfigurationKindget_configuration_fileskinds)PipError) indent_log)get_prog write_outputceZdZdZdZdZddZddZddZddZ ddZ dd Z dd Z dd Z dd Zdd ZddZddZddZddZddZy)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 cP|jjddddd|jjdddd d |jjd d dd d |jjdddd d|jjd|jy)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 j/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pip/_internal/commands/configuration.py add_optionsz ConfigurationCommand.add_options<s   9 !    > !    7 !    F !  ''4==9c|j|j|j|j|j|j dS)N)listeditgetsetunsetdebug) list_valuesopen_in_editorget_nameset_name_value unset_namelist_config_valuesr#s r% handler_mapz ConfigurationCommand.handler_mapbs>$$''==&&__,,   r'cb|j}|r|d|vr4tjddjt |t S|d} |j ||dv}t|j||_ |jj ||||ddtS#t$r2}tj|jdt cYd}~Sd}~wwxYw#t$r2}tj|jdt cYd}~Sd}~wwxYw)NrzNeed an action (%s) to perform.z, )r+r,r-r*) need_value)isolated load_only)r5loggererrorjoinsortedr_determine_filerargsr isolated_mode configurationloadr )r$optionsr@r5rr9es r%runzConfigurationCommand.runls&&( tAwk1 LL1 &-. La ,,V/N%N-I+**i  !  K ab 2 #  LL #L   LL #L s<B5 C35 C0>'C+%C0+C03 D.<'D)#D.)D.ctj|jftj|jftj |j ffDcgc] \}}|r| }}}|sN|sytdttj Drtj StjSt|dk(r|dStdcc}}w)Nc3ZK|]#}tjj|%yw)N)ospathexists).0site_config_files r% z7ConfigurationCommand._determine_file..s&$/0s)+r:rzLNeed exactly one file to operate upon (--user, --site, --global) to perform.) r USERrGLOBALrSITEranyr lenr)r$rDr7keyvalue file_optionss r%r?z$ConfigurationCommand._determine_filesW../w223W../ U    (?(A%**(Mzz!zz!  ! #? " 5  1 sCc|j|ddt|jjD]3\}}t|jD]\}}t d||5y)Nr)rn%s=%r) _get_n_argsr>rBitemsrr$rDr@rTrUs r%r/z ConfigurationCommand.list_valuessh v+ !3!3!9!9!;< 2JC$U[[]3 2 UWc51 2 2r'cz|j|dd}|jj|}td|y)Nz get [name]r:rXz%s)r[rB get_valuerr]s r%r1zConfigurationCommand.get_names9t\Q7"",,S1T5!r'c|j|dd\}}|jj|||jy)Nzset [name] [value]rX)r[rB set_value_save_configurationr]s r%r2z#ConfigurationCommand.set_name_values@%%d,@A%F U $$S%0   "r'c|j|dd}|jj||jy)Nz unset [name]r:rX)r[rB unset_valuerc)r$rDr@rTs r%r3zConfigurationCommand.unset_names9t^q9 &&s+   "r'c|j|dd|jt|jj D]k\}}t d||D]U}t 5tjj|}t d|||r|j||dddWmy#1swYdxYw)z9List config key-value pairs across different config filesr.rrX%s:z%s, exists: %rN) r[print_env_var_valuesr>rBiter_config_filesrrrIrJrKprint_config_file_values)r$rDr@variantfilesfname file_existss r%r4z'ConfigurationCommand.list_config_valuess w!, !!#%T%7%7%I%I%KL FNGU  ( F\F"$''.."7K !15+F"55guE FF F FFFs )AB77C c|jj|jD]B\}}t5||k(r%|jD]\}}t d||dddDy#1swYOxYw)z.Get key-value pairs from the file of a variantz%s: %sN)rBget_values_in_configr\rr)r$rkrmnamerUconfname confvalues r%rjz-ConfigurationCommand.print_config_file_valuess--BB7KQQS DKD% D5=/4{{}D+)$XxCD D D D D Ds +A00A9 ctddt5t|jj D]%\}}d|j }td||' dddy#1swYyxYw)z5Get key-values pairs present as environment variablesrgenv_varPIP_rZN)rrr>rBget_environ_varsupper)r$rTrUrus r%rhz)ConfigurationCommand.print_env_var_valuesskUI& \ 6$T%7%7%H%H%JK 6 U  .Wgu5 6 6 6 6s A A--A6cz|j|}|jj}| tdd|vrtd| t j |d|ddy#t $r}|js||_d}~wtj$r}td|jd}~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$rDr@rrmrEs r%r0z#ConfigurationCommand.open_in_editors''0""335 =BC C E\GwO  V  ! !VHBugQ"7t D  ::# ,, VEall^TU U Vs$ A** B:3BB:B55B:ctt||k7rd|dtd|d}t||dk(r|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")r:r)rSrr)r$r@examplerYmsgs r%r[z ConfigurationCommand._get_n_argssT t9>?sC&j\'"> 3-  67NKr'c |jjy#t$r!tj dt dwxYw)Nz:Unable to save configuration. Please report this as a bug.zInternal Error.)rBsave Exceptionr; exceptionrr#s r%rcz(ConfigurationCommand._save_configuration sG .    # # % .   L ,- -  .s *Ac|j |jSdtjvrtjdSdtjvrtjdStd)NVISUALEDITORz"Could not determine editor to use.)rrIenvironr)r$rDs r%r|z&ConfigurationCommand._determine_editorsX >> %>> !  #::h' '  #::h' '?@ @r'N)returnNone)rz.dict[str, Callable[[Values, list[str]], None]])rDrr@ list[str]rint)rDrr7boolrz Kind | None)rDrr@rrr)rkr rmstrrr)r@rrrrYrrr)rDrrr)__name__ __module__ __qualname____doc__ignore_require_venvusager&r5rFr?r/r1r2r3r4rjrhr0r[rcr|r'r%rrsg0 E$:L $L <2" # # F D6V,  .Ar'r) __future__rloggingrIr~optparsertypingrrpip._internal.cli.base_commandrpip._internal.cli.status_codesrr pip._internal.configurationr r r r pip._internal.exceptionsrpip._internal.utils.loggingrpip._internal.utils.miscrr getLoggerrr;rrr'r%rsT"  29 .2;   8 $HA7HAr'