3 e@sddlmZddlmZddlmZddlZddlZddlZddlm Z dddd gZ dd dZ dd dZ Gddde Z Gdd d e ZdS)) convert_path)log)DistutilsOptionErrorN)Command config_file edit_config option_basesetoptlocalcCsh|dkr dS|dkr,tjjtjjtjdS|dkrZtjdkrBdpDd}tjjtd |St d |d S) zGet the filename of the distutils, local, global, or per-user config `kind` must be one of "local", "global", or "user" r z setup.cfgglobalz distutils.cfguserposix.z~/%spydistutils.cfgz7config_file() type must be 'local', 'global', or 'user'N) ospathjoindirname distutils__file__name expanduserr ValueError)kinddotr?/tmp/pip-build-vlmub77e/setuptools/setuptools/command/setopt.pyr sFc Cs8tjd|tj}dd|_|j|gx|jD]\}}|dkr^tjd|||j|q4|j |stjd|||j |x||jD]p\}}|dkrtjd||||j |||j |stjd|||j|qtjd |||||j |||qWq4Wtjd ||s4t|d }|j|WdQRXdS) aYEdit a configuration file to include `settings` `settings` is a dictionary of dictionaries or ``None`` values, keyed by command/section name. A ``None`` value means to delete the entire section, while a dictionary lists settings to be changed or deleted in that section. A setting of ``None`` means to delete that setting. zReading configuration from %scSs|S)Nr)xrrr*szedit_config..NzDeleting section [%s] from %szAdding new section [%s] to %szDeleting %s.%s from %sz#Deleting empty [%s] section from %szSetting %s.%s to %r in %sz Writing %sw)rdebug configparserRawConfigParser optionxformreaditemsinforemove_section has_section add_section remove_optionoptionssetopenwrite) filenamesettingsdry_runoptssectionr+optionvaluefrrrr s:             c@s2eZdZdZdddgZddgZd d Zd dZdS)rz)__name__ __module__ __qualname____doc__ user_optionsboolean_optionsrBrGrrrrrLsc@sJeZdZdZdZddddgejZejd gZddZddZ ddZ dS)r z#Save command-line options to a filez1set an option in setup.cfg or another config filecommand=ccommand to set an option foroption=o option to set set-value=svalue of the optionremoverremove (unset) the valuecCs&tj|d|_d|_d|_d|_dS)N)rrBcommandr4 set_valuerW)rArrrrBs  zsetopt.initialize_optionscCsDtj||jdks|jdkr&td|jdkr@|j r@tddS)Nz%Must specify --command *and* --optionz$Must specify --set-value or --remove)rrGrZr4rr[rW)rArrrrGs  zsetopt.finalize_optionscCs*t|j|j|jjdd|jii|jdS)N-_)rr/rZr4replacer[r1)rArrrrunsz setopt.runN)rNrOrP)rQrRrS)rTrUrV)rWrXrY) rHrIrJrK descriptionrrLrMrBrGr_rrrrr ss )r )F)distutils.utilrrrZdistutils.errorsrrr! setuptoolsr__all__rrrr rrrrs       ,'