???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................ó
šV~gc           @   sÇ   d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l	 Z	 d  d l
 Z
 d  d l Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d S(	   iÿÿÿÿNc       	   C   s¯   t  j d d ƒ }  |  j d d d ƒ|  j d d d d d	 d
 d t j j ƒ|  j ƒ  } d } y t t | ƒ   GHWn' t	 k
 r } d j
 | ƒ GHd } n Xt j d ƒ d  S(   Nt   descriptions,   Recreate wheel of package with given RECORD.t   record_patht   helps   Path to RECORD files   -os   --output-dirs>   Dir where to place the wheel, defaults to current working dir.t   destt   outdirt   defaulti    s
   Failed: {}i   (   t   argparset   ArgumentParsert   add_argumentt   ost   patht   curdirt
   parse_argst   rewheel_from_recordt   varst   BaseExceptiont   formatt   syst   exit(   t   parsert   nst   retcodet   e(    (    s?   /opt/alt/python27/lib64/python2.7/ensurepip/rewheel/__init__.pyt   run   s    
c           C   s3   y t  j SWn! t k
 r. t t  d t  j ƒ SXd S(   sk   Get prefix to site-specific directory prefix where the platform
    independent Python files are installed.t   real_prefixN(   R   t   base_prefixt   AttributeErrort   getattrt   prefix(    (    (    s?   /opt/alt/python27/lib64/python2.7/ensurepip/rewheel/__init__.pyt   _get_base_prefix   s    c           C   s'   y t  j SWn t k
 r" t  j SXd S(   sF    Get exec_prefix dir used to find the machine-specific Python library.N(   R   t   base_exec_prefixR   t   exec_prefix(    (    (    s?   /opt/alt/python27/lib64/python2.7/ensurepip/rewheel/__init__.pyt   _get_base_exec_prefix)   s    c         C   sr  g  } t  j d d k  r( t j ƒ  } n t j t ƒ  t ƒ  g ƒ } g  | D] } t j j | ƒ rJ | ^ qJ } xý |  D]õ } d } x® | D]¦ } t j j
 | | ƒ d j t j ƒ } g  t j | ƒ D] } t j j
 | | ƒ ^ qÃ } g  | D] }	 t j | |	 ƒ rë |	 ^ që }
 t |
 ƒ d k rˆ |
 d } qˆ qˆ W| d k	 r]| j t j j
 | d ƒ ƒ qu | j d ƒ qu W| S(   s±   Return list of paths to RECORD files for system-installed projects.

    If a project is not installed, the resulting list contains None instead
    of a path to its RECORD
    i    i   s   -[^\{0}]+\.dist-infoi   t   RECORDN(   R   t   version_infot   sitet   getsitepackagesR   R    R	   R
   t   existst   Nonet   joinR   t   sept   listdirt   ret   matcht   lent   append(   t   projectst   recordst   sys_sitepackt   spt   projectR
   t   dist_info_ret   pt
   candidatest   ct   filtered(    (    s?   /opt/alt/python27/lib64/python2.7/ensurepip/rewheel/__init__.pyt   find_system_records0   s"    +%1+c         C   s?  t  j j t  j j |  ƒ ƒ } |  t | ƒ j t  j j ƒ } t | | ƒ \ } } t |  ƒ } t  j j | | d ƒ } t	 j
 | d d d t	 j ƒ} t j ƒ  }	 t j |	 ƒ }
 xO | D]G \ } } } | j t  j j | | ƒ d | ƒ|
 j | | | g ƒ q· W|
 j | d d g ƒ | j | |	 j ƒ  ƒ | j ƒ  | j S(   sc   Recreates a whee of package with given record_path and returns path
    to the newly created wheel.s   .whlt   modet   wt   compressiont   arcnamet    (   R	   R
   t   dirnameR,   t   stripR(   t   get_records_to_packt   get_wheel_nameR'   t   zipfilet   ZipFilet   ZIP_DEFLATEDt   iot   BytesIOt   csvt   writert   writet   writerowt   writestrt   getvaluet   closet   filename(   R   R   t   site_dirt   record_relpatht   to_writet   to_omitt   new_wheel_namet   new_wheel_patht	   new_wheelt
   new_recordRH   t   ft   sha_hasht   size(    (    s?   /opt/alt/python27/lib64/python2.7/ensurepip/rewheel/__init__.pyR   N   s    "
c      
   C   s€  t  j j t  j j |  ƒ d ƒ } t j | d d ƒ% } t j j ƒ  j	 | j
 ƒ  ƒ } Wd QXt  j j t  j j |  ƒ d ƒ } t j | d d ƒ% } t j j ƒ  j	 | j
 ƒ  ƒ } Wd QX| j d ƒ } | j d ƒ } d }	 g  }
 x1 | j d	 ƒ D]  } |
 j | j d
 ƒ d ƒ qô Wd j |
 ƒ }
 | j d	 ƒ j d
 ƒ d d !\ } } t d | | |	 |
 | | g ƒ } d
 j t | ƒ ƒ S(   s.   Return proper name of the wheel, without .whl.t   WHEELt   encodings   utf-8Nt   METADATAt   Namet   VersionR=   t   Tagt   -i    t   .i   i   (   R	   R
   R'   R>   t   codecst   opent   emailR   t   Parsert   parsestrt   readt   gett   get_allR-   t   splitt   filterR&   t   list(   R   t   wheel_info_patht   wheel_info_filet
   wheel_infot   metadata_patht   metadata_filet   metadatat   distributiont   versiont	   build_tagt   lang_tagt   tt   abi_tagt   plat_tagt   to_join(    (    s?   /opt/alt/python27/lib64/python2.7/ensurepip/rewheel/__init__.pyRA   j   s     !$!$%!c   
      C   sU  t  j j |  | ƒ } t j | d d ƒ } | j ƒ  } Wd QXt  j j | ƒ j t  j j ƒ } | t	 d ƒ  d } g  } g  } xÇ | j
 ƒ  D]¹ } | j d ƒ }	 t	 |	 ƒ d k rŽ t  j j |	 d ƒ s'|	 d j d	 ƒ s'|	 d j d
 ƒ s'|	 d j d ƒ s'|	 d | k s'|	 d j | ƒ r7| j |	 ƒ qG| j |	 ƒ qŽ qŽ W| | f S(   s  Accepts path of sitedir and path of RECORD file relative to it.
    Returns two lists:
    - list of files that can be written to new RECORD straight away
    - list of files that shouldn't be written or need some processing
      (pyc and pyo files, scripts)
    R[   s   utf-8Ns	   dist-infot   datat   ,i   i    s   ..s   .pycs   .pyo(   R	   R
   R'   Rb   Rc   Rg   R>   R?   R(   R,   t
   splitlinesRj   t   isabst
   startswitht   endswithR-   (
   RO   RP   t   record_file_patht   record_filet   record_contentst   data_dirRQ   RR   t   lt   spl(    (    s?   /opt/alt/python27/lib64/python2.7/ensurepip/rewheel/__init__.pyR@   ‚   s"    !)&#(   R   Rb   RG   t   email.parserRd   R	   RE   R*   R#   t
   subprocessR   RB   R   R   R    R8   R   RA   R@   (    (    (    s?   /opt/alt/python27/lib64/python2.7/ensurepip/rewheel/__init__.pyt   <module>   s"   		
				