Y@sddlmZddlmZddlmZddlZddlZddlmZddl m Z ddd d gZ d d dZ d ddZ Gdd d e ZGdd d eZdS)) convert_path)log)DistutilsOptionErrorN) configparser)Command config_file edit_config option_basesetoptlocalcCs|dkrdS|dkr>tjjtjjtjdS|dkrtjdkr_dpbd}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-3puug3g5/setuptools/setuptools/command/setopt.pyrs    Fc Cstjd|tj}|j|gx%|jD]\}}|dkrttjd|||j|q9|j|stjd|||j |x|jD]\}}|dkr tjd||||j |||j |sLtjd|||j|qtjd|||||j |||qWq9Wtjd||st |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 %sNzDeleting 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)rdebugrRawConfigParserreaditemsinforemove_section has_section add_section remove_optionoptionssetopenwrite) filenamesettingsdry_runoptssectionr(optionvaluefrrrr!s8       c@sIeZdZdZdddgZddgZd d Zd dZdS)r z|jtd|jdk r]|j|j|sv|jtdt|dkrtd||\|_dS)Nr r r z/Must specify only one configuration file option)r<appendrr=r,lenr)r> filenamesrrrfinalize_optionsas   zoption_base.finalize_optionsN)r4r5r6)r7r8r9)r:r3r;)__name__ __module__ __qualname____doc__ user_optionsboolean_optionsr?rDrrrrr Ls    c@sieZdZdZdZddddgejZejd 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 valuecCs5tj|d|_d|_d|_d|_dS)N)r r?commandr1 set_valuerT)r>rrrr?s     zsetopt.initialize_optionscCs`tj||jdks+|jdkr7td|jdkr\|j r\tddS)Nz%Must specify --command *and* --optionz$Must specify --set-value or --remove)r rDrWr1rrXrT)r>rrrrDs   zsetopt.finalize_optionscCs;t|j|j|jjdd|jii|jdS)N-_)rr,rWr1replacerXr.)r>rrrruns$z setopt.runN)rKrLrM)rNrOrP)rQrRrS)zremoverUrV) rErFrGrH descriptionr rIrJr?rDr\rrrrr ss    )distutils.utilrrrdistutils.errorsrrZ six.movesr setuptoolsr__all__rrr r rrrrs  +'