î
½1kdÌ  ã               @   s¸   d  d l  Z  d  d l Z d  d l m Z d  d l m 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 Gd d „  d e ƒ Z Gd d	 „  d	 e ƒ Z d S)é    N)ÚCommand)Úconvert_path)Úlog)ÚDistutilsOptionErrorÚconfig_fileÚedit_configÚoption_baseÚsetoptÚlocalc             C   s’   |  d k r d S|  d k r> t  j j t  j j t j ƒ d ƒ S|  d k r t  j d k r_ d pb d } t  j j t d	 | ƒ ƒ St	 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)ÚkindÚdot© r   úO/var/www/pythonscrapper/code/venv/build/setuptools/setuptools/command/setopt.pyr      s    	Fc       
   	   C   s¬  d d l  m } t j d |  ƒ | j ƒ  } | j |  g ƒ x+| j ƒ  D]\ } } | d k r„ t j d | |  ƒ | j | ƒ qI | j	 | ƒ s¶ t j d | |  ƒ | j
 | ƒ n  x­ | j ƒ  D]Ÿ \ } } | d k r6t j d | | |  ƒ | j | | ƒ | j | ƒ sbt j d | |  ƒ | j | ƒ qbqÃ t j d	 | | | |  ƒ | j | | | ƒ qÃ WqI Wt j d
 |  ƒ | s¨t |  d ƒ � }	 | j |	 ƒ Wd QXn  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.
    r   )ÚConfigParserz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)Zsetuptools.compatr   r   ÚdebugÚRawConfigParserÚreadÚitemsÚinfoÚremove_sectionÚhas_sectionÚadd_sectionÚremove_optionÚoptionsÚsetÚopenÚwrite)
ÚfilenameZsettingsÚdry_runr   ÚoptsÚsectionr(   ÚoptionÚvalueÚfr   r   r   r      s:    	
c               @   sI   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=r2   ú-configuration file to use (default=setup.cfg)c             C   s   d  |  _  d  |  _ d  |  _ d  S)N)Úglobal_configÚuser_configr,   )Úselfr   r   r   Úinitialize_optionsX   s    		zoption_base.initialize_optionsc             C   s¶   g  } |  j  r% | j t d ƒ ƒ n  |  j rD | j t d ƒ ƒ n  |  j d  k	 rf | j |  j ƒ n  | s‚ | j t d ƒ ƒ n  t | ƒ d k r¦ t d | ƒ ‚ n  | \ |  _ d  S)Nr   r   r
   é   z/Must specify only one configuration file option)r;   Úappendr   r<   r,   Úlenr   )r=   Ú	filenamesr   r   r   Úfinalize_options]   s    		zoption_base.finalize_optionsN)r3   r4   r5   )r6   r7   r8   )r9   r2   r:   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úuser_optionsÚboolean_optionsr>   rC   r   r   r   r   r   H   s      	c               @   si   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   s5   t  j |  ƒ d  |  _ d  |  _ d  |  _ d  |  _ d  S)N)r   r>   Úcommandr0   Ú	set_valuerS   )r=   r   r   r   r>   }   s
    			zsetopt.initialize_optionsc             C   sf   t  j |  ƒ |  j d  k s+ |  j d  k r: t d ƒ ‚ n  |  j d  k rb |  j rb t d ƒ ‚ n  d  S)Nz%Must specify --command *and* --optionz$Must specify --set-value or --remove)r   rC   rV   r0   r   rW   rS   )r=   r   r   r   rC   „   s
    zsetopt.finalize_optionsc             C   s=   t  |  j i i |  j |  j j d d ƒ 6|  j 6|  j ƒ d  S)Nú-Ú_)r   r,   rW   r0   ÚreplacerV   r-   )r=   r   r   r   Úrun‹   s    	#z
setopt.runN)rJ   rK   rL   )rM   rN   rO   )rP   rQ   rR   )zremoverT   rU   )rD   rE   rF   rG   Údescriptionr   rH   rI   r>   rC   r[   r   r   r   r   r	   o   s   
)r   r   Ú
setuptoolsr   Údistutils.utilr   r   Zdistutils.errorsr   Ú__all__r   r   r   r	   r   r   r   r   Ú<module>   s   +'