ó
è¾bc           @   sR   d  Z  d d l Z d d l m Z d d l m 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.
iÿÿÿÿN(   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   https://upload.pypi.org/legacy/t   pypis   repository=t   rs   url of repository [default: %s]s   show-responses&   display full response text from serverc         C   s   t  j j t  j j d ƒ d ƒ S(   s   Returns rc file path.t   ~s   .pypirc(   t   ost   patht   joint
   expanduser(   t   self(    (    s&   /usr/lib/python2.7/distutils/config.pyt   _get_rc_file&   s    c         C   sd   |  j  ƒ  } t j t j | t j t j Bd ƒ d ƒ } z | j t | | f ƒ Wd | j ƒ  Xd S(   s   Creates a default .pypirc file.i€  t   wN(	   R   R   t   fdopent   opent   O_CREATt   O_WRONLYt   writet   DEFAULT_PYPIRCt   close(   R
   t   usernamet   passwordt   rct   f(    (    s&   /usr/lib/python2.7/distutils/config.pyt   _store_pypirc*   s
    +c         C   s3  |  j  ƒ  } t j j | ƒ r/|  j d | ƒ |  j p> |  j } t ƒ  } | j | ƒ | j	 ƒ  } d | k r¨| j
 d d ƒ } g  | j d ƒ D]$ } | j ƒ  d k r‘ | j ƒ  ^ q‘ } | g  k ræ d | k rß d g } qæ i  Sn  xC| D]´ } i | d 6} | j
 | d ƒ | d <xd d	 |  j f d
 |  j f d f D]A \ }	 }
 | j | |	 ƒ ro| j
 | |	 ƒ | |	 <q8|
 | |	 <q8W| d | k s| d	 | k rí | Sqí Wq/d | k r/d } | j | d	 ƒ rá| j
 | d	 ƒ } n	 |  j } i | j
 | d ƒ d 6| j
 | d ƒ d 6| d	 6| d 6|  j d
 6Sn  i  S(   s   Reads the .pypirc file.s   Using PyPI login from %st	   distutilss   index-serverss   
t    R   t   serverR   t
   repositoryt   realmR   s   server-loginN(   R   N(   R   R   R   t   existst   announceR   t   DEFAULT_REPOSITORYR    t   readt   sectionst   gett   splitt   stript   DEFAULT_REALMt   Nonet
   has_option(   R
   R   R   t   configR"   t   index_serversR   t   _serverst   currentt   keyt   default(    (    s&   /usr/lib/python2.7/distutils/config.pyt   _read_pypirc3   sP    	$		c         C   s   d |  _ d |  _ d |  _ d S(   s   Initialize options.i    N(   R'   R   R   t   show_response(   R
   (    (    s&   /usr/lib/python2.7/distutils/config.pyt   initialize_optionsi   s    		c         C   s@   |  j  d k r |  j |  _  n  |  j d k r< |  j |  _ n  d S(   s   Finalizes options.N(   R   R'   R    R   R&   (   R
   (    (    s&   /usr/lib/python2.7/distutils/config.pyt   finalize_optionso   s    N(   s   show-responseNs&   display full response text from server(   t   __name__t
   __module__t   __doc__R    R&   R'   R   R   t   user_optionst   boolean_optionsR   R   R/   R1   R2   (    (    (    s&   /usr/lib/python2.7/distutils/config.pyR      s     						6	(   R5   R   R    t   distutils.cmdR   R   R   (    (    (    s&   /usr/lib/python2.7/distutils/config.pyt   <module>   s
   
