ó â\e[c@s¹ddlZddlZddlZddlmZddlmZmZddlm Z ddl m Z ddl m Z mZddlmZejeƒZdefd „ƒYZdS( iÿÿÿÿN(tCommand(t Configurationtkinds(tPipError(tvenv_config_file(tERRORtSUCCESS(tget_progtConfigurationCommandcBsƒeZdZdZdZdZd„Zd„Zd„Zd„Z d„Z d „Z d „Z d „Z d „Zd „Zd„ZRS(s9Manage 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 If none of --user, --global and --venv 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. tconfigsâ %prog [] list %prog [] [--editor ] edit %prog [] get name %prog [] set name value %prog [] unset name s&Manage local and global configuration.c OsÜtt|ƒj||Žd|_|jjdddddddddƒ|jjd dd dd dtdd ƒ|jjd dddd dtddƒ|jjddddd dtddƒ|jj d|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--venvt venv_files*Use the virtualenv configuration file onlyi( tsuperRt__init__tNonet configurationtcmd_optst add_optiontFalsetparsertinsert_option_group(tselftargstkwargs((sC/tmp/pip-install-0xiv62/pip/pip/_internal/commands/configuration.pyR,s6     cCs<i|jd6|jd6|jd6|jd6|jd6}| sO|d|krxtjdjdjt |ƒƒƒƒt S|d}y|j |d |d kƒ}Wn(t k rË}tj|j dƒt SXtd |jd |ƒ|_|jjƒy||||d ƒWn(t k r7}tj|j dƒt SXtS(NtlisttedittgettsettunsetisNeed an action ({}) to perform.s, t need_valuetisolatedt load_onlyi(sgetssetsunsetsedit(t list_valuestopen_in_editortget_nametset_name_valuet unset_nametloggerterrortformattjointsortedRt_determine_fileRRRt isolated_modeRtloadR(RtoptionsRthandlersR R'te((sC/tmp/pip-install-0xiv62/pip/pip/_internal/commands/configuration.pytrunVs4        cCs¿i|jtj6|jtj6|jtj6}t|jƒƒdkrr|sOdSt j j t ƒrhtjStjSn=t|jƒƒdkr¯g|D]}||r‘|^q‘dStdƒ‚dS(NiisLNeed exactly one file to operate upon (--user, --venv, --global) to perform.(RRtUSERRtGLOBALRtVENVtsumtvaluesRtostpathtexistsRR(RR5R%t file_optionstkey((sC/tmp/pip-install-0xiv62/pip/pip/_internal/commands/configuration.pyR2s   %cCsS|j|dddƒx6t|jjƒƒD]\}}tjd||ƒq,WdS(NR tnis%s=%r(t _get_n_argsR1RtitemsR-tinfo(RR5RRBtvalue((sC/tmp/pip-install-0xiv62/pip/pip/_internal/commands/configuration.pyR(™s"cCs>|j|dddƒ}|jj|ƒ}tjd|ƒdS(Ns get [name]RCis%s(RDRt get_valueR-RF(RR5RRBRG((sC/tmp/pip-install-0xiv62/pip/pip/_internal/commands/configuration.pyR*ŸscCs?|j|dddƒ\}}|jj||ƒ|jƒdS(Nsset [name] [value]RCi(RDRt set_valuet_save_configuration(RR5RRBRG((sC/tmp/pip-install-0xiv62/pip/pip/_internal/commands/configuration.pyR+¥scCs6|j|dddƒ}|jj|ƒ|jƒdS(Ns unset [name]RCi(RDRt unset_valueRJ(RR5RRB((sC/tmp/pip-install-0xiv62/pip/pip/_internal/commands/configuration.pyR,«scCs…|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_editorRtget_file_to_editRRt subprocesst check_calltCalledProcessErrorR/t returncode(RR5RR tfnameR7((sC/tmp/pip-install-0xiv62/pip/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(tlenR/RR(RRtexampleRCtmsg((sC/tmp/pip-install-0xiv62/pip/pip/_internal/commands/configuration.pyRDÀs cCsHy|jjƒWn0tk rCtjdddƒtdƒ‚nXdS(Ns:Unable to save configuration. Please report this as a bug.texc_infoisInternal Error.(Rtsavet ExceptionR-R.R(R((sC/tmp/pip-install-0xiv62/pip/pip/_internal/commands/configuration.pyRJÏs cCsZ|jdk r|jSdtjkr0tjdSdtjkrJtjdStdƒ‚dS(NtVISUALtEDITORs"Could not determine editor to use.(R RR>tenvironR(RR5((sC/tmp/pip-install-0xiv62/pip/pip/_internal/commands/configuration.pyRLÛs  (t__name__t __module__t__doc__tnametusagetsummaryRR8R2R(R*R+R,R)RDRJRL(((sC/tmp/pip-install-0xiv62/pip/pip/_internal/commands/configuration.pyRs * +        (tloggingR>RNtpip._internal.basecommandRtpip._internal.configurationRRtpip._internal.exceptionsRtpip._internal.locationsRtpip._internal.status_codesRRtpip._internal.utils.miscRt getLoggerR\R-R(((sC/tmp/pip-install-0xiv62/pip/pip/_internal/commands/configuration.pyts