3

Q'ícÝã@sddlmZddlmZddlmZddlZddlZddlmZddl	m
Z
ddd	d
gZddd„Zddd„Z
Gdd	„d	e
ƒZGdd
„d
eƒZdS)é)Úconvert_path)Úlog)ÚDistutilsOptionErrorN)Úconfigparser)ÚCommandÚconfig_fileÚedit_configÚoption_baseÚsetoptÚlocalcCsh|dkrdS|dkr,tjjtjjtjƒdƒS|dkrZtjdkrBdpDd}tjjtd	|ƒƒSt	d
|ƒ‚dS)zGet the filename of the distutils, local, global, or per-user config

    `kind` must be one of "local", "global", or "user"
    rz	setup.cfgÚglobalz
distutils.cfgÚuserÚposixÚ.Úz~/%spydistutils.cfgz7config_file() type must be 'local', 'global', or 'user'N)
ÚosÚpathÚjoinÚdirnameÚ	distutilsÚ__file__ÚnameÚ
expanduserrÚ
ValueError)ÚkindÚdot©rú?/tmp/pip-build-l_bcah40/setuptools/setuptools/command/setopt.pyrsFc		Cs.tjd|ƒtjƒ}|j|gƒxÖ|jƒD]Ê\}}|dkrTtjd||ƒ|j|ƒq*|j|ƒsvtjd||ƒ|j	|ƒx||jƒD]p\}}|dkrÐtjd|||ƒ|j
||ƒ|j|ƒsðtjd||ƒ|j|ƒq€tjd||||ƒ|j|||ƒq€Wq*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 %sÚw)rÚdebugrÚRawConfigParserÚreadÚitemsÚinfoÚremove_sectionÚhas_sectionÚadd_sectionÚ
remove_optionÚoptionsÚsetÚopenÚwrite)	ÚfilenameÚsettingsÚdry_runÚoptsÚsectionr(ÚoptionÚvalueÚfrrrr!s8



c@s2eZdZdZdddgZddgZdd„Zd
d„ZdS)r	z<Abstract base class for commands that mess with config filesú
global-configÚgú0save options to the site-wide distutils.cfg fileúuser-configÚuú7save options to the current user's pydistutils.cfg fileú	filename=r3ú-configuration file to use (default=setup.cfg)cCsd|_d|_d|_dS)N)Ú
global_configÚuser_configr,)ÚselfrrrÚinitialize_options\szoption_base.initialize_optionscCsvg}|jr|jtdƒƒ|jr,|jtdƒƒ|jdk	rB|j|jƒ|sT|jtdƒƒt|ƒdkrjtd|ƒ‚|\|_dS)Nrr
réz/Must specify only one configuration file option)r<Úappendrr=r,Úlenr)r>Ú	filenamesrrrÚfinalize_optionsas
zoption_base.finalize_optionsN)r4r5r6)r7r8r9)r:r3r;)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úuser_optionsÚboolean_optionsr?rDrrrrr	Lsc@sJeZdZdZdZddddgejZejdgZdd„Zdd„Z	dd„Z
dS)r
z#Save command-line options to a filez1set an option in setup.cfg or another config fileúcommand=Úcúcommand to set an option forúoption=Úoú
option to setú
set-value=Úsúvalue of the optionÚremoveÚrúremove (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@tdƒ‚dS)Nz%Must specify --command *and* --optionz$Must specify --set-value or --remove)r	rDrWr1rrXrT)r>rrrrDˆs

zsetopt.finalize_optionscCs*t|j|j|jjddƒ|jii|jƒdS)Nú-Ú_)rr,rWr1ÚreplacerXr.)r>rrrÚrunsz
setopt.runN)rKrLrM)rNrOrP)rQrRrS)rTrUrV)rErFrGrHÚdescriptionr	rIrJr?rDr\rrrrr
ss)r)F)Údistutils.utilrrrZdistutils.errorsrrZsetuptools.extern.six.movesrÚ
setuptoolsrÚ__all__rrr	r
rrrrÚ<module>s

+'