ó BuÆ_c@sddlZddlZddlZddlmZddlmZmZddlm Z m Z m Z ddl m Z ddlmZddlmZmZddlmZerñdd lmZmZmZdd lmZdd lmZnejeƒZd efd „ƒYZdS(iÿÿÿÿN(tCommand(tERRORtSUCCESS(t Configurationtget_configuration_filestkinds(tPipError(t indent_log(tget_progt write_output(tMYPY_CHECK_RUNNING(tListtAnytOptional(tValues(tKindtConfigurationCommandcBs˜eZdZeZdZd„Zd„Zd„Zd„Z d„Z d„Z d„Z d „Z d „Zd „Zd „Zd „Zd„Zd„ZRS(sh 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 on the to the user file by default. s %prog [] list %prog [] [--editor ] edit %prog [] get name %prog [] set name value %prog [] unset name %prog [] debug c Csº|jjdddddddddƒ|jjd dd dd dtdd ƒ|jjd dddd dtddƒ|jjddddd dtddƒ|jjd|jƒdS(Ns--editortdestteditortactiontstoretdefaultthelps\Editor to use to edit the file. Uses VISUAL or EDITOR environment variables if not provided.s--globalt global_filet store_trues+Use the system-wide configuration file onlys--usert user_files$Use the user configuration file onlys--sitet site_files3Use the current environment configuration file onlyi(tcmd_optst add_optiontNonetFalsetparsertinsert_option_group(tself((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/commands/configuration.pyt add_options8s2    c Cs@i|jd6|jd6|jd6|jd6|jd6|jd6}| sY|d|kr|tjdd jt |ƒƒƒt S|d}y|j |d |dkƒ}Wn(t k rÏ}tj|j dƒt SXtd |jd |ƒ|_|jjƒy||||d ƒWn(t k r;}tj|j dƒt SXtS(NtlisttedittgettsettunsettdebugisNeed an action (%s) to perform.s, t need_valuetisolatedt load_onlyi(sgetssetR'R$(t list_valuestopen_in_editortget_nametset_name_valuet unset_nametlist_config_valuestloggerterrortjointsortedRt_determine_fileRtargsRt isolated_modet configurationtloadR(R!toptionsR7thandlersRR+te((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/commands/configuration.pytrun_s8        cCs½gtj|jftj|jftj|jffD]\}}|r4|^q4}|s“|sbdStd„t ƒtjDƒƒr‰tjStjSnt |ƒdkr­|dSt dƒ‚dS(Ncss!|]}tjj|ƒVqdS(N(tostpathtexists(t.0tsite_config_file((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/commands/configuration.pys šsiisLNeed exactly one file to operate upon (--user, --site, --global) to perform.( RtUSERRtGLOBALRtSITERRtanyRtlenR(R!R;R)tkeytvaluet file_options((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/commands/configuration.pyR6s" cCsP|j|dddƒx3t|jjƒƒD]\}}td||ƒq,WdS(NR#tnis%s=%r(t _get_n_argsR5R9titemsR (R!R;R7RIRJ((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/commands/configuration.pyR,¨s"cCs;|j|dddƒ}|jj|ƒ}td|ƒdS(Ns get [name]RLis%s(RMR9t get_valueR (R!R;R7RIRJ((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/commands/configuration.pyR.¯scCs?|j|dddƒ\}}|jj||ƒ|jƒdS(Nsset [name] [value]RLi(RMR9t set_valuet_save_configuration(R!R;R7RIRJ((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/commands/configuration.pyR/¶scCs6|j|dddƒ}|jj|ƒ|jƒdS(Ns unset [name]RLi(RMR9t unset_valueRQ(R!R;R7RI((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/commands/configuration.pyR0½sc Cs°|j|dddƒ|jƒx‰t|jjƒƒD]r\}}td|ƒxV|D]N}tƒ=tjj |ƒ}td||ƒ|rž|j |ƒnWdQXqVWq6WdS(s9List config key-value pairs across different config filesR(RLis%s:s%s, exists: %rN( RMtprint_env_var_valuesR5R9titer_config_filesR RR?R@RAtprint_config_file_values(R!R;R7tvarianttfilestfnamet file_exists((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/commands/configuration.pyR1Äs "    c CsMxF|jj|ƒjƒD],\}}tƒtd||ƒWdQXqWdS(s.Get key-value pairs from the file of a variants%s: %sN(R9tget_values_in_configRNRR (R!RVtnameRJ((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/commands/configuration.pyRUÖs  c CsltddƒtƒPxHt|jjƒƒD]1\}}dj|jƒƒ}td||ƒq-WWdQXdS(s5Get key-values pairs present as environment variabless%s:tenv_varsPIP_{}s%s=%rN(R RR5R9tget_environ_varstformattupper(R!RIRJR\((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/commands/configuration.pyRSÞs   "cCs…|j|ƒ}|jjƒ}|dkr9tdƒ‚nytj||gƒWn.tjk r€}tdj|j ƒƒ‚nXdS(Ns%Could not determine appropriate file.s*Editor Subprocess exited with exit code {}( t_determine_editorR9tget_file_to_editRRt subprocesst check_calltCalledProcessErrorR^t returncode(R!R;R7RRXR=((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/commands/configuration.pyR-çs cCsUt|ƒ|kr9dj|tƒ|ƒ}t|ƒ‚n|dkrM|dS|SdS(sJHelper to make sure the command got the right number of arguments sJGot unexpected number of arguments, expected {}. (example: "{} config {}")iiN(RHR^RR(R!R7texampleRLtmsg((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/commands/configuration.pyRM÷s cCsBy|jjƒWn*tk r=tjdƒtdƒ‚nXdS(Ns:Unable to save configuration. Please report this as a bug.sInternal Error.(R9tsavet ExceptionR2t exceptionR(R!((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/commands/configuration.pyRQs  cCsZ|jdk r|jSdtjkr0tjdSdtjkrJtjdStdƒ‚dS(NtVISUALtEDITORs"Could not determine editor to use.(RRR?tenvironR(R!R;((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/commands/configuration.pyR`s  (t__name__t __module__t__doc__tTruetignore_require_venvtusageR"R>R6R,R.R/R0R1RURSR-RMRQR`(((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/commands/configuration.pyRs"  ' .          ( tloggingR?Rbtpip._internal.cli.base_commandRtpip._internal.cli.status_codesRRtpip._internal.configurationRRRtpip._internal.exceptionsRtpip._internal.utils.loggingRtpip._internal.utils.miscRR tpip._internal.utils.typingR ttypingR R R toptparseRRt getLoggerRnR2R(((sU/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/commands/configuration.pyts