U n a&@sddlZddlZddlZddlmZddlmZmZddlm Z m Z m Z ddl m Z ddlmZmZeeZGdddeZdS) N)Command)ERRORSUCCESS) Configurationget_configuration_fileskinds)PipError)get_prog write_outputcsxeZdZdZdZdZfddZddZdd Zd d Z d d Z ddZ ddZ ddZ ddZddZddZZS)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 name set: Set the name=value unset: Unset the value associated with name 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. Tz %prog [] list %prog [] [--editor ] edit %prog [] get name %prog [] set name value %prog [] unset name cstt|j||d|_|jjdddddd|jjdddd d d|jjd d dd d d|jjdddd dd|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)superr __init__ configurationcmd_opts add_optionparserinsert_option_group)selfargskwargs __class__eC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-6mt8ur68\pip\_internal\commands\configuration.pyr0s> zConfigurationCommand.__init__c Cs|j|j|j|j|jd}|r*|d|krHtddt |t S|d}z|j ||dkd}Wn:t k r}zt|j dt WYSd}~XYnXt|j|d|_|jz||||ddWn<t k r}zt|j dt WYSd}~XYnXtS) N)listeditgetsetunsetrzNeed an action ({}) to perform.z, )r&r'r(r%) need_value)isolated load_only) list_valuesopen_in_editorget_nameset_name_value unset_nameloggererrorformatjoinsortedr_determine_filerrr isolated_moderloadr)roptionsrhandlersrr+er"r"r#runZs>    zConfigurationCommand.runcCsddtj|jftj|jftj|jffD}|s`|s8dStddttjDrXtjStjSnt |dkrt|dSt ddS)NcSsg|]\}}|r|qSr"r").0keyvaluer"r"r# sz8ConfigurationCommand._determine_file..css|]}tj|VqdS)N)ospathexists)r>site_config_filer"r"r# sz7ConfigurationCommand._determine_file..r,rzLNeed exactly one file to operate upon (--user, --site, --global) to perform.) rUSERrGLOBALrSITEranyrlenr)rr:r)Z file_optionsr"r"r#r7s$     z$ConfigurationCommand._determine_filecCs8|j|dddt|jD]\}}td||qdS)Nr$rnz%s=%r) _get_n_argsr6ritemsr rr:rr?r@r"r"r#r-sz ConfigurationCommand.list_valuescCs*|j|ddd}|j|}td|dS)Nz get [name]r,rLz%s)rNr get_valuer rPr"r"r#r/s zConfigurationCommand.get_namecCs.|j|ddd\}}|j|||dS)Nzset [name] [value]rL)rNr set_value_save_configurationrPr"r"r#r0sz#ConfigurationCommand.set_name_valuecCs(|j|ddd}|j||dS)Nz unset [name]r,rL)rNr unset_valuerT)rr:rr?r"r"r#r1s zConfigurationCommand.unset_namec Csp||}|j}|dkr$tdzt||gWn4tjk rj}ztd|jW5d}~XYnXdS)Nz%Could not determine appropriate file.z*Editor Subprocess exited with exit code {}) _determine_editorrget_file_to_editr subprocess check_callCalledProcessErrorr4 returncode)rr:rr fnamer<r"r"r#r.s  z#ConfigurationCommand.open_in_editorcCs<t||kr$d|t|}t||dkr4|dS|SdS)zJHelper to make sure the command got the right number of arguments zJGot unexpected number of arguments, expected {}. (example: "{} config {}")r,rN)rKr4r r)rrZexamplerMmsgr"r"r#rNs z ConfigurationCommand._get_n_argscCs>z|jWn*tk r8tjdddtdYnXdS)Nz:Unable to save configuration. Please report this as a bug.r,)exc_infozInternal Error.)rsave Exceptionr2r3r)rr"r"r#rTsz(ConfigurationCommand._save_configurationcCsD|jdk r|jSdtjkr$tjdSdtjkr8tjdStddS)NZVISUALZEDITORz"Could not determine editor to use.)r rBenvironr)rr:r"r"r#rVs     z&ConfigurationCommand._determine_editor)__name__ __module__ __qualname____doc__ignore_require_venvusagerr=r7r-r/r0r1r.rNrTrV __classcell__r"r"r r#r s *+ r )loggingrBrXpip._internal.cli.base_commandrpip._internal.cli.status_codesrrpip._internal.configurationrrrpip._internal.exceptionsrpip._internal.utils.miscr r getLoggerrbr2r r"r"r"r#s