
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
ÄvhÝ  ã               @   s�   d dl mZ d dlmZ d dlmZ d dlZd dlZd dlmZ d dl	m
Z
 ddd	d
gZddd„Zddd„ZG dd	„ d	e
ƒZG dd
„ d
eƒZdS )é    )Úconvert_path)Úlog)ÚDistutilsOptionErrorN)Úconfigparser)ÚCommandÚconfig_fileÚedit_configÚoption_baseÚsetoptÚlocalc             C   sh   | dkrdS | dkr,t jjt jjtjƒdƒS | dkrZt jdkrBdpDd}t jjtd	| ƒƒS t	d
| ƒ‚dS )z�Get the filename of the distutils, local, global, or per-user config

    `kind` must be one of "local", "global", or "user"
    r   z	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)ZkindÚdot© r   ú/usr/lib/python3.6/setopt.pyr      s    Fc       	   	   C   s.  t jd| ƒ tjƒ }|j| gƒ xÖ|jƒ D ]Ê\}}|dkrTt jd|| ƒ |j|ƒ q*|j|ƒsvt jd|| ƒ |j	|ƒ x||jƒ D ]p\}}|dkrÐt jd||| ƒ |j
||ƒ |j|ƒsðt jd|| ƒ |j|ƒ q€t jd|||| ƒ |j|||ƒ q€W q*W t jd| ƒ |�s*t| d	ƒ�}|j|ƒ W dQ R X dS )
aY  Edit 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.
    zReading configuration from %sNzDeleting section [%s] from %szAdding new section [%s] to %szDeleting %s.%s from %sz#Deleting empty [%s] section from %szSetting %s.%s to %r in %sz
Writing %sÚw)r   Údebugr   ZRawConfigParserÚreadÚitemsÚinfoZremove_sectionZhas_sectionZadd_sectionZremove_optionÚoptionsÚsetÚopenÚwrite)	ÚfilenameZsettingsÚdry_runZoptsZsectionr"   ÚoptionÚvalueÚfr   r   r   r   !   s8    



c               @   s2   e Zd ZdZdddgZddgZdd„ Zdd„ ZdS )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=r*   ú-configuration file to use (default=setup.cfg)c             C   s   d | _ d | _d | _d S )N)Úglobal_configÚuser_configr&   )Úselfr   r   r   Úinitialize_options\   s    zoption_base.initialize_optionsc             C   sv   g }| j r|jtdƒƒ | jr,|jtdƒƒ | jd k	rB|j| jƒ |sT|jtdƒƒ t|ƒdkrjtd|ƒ‚|\| _d S )Nr   r   r   é   z/Must specify only one configuration file option)r3   Úappendr   r4   r&   Úlenr   )r5   Ú	filenamesr   r   r   Úfinalize_optionsa   s    
zoption_base.finalize_optionsN)r+   r,   r-   )r.   r/   r0   )r1   r*   r2   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úuser_optionsÚboolean_optionsr6   r;   r   r   r   r   r	   L   s      c               @   sJ   e Zd ZdZdZddddgej Zejdg Zdd„ Zdd„ Z	dd„ Z
dS )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 valuec             C   s&   t j| ƒ d | _d | _d | _d | _d S )N)r	   r6   Úcommandr(   Ú	set_valuerK   )r5   r   r   r   r6   �   s
    
zsetopt.initialize_optionsc             C   sD   t j| ƒ | jd ks| jd kr&tdƒ‚| jd kr@| j r@tdƒ‚d S )Nz%Must specify --command *and* --optionz$Must specify --set-value or --remove)r	   r;   rN   r(   r   rO   rK   )r5   r   r   r   r;   ˆ   s
    
zsetopt.finalize_optionsc             C   s*   t | j| j| jjddƒ| jii| jƒ d S )Nú-Ú_)r   r&   rN   r(   ÚreplacerO   r'   )r5   r   r   r   Úrun�   s    z
setopt.runN)rB   rC   rD   )rE   rF   rG   )rH   rI   rJ   )rK   rL   rM   )r<   r=   r>   r?   Údescriptionr	   r@   rA   r6   r;   rS   r   r   r   r   r
   s   s   )r   )F)Zdistutils.utilr   r   r   Zdistutils.errorsr   r   Zsetuptools.extern.six.movesr   Z
setuptoolsr   Ú__all__r   r   r	   r
   r   r   r   r   Ú<module>   s   

+'