3 M(Y@sddlmZddlmZddlmZddlZddlZddlmZddl m Z ddd d gZ dd dZ dddZ Gdd d e ZGdd d eZdS)) convert_path)log)DistutilsOptionErrorN) configparser)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)kinddotrG/private/tmp/pip-build-nl73fm5q/setuptools/setuptools/command/setopt.pyrsFc Cs.tjd|tj}|j|gx|jD]\}}|dkrTtjd|||j|q*|j|svtjd|||j |x||jD]p\}}|dkrtjd||||j |||j |stjd|||j|qtjd|||||j |||qWq*Wtjd||s*t |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@s2eZdZdZdddgZddgZd d Zd dZdS)r z filenamesrrrfinalize_optionsas   zoption_base.finalize_optionsN)r4r5r6)r7r8r9)r:r3r;)__name__ __module__ __qualname____doc__ user_optionsboolean_optionsr?rDrrrrr Lsc@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)r r?commandr1 set_valuerT)r>rrrr?s  zsetopt.initialize_optionscCsDtj||jdks|jdkr&td|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>rrrrunsz setopt.runN)rKrLrM)rNrOrP)rQrRrS)rTrUrV) rErFrGrH descriptionr rIrJr?rDr\rrrrr ss )r )F)distutils.utilrrrZdistutils.errorsrrZsetuptools.extern.six.movesr setuptoolsr__all__rrr r rrrrs        +'