Ñò
 Kc           @   s°   d  Z  d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z	 d d k
 l Z d d k l Z d d k l Z d e f d „  ƒ  YZ d S(   ss   upload_docs

Implements a Distutils 'upload_docs' subcommand (upload documentation to
PyPI's packages.python.org).
iÿÿÿÿN(   t   log(   t   DistutilsOptionError(   t   uploadt   upload_docsc           B   sc   e  Z d  Z d d d e i f d d g Z e i Z d „  Z d	 „  Z	 d
 „  Z
 d „  Z d „  Z RS(   s   Upload documentation to PyPIs   repository=t   rs   url of repository [default: %s]s   show-responses&   display full response text from servers   upload-dir=s   directory to uploadc         C   s   t  i |  ƒ d  |  _ d  S(   N(   R   t   initialize_optionst   Nonet
   upload_dir(   t   self(    (    sB   /usr/lib/python2.6/dist-packages/setuptools/command/upload_docs.pyR   "   s    c         C   s€   t  i |  ƒ |  i d  j o> |  i d ƒ } t i i | i d ƒ |  _ |  i	 |  i ƒ n |  i
 d ƒ |  i d |  i ƒ d  S(   Nt   buildt   docsR   s   Using upload directory %s(   R   t   finalize_optionsR   R   t   get_finalized_commandt   ost   patht   joint
   build_baset   mkpatht   ensure_dirnamet   announce(   R   R	   (    (    sB   /usr/lib/python2.6/dist-packages/setuptools/command/upload_docs.pyR   &   s    c         C   s  |  i  i i ƒ  } t i ƒ  } t i i | d | ƒ } t i	 | d ƒ } x¿ t i
 |  i ƒ D]« \ } } } | |  i j o | o t d |  i ƒ ‚ n xj | D]b } t i i | | ƒ } | t |  i ƒ i t i i ƒ }	 t i i |	 | ƒ }
 | i | |
 ƒ q¡ Wq\ W| i ƒ  | S(   Ns   %s.zipt   ws'   no files found in upload directory '%s'(   t   distributiont   metadatat   get_namet   tempfilet   mkdtempR   R   R   t   zipfilet   ZipFilet   walkR   R   t   lent   lstript   sept   writet   close(   R   t   namet   tmp_dirt   tmp_filet   zip_filet   roott   dirst   filest   fullt   relativet   dest(    (    sB   /usr/lib/python2.6/dist-packages/setuptools/command/upload_docs.pyt   create_zipfile/   s$      "
c         C   s   |  i  ƒ  } |  i | ƒ d  S(   N(   R,   t   upload_file(   R   R%   (    (    sB   /usr/lib/python2.6/dist-packages/setuptools/command/upload_docs.pyt   runA   s    c      
   C   s  t  | d ƒ i ƒ  } |  i i } h d d 6| i ƒ  d 6t i i | ƒ | f d 6} d t i	 |  i
 d |  i ƒ i ƒ  } d } d	 | } | d
 } t i ƒ  }	 x | i ƒ  D]ò \ }
 } t | ƒ t g  ƒ j o | g } n x½ | D]µ } t | ƒ t j o d | d } | d } n d } t | ƒ } |	 i | ƒ |	 i d |
 ƒ |	 i | ƒ |	 i d ƒ |	 i | ƒ | o" | d d j o |	 i d ƒ qç qç Wq® W|	 i | ƒ |	 i d ƒ |	 i ƒ  }	 |  i d |  i t i ƒ t i |  i ƒ \ } } } } } } | o | o | p t ‚ | d j o t i | ƒ } n1 | d j o t i | ƒ } n t d | ƒ ‚ d } t i } yu | i ƒ  | i d | ƒ | i d d | ƒ | i d t t  |	 ƒ ƒ ƒ | i d | ƒ | i! ƒ  | i" |	 ƒ Wn2 t# i$ j
 o# } |  i t | ƒ t i% ƒ d  SX| i& ƒ  } | i' d j o' |  i d | i' | i( f t i ƒ n | i' d j oK | i) d  ƒ } | d  j o d! | i ƒ  } n |  i d" | t i ƒ n$ |  i d# | i' | i( f t i% ƒ |  i+ o d$ d% G| i ƒ  Gd$ d% GHn d  S(&   Nt   rbt
   doc_uploads   :actionR"   t   contents   Basic t   :s3   --------------GHSKFJDLGDS7543FJKLFHRE75642756743254s   
--s   --s   ;filename="%s"i    i   t    s*   
Content-Disposition: form-data; name="%s"s   

iÿÿÿÿs   s   
s   Submitting documentation to %st   httpt   httpss   unsupported schema t   POSTs   Content-types    multipart/form-data; boundary=%ss   Content-lengtht   AuthorizationiÈ   s   Server response (%s): %si-  t   Locations   http://packages.python.org/%s/s   Upload successful. Visit %ss   Upload failed (%s): %st   -iK   (,   t   opent   readR   R   R   R   R   t   basenamet   base64t   encodestringt   usernamet   passwordt   stript   StringIOt   itemst   typet   tuplet   strR    t   getvalueR   t
   repositoryR    t   INFOt   urlparset   AssertionErrort   httplibt   HTTPConnectiont   HTTPSConnectiont   connectt
   putrequestt	   putheaderR   t
   endheaderst   sendt   sockett   errort   ERRORt   getresponset   statust   reasont	   getheaderR   t   show_response(   R   t   filenameR1   t   metat   datat   autht   boundaryt   sep_boundaryt   end_boundaryt   bodyt   keyt   valuet   fnt   schemat   netloct   urlt   paramst   queryt	   fragmentsR4   t   loglevelt   eR   t   location(    (    sB   /usr/lib/python2.6/dist-packages/setuptools/command/upload_docs.pyR-   E   sŒ    	

  
$	
	


N(   s   show-responseNs&   display full response text from server(   s   upload-dir=Ns   directory to upload(   t   __name__t
   __module__t   descriptionR   t   DEFAULT_REPOSITORYR   t   user_optionst   boolean_optionsR   R   R,   R.   R-   (    (    (    sB   /usr/lib/python2.6/dist-packages/setuptools/command/upload_docs.pyR      s    							(   t   __doc__R   RT   R   RL   R=   RJ   R   t	   cStringIORB   t	   distutilsR    t   distutils.errorsR   t   distutils.command.uploadR   R   (    (    (    sB   /usr/lib/python2.6/dist-packages/setuptools/command/upload_docs.pyt   <module>   s   