
$8Zc           @   s^   d  Z  d d k Z d d k Z d d k l Z d d k l Z d Z d e f d     YZ d S(   s   distutils.pypirc

Provides the PyPIRCCommand class, the base class for the command classes
that uses .pypirc in the distutils.command package.
iN(   t   ConfigParser(   t   CommandsE   [distutils]
index-servers =
    pypi

[pypi]
username:%s
password:%s
t   PyPIRCCommandc           B   su   e  Z d  Z d Z d Z d Z d Z d d d e f d g Z d g Z	 d   Z
 d	   Z d
   Z d   Z d   Z RS(   s;   Base command that knows how to handle the .pypirc file
    s   http://pypi.python.org/pypit   pypis   repository=t   rs   url of repository [default: %s]s   show-responses&   display full response text from serverc         C   s   t  i i t  i i d  d  S(   s   Returns rc file path.t   ~s   .pypirc(   t   ost   patht   joint
   expanduser(   t   self(    (    s&   /usr/lib/python2.6/distutils/config.pyt   _get_rc_file'   s    c      	   C   s   |  i    } t i t i | t i t i Bd  d  } z | i t | | f  Wd | i   Xy t i	 | d  Wn t
 j
 o n Xd S(   s   Creates a default .pypirc file.i  t   wN(   R   R   t   fdopent   opent   O_CREATt   O_WRONLYt   writet   DEFAULT_PYPIRCt   closet   chmodt   OSError(   R
   t   usernamet   passwordt   rct   f(    (    s&   /usr/lib/python2.6/distutils/config.pyt   _store_pypirc+   s    +c         C   sx  |  i    } t i i |  oU|  i d |  |  i p |  i } |  i p |  i } t	   } | i
 |  | i   } d | j oc| i d d  } g  } | i d  D]* } | i   d j o | | i   q q ~ }	 |	 g  j o" d | j o d g }	 qh  Sn x`|	 D] } h | d 6}
 | i | d  |
 d <| i | d	  |
 d	 <xc d
 |  i f d |  i f f D]C \ } } | i | |  o | i | |  |
 | <qr| |
 | <qrW|
 d | j p |
 d
 | j o |
 SqWqtd | j o{ d } | i | d
  o | i | d
  } n
 |  i } h | i | d  d 6| i | d	  d	 6| d
 6| d 6|  i d 6Sn h  S(   s   Reads the .pypirc file.s   Using PyPI login from %st	   distutilss   index-serverss   
t    R   t   serverR   R   t
   repositoryt   realms   server-login(   R   R   R   t   existst   announceR   t   DEFAULT_REPOSITORYR   t   DEFAULT_REALMR    t   readt   sectionst   gett   splitt   stript
   has_option(   R
   R   R   R   t   configR%   t   index_serverst   _[1]R   t   _serverst   currentt   keyt   default(    (    s&   /usr/lib/python2.6/distutils/config.pyt   _read_pypirc9   sV    	- 	 	c         C   s   d |  _ d |  _ d |  _ d S(   s   Initialize options.i    N(   t   NoneR   R   t   show_response(   R
   (    (    s&   /usr/lib/python2.6/distutils/config.pyt   initialize_optionsq   s    		c         C   sD   |  i  d j o |  i |  _  n |  i d j o |  i |  _ n d S(   s   Finalizes options.N(   R   R2   R"   R   R#   (   R
   (    (    s&   /usr/lib/python2.6/distutils/config.pyt   finalize_optionsw   s    N(   s   show-responseNs&   display full response text from server(   t   __name__t
   __module__t   __doc__R"   R#   R2   R   R   t   user_optionst   boolean_optionsR   R   R1   R4   R5   (    (    (    s&   /usr/lib/python2.6/distutils/config.pyR      s     					8	(   R8   R   t   sysR    t   distutils.cmdR   R   R   (    (    (    s&   /usr/lib/python2.6/distutils/config.pyt   <module>   s   
