
[Y                 @   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 Td 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)*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)zGet 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   L/home/kubikplay/www/django_dtb/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 |	  |	 j   n  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close)
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g0save options to the site-wide distutils.cfg fileuser-configu7save options to the current user's pydistutils.cfg file	filename=r3   -configuration file to use (default=setup.cfg)c             C   s   d  |  _  d  |  _ d  |  _ d  S)N)global_configuser_configr-   )selfr   r   r   initialize_optionsc   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-   lenDistutilsOptionError)r>   	filenamesr   r   r   finalize_optionsh   s    		zoption_base.finalize_optionsN)r4   r5   r6   )r7   r8   r9   )r:   r3   r;   )__name__
__module____qualname____doc__user_optionsboolean_optionsr?   rE   r   r   r   r   r   S   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?   commandr1   	set_valuerU   )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   rE   rX   r1   rC   rY   rU   )r>   r   r   r   rE      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-   rY   r1   replacerX   r.   )r>   r   r   r   run   s    	#z
setopt.runN)rL   rM   rN   )rO   rP   rQ   )rR   rS   rT   )zremoverV   rW   )rF   rG   rH   rI   descriptionr   rJ   rK   r?   rE   r]   r   r   r   r   r	   |   s   
)r   r   
setuptoolsr   distutils.utilr   r   distutils.errors__all__r   r   r   r	   r   r   r   r   <module>   s   
 ))