Ñò
$8Zc           @   sÒ   d  Z  d d k Td d k l Z d d k l Z d d k l Z d d k l	 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 Z d d k Z d d	 k l Z d
 e f d „  ƒ  YZ d S(   s`   distutils.command.upload

Implements the Distutils 'upload' subcommand (upload package to PyPI).iÿÿÿÿ(   t   *(   t   PyPIRCCommand(   t   spawn(   t   log(   t   md5N(   t   standard_b64encode(   t   ConfigParsert   uploadc           B   sU   e  Z d  Z e i d d g Z e i d g Z d „  Z d „  Z d	 „  Z d
 „  Z	 RS(   s   upload binary package to PyPIt   signt   ss   sign files to upload using gpgs	   identity=t   is   GPG identity used to sign filesc         C   s>   t  i |  ƒ d |  _ d |  _ d |  _ t |  _ d  |  _ d  S(   Nt    i    (	   R   t   initialize_optionst   usernamet   passwordt   show_responset   FalseR   t   Nonet   identity(   t   self(    (    s.   /usr/lib/python2.6/distutils/command/upload.pyR       s    				c         C   s‡   t  i |  ƒ |  i o |  i o t d ƒ ‚ n |  i ƒ  } | h  j o8 | d |  _ | d |  _ | d |  _ | d |  _	 n d  S(   Ns.   Must use --sign for --identity to have meaningR   R   t
   repositoryt   realm(
   R   t   finalize_optionsR   R   t   DistutilsOptionErrort   _read_pypircR   R   R   R   (   R   t   config(    (    s.   /usr/lib/python2.6/distutils/command/upload.pyR   (   s    c         C   sT   |  i  i p t d ƒ ‚ n x0 |  i  i D]" \ } } } |  i | | | ƒ q* Wd  S(   Ns'   No dist file created in earlier command(   t   distributiont
   dist_filesR   t   upload_file(   R   t   commandt	   pyversiont   filename(    (    s.   /usr/lib/python2.6/distutils/command/upload.pyt   run5   s
     c      
   C   s£  |  i  oM d d d | g } |  i o d |  i g | d d +n t | d |  i ƒn t | d ƒ i ƒ  } |  i i } h d d	 6d
 d 6| i ƒ  d 6| i	 ƒ  d 6t
 i i | ƒ | f d 6| d 6| d 6t | ƒ i ƒ  d 6d d 6| i ƒ  d 6| i ƒ  d 6| i ƒ  d 6| i ƒ  d 6| i ƒ  d 6| i ƒ  d 6| i ƒ  d 6| i ƒ  d 6| i ƒ  d 6| i ƒ  d 6| i ƒ  d 6| i ƒ  d 6| i ƒ  d  6} d! } | d" j o4 t i ƒ  \ }	 }
 } |	 o d# |	 |
 f } qþn( | d$ j o d% t i d& d' ƒ } n | | d( <|  i  o4 t
 i i | ƒ d) t | d) ƒ i ƒ  f | d* <n d+ t |  i d, |  i  ƒ } d- } d. | } | d/ } t! i! ƒ  } xô | i" ƒ  D]æ \ } } t# | ƒ t# g  ƒ j o | g } n x± | D]© } t# | ƒ t$ j o d0 | d1 } | d' } n d! } | i% | ƒ | i% d2 | ƒ | i% | ƒ | i% d3 ƒ | i% | ƒ | o" | d4 d5 j o | i% d6 ƒ qÐqÐWq—W| i% | ƒ | i% d6 ƒ | i& ƒ  } |  i' d7 | |  i( f t) i* ƒ t+ i+ |  i( ƒ \ } } } } } } | o | o | p t, ‚ | d8 j o t- i. | ƒ } n. | d9 j o t- i/ | ƒ } n t, d: | ‚ d! } t) i* } yu | i0 ƒ  | i1 d; | ƒ | i2 d< d= | ƒ | i2 d> t3 t4 | ƒ ƒ ƒ | i2 d? | ƒ | i5 ƒ  | i6 | ƒ Wn2 t7 i8 j
 o# } |  i' t3 | ƒ t) i9 ƒ d  SX| i: ƒ  } | i; d@ j o' |  i' dA | i; | i< f t) i* ƒ n$ |  i' dB | i; | i< f t) i9 ƒ |  i= o dC dD G| i ƒ  GdC dD GHn d  S(E   Nt   gpgs   --detach-signs   -as   --local-useri   t   dry_runt   rbt   file_uploads   :actiont   1t   protcol_versiont   namet   versiont   contentt   filetypeR   t
   md5_digests   1.0t   metadata_versiont   summaryt	   home_paget   authort   author_emailt   licenset   descriptiont   keywordst   platformt   classifierst   download_urlt   providest   requirest	   obsoletesR   t	   bdist_rpms   built for %s %st
   bdist_dumbs   built for %st   tersei   t   comments   .asct   gpg_signatures   Basic t   :s3   --------------GHSKFJDLGDS7543FJKLFHRE75642756743254s   
--s   --s   ;filename="%s"i    s*   
Content-Disposition: form-data; name="%s"s   

iÿÿÿÿs   s   
s   Submitting %s to %st   httpt   httpss   unsupported schema t   POSTs   Content-types    multipart/form-data; boundary=%ss   Content-lengtht   AuthorizationiÈ   s   Server response (%s): %ss   Upload failed (%s): %st   -iK   (>   R   R   R   R"   t   opent   readR   t   metadatat   get_namet   get_versiont   ost   patht   basenameR   t	   hexdigestt   get_descriptiont   get_urlt   get_contactt   get_contact_emailt   get_licencet   get_long_descriptiont   get_keywordst   get_platformst   get_classifierst   get_download_urlt   get_providest   get_requirest   get_obsoletesR4   t   distR   R   R   t   StringIOt   itemst   typet   tuplet   writet   getvaluet   announceR   R   t   INFOt   urlparset   AssertionErrort   httplibt   HTTPConnectiont   HTTPSConnectiont   connectt
   putrequestt	   putheadert   strt   lent
   endheaderst   sendt   sockett   errort   ERRORt   getresponset   statust   reasonR   (   R   R   R   R   t   gpg_argsR)   t   metat   dataR=   R[   R(   t   idt   autht   boundaryt   sep_boundaryt   end_boundaryt   bodyt   keyt   valuet   fnt   schemat   netloct   urlt   paramst   queryt	   fragmentsR@   t   loglevelt   et   r(    (    s.   /usr/lib/python2.6/distutils/command/upload.pyR   ;   sÄ    

	

!

   $	
	


(   s   signR	   s   sign files to upload using gpg(   s	   identity=R
   s   GPG identity used to sign files(
   t   __name__t
   __module__R2   R   t   user_optionst   boolean_optionsR   R   R    R   (    (    (    s.   /usr/lib/python2.6/distutils/command/upload.pyR      s    
			(   t   __doc__t   distutils.errorst   distutils.coreR   t   distutils.spawnR   t	   distutilsR   t   hashlibR   RJ   Rp   R4   Rf   t   base64R   Rd   t	   cStringIOR\   R   R   (    (    (    s.   /usr/lib/python2.6/distutils/command/upload.pyt   <module>   s   
