U n a 8@sdZddlZddlZddlZddlZddlmZddlmZm Z ddl m Z ddl m Z mZddlmZmZddlmZerdd lmZmZmZmZmZmZmZejZed eZee Z!d d Z"d dZ#eddddddZ$e rdndZ%ddZ&Gddde'Z(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) configparser)ConfigurationError!ConfigurationFileCouldNotBeLoaded)appdirs)WINDOWS expanduser) ensure_direnum)MYPY_CHECK_RUNNING)AnyDictIterableListNewTypeOptionalTupleKindcCs*|dd}|dr&|dd}|S)zFMake a name consistent regardless of source (environment or file) _-z--N)lowerreplace startswith)namer\C:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-6mt8ur68\pip\_internal\configuration.py_normalize_name-s  rcCs&d|krd|}t||ddS)N.zbKey does not contain dot separated section and key. Perhaps you wanted to use 'global.{}' instead?)formatrsplit)r error_messagerrr_disassemble_key7sr"userglobalsiteenvzenv-var)USERGLOBALSITEENVENV_VARzpip.inizpip.confcCspddtdD}tjtjt}tjtdt r8dndt}tjt dt}t j |t j |gt j||giS)NcSsg|]}tj|tqSr)ospathjoinCONFIG_BASENAME).0r-rrr Qsz+get_configuration_files..pip~z.pip)rsite_config_dirsr,r-r.sysprefixr/rruser_config_dirkindsr(r)r')global_config_filessite_config_filelegacy_config_filenew_config_filerrrget_configuration_filesOs( r=cseZdZdZd+fdd ZddZddZd d Zd d Zd dZ ddZ ddZ ddZ e ddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*ZZS), 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. Nc stt|tjtjtjdg}||krJtdd t t |dd||_ ||_ tjtjtjtjtjg|_ddg|_dd|jD|_dd|jD|_g|_dS) Nz5Got invalid value for load_only - should be one of {}z, versionhelpcSsi|] }|gqSrrr0variantrrr sz*Configuration.__init__..cSsi|] }|iqSrrrBrrrrDs)superr>__init__r8r'r(r)rrr.mapreprisolated load_onlyr*r+_override_order_ignore_env_names_parsers_config_modified_parsers)selfrIrJ_valid_load_only __class__rrrFts0 zConfiguration.__init__cCs||js|dS)zELoads configuration from configuration files and environment N)_load_config_filesrI_load_environment_varsrPrrrloadszConfiguration.loadcCs<|jdk stdz|dWStk r6YdSXdS)z@Returns the file with highest priority in configuration Nz)Need to be specified a file to be editingr)rJAssertionError_get_parser_to_modify IndexErrorrVrrrget_file_to_edits zConfiguration.get_file_to_editcCs |jS)z`Returns key-value pairs like dict.items() representing the loaded configuration ) _dictionaryitemsrVrrrr]szConfiguration.itemscCs4z |j|WStk r.td|YnXdS)z,Get a value from the configuration. No such key - {}N)r\KeyErrorrr)rPkeyrrr get_values zConfiguration.get_valuecCsj||\}}|dk rJt|\}}||s<||||||||j|j|<|||dS)z-Modify a value in the configuration. N) _ensure_have_load_onlyrYr" has_section add_sectionsetrNrJ_mark_as_modified)rPr`valuefnameparsersectionrrrr set_values    zConfiguration.set_valuec Cs|||j|jkr&td||\}}|dk rt|\}}d}||r`|||}|rt | |}z t |}Wnt k rd}YnX|dkr| ||||ntd|j|j|=dS)z,Unset a value in the configuration. r^NFz4Fatal Internal error [id=1]. Please report as a bug.)rbrNrJrrrYr"rc remove_optioniterr]next StopIterationremove_sectionrf) rPr`rhrirjrmodified_something section_itervalrrr unset_values,       zConfiguration.unset_valuec CsX||jD]D\}}td|ttj|t|d}| |W5QRXqdS)z*Save the current in-memory state. z Writing to %swN) rbrOloggerinforr,r-dirnameopenwrite)rPrhrifrrrsaves   zConfiguration.savecCs$|jdkrtdtd|jdS)Nz'Needed a specific file to be modifying.z$Will be working with %s variant only)rJrrvdebugrVrrrrbs z$Configuration._ensure_have_load_onlycCs$i}|jD]}||j|q |S)zfs,   '    r>))rrloggingr,r5pip._vendor.six.movesrpip._internal.exceptionsrrZpip._internal.utilsrpip._internal.utils.compatrrpip._internal.utils.miscrr pip._internal.utils.typingr typingr r r rrrrrstrr getLoggerrrvrr"r8r/r=objectr>rrrrs6   $