o gs3@sBdZddlZddlZddlZddlZddlmZmZmZm Z m Z m Z m Z ddl mZmZddlmZddlmZddlmZddlmZmZejZe d eZerRd nd Zd Zed dddddZejej ej!ej"ej#fZ$ej ejej!fZ%ee&Z'dedefddZ(dede efddZ)deee effddZ*GdddZ+dS)a Configuration management setup Some terminology: - name As written in config files. - value Value associated with a name - key Name combined with it's section (section.name) - variant A single word describing where the configuration key-value pair came from N)AnyDictIterableListNewTypeOptionalTuple)ConfigurationError!ConfigurationFileCouldNotBeLoaded)appdirs)WINDOWS) getLogger) ensure_direnumKindzpip.inizpip.conf)versionhelpuserglobalsiteenvzenv-var)USERGLOBALSITEENVENV_VARnamereturncCs*|dd}|dr|dd}|S)zAMake a name consistent regardless of source (environment or file)_-z--N)lowerreplace startswith)rr$=/usr/lib/python3/dist-packages/pip/_internal/configuration.py_normalize_name2s  r&cCs&d|vr d|}t||ddS)N.zbKey does not contain dot separated section and key. Perhaps you wanted to use 'global.{}' instead?)formatr split)r error_messager$r$r%_disassemble_key:s  r,cCstddtdD}tjtjt}tjtjdt rdndt}tjt dt}t j |t j |gt j||giS)NcSsg|] }tj|tqSr$)ospathjoinCONFIG_BASENAME).0r.r$r$r% Esz+get_configuration_files..pip~z.pip)r site_config_dirsr-r.r/sysprefixr0 expanduserr user_config_dirkindsrrr)global_config_filessite_config_filelegacy_config_filenew_config_filer$r$r%get_configuration_filesDs   r?cseZdZdZd7dedeeddffdd Zd8dd Zdee fd d Z de e e e ffd d Zde de fddZde de ddfddZde ddfddZd8ddZd8ddZedee e ffddZd8ddZdede defd d!Zde defd"d#Zd8d$d%Zd&e d'e e e e fdee e ffd(d)Zde e e e ffd*d+Zde e eee ffd,d-Zdedee e ffd.d/Z de e effd0d1Z!de d2eddfd3d4Z"de fd5d6Z#Z$S)9 ConfigurationaHandles management of configuration. Provides an interface to accessing and managing configuration files. This class converts provides an API that takes "section.key-name" style keys and stores the value associated with it as "key-name" under the section "section". This allows for a clean interface wherein the both the section and the key-name are preserved in an easy to manage form in the configuration files and the data stored is also nice. Nisolated load_onlyrcsjt|dur|tvrtddttt||_||_ ddt D|_ ddt D|_ g|_ dS)Nz5Got invalid value for load_only - should be one of {}z, cSsi|]}|gqSr$r$r1variantr$r$r% rz*Configuration.__init__..cSsi|]}|iqSr$r$rCr$r$r%rEurF)super__init__VALID_LOAD_ONLYr r)r/mapreprrArBOVERRIDE_ORDER_parsers_config_modified_parsers)selfrArB __class__r$r%rHes  zConfiguration.__init__cCs||js |dSdS)ztj |tj fVtj |tj fVdS)zYields variant and configuration files associated with it. This should be treated like items of a dictionary. PIP_CONFIG_FILEN) r-rgetr:rr?rrAr.rrr)rP config_filer}should_load_user_configr$r$r%ry8s zConfiguration.iter_config_filescCs |j|S)z#Get values present in a config file)rN)rPrDr$r$r%get_values_in_configVs z"Configuration.get_values_in_configcCs*|jsJ|j|j}|std|dS)Nz4Fatal Internal error [id=2]. Please report as a bug.)rBrMr )rPparsersr$r$r%rWZs  z#Configuration._get_parser_to_modifyrgcCs&||f}||jvr|j|dSdSN)rOr|)rPrfrgfile_parser_tupler$r$r%rehs zConfiguration._mark_as_modifiedcCs|jjd|jdS)N())rR__name__rZrUr$r$r%__repr__mszConfiguration.__repr__r)rN)%r __module__ __qualname____doc__boolrrrHrVstrrYrrrr[r_rirlrtrapropertyrrZrSrr{rrTrrrryrrWrer __classcell__r$r$rQr%r@Ws<         r@),rrrr-r6typingrrrrrrrpip._internal.exceptionsr r pip._internal.utilsr pip._internal.utils.compatr pip._internal.utils.loggingr pip._internal.utils.miscrrrrrr0rr:rrrrrrLrIrrnr&r,r?r@r$r$r$r%s: $