
ÂÂ­ÂÂ­ÂÂ­ÂÂ­ÂÂ­ÂÂ­ÂÂ­ÂÂ­ÂÂ­ÂÂ­ÂÂ­ÂÂ­ÂÂ­ÂÂ­ÂÂ­ÂÂ­ÂÂ­ÂÂ­
<!DOCTYPE html>
<html>
ó
vWS`c           @   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 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   sP  g  } t  j t j t j g ƒ } g  | D] } t j j | ƒ r( | ^ q( } 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 rf |
 d } qf qf W| d k	 r;| j t j j	 | d ƒ ƒ qS | j d ƒ qS 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
    s   -[^\{0}]+\.dist-infoi   i    t   RECORDN(   t   sitet   getsitepackagesR   t   base_prefixt   base_exec_prefixR	   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_records   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   StringIOt   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_recordR@   t   ft   sha_hasht   size(    (    s?   /opt/alt/python27/lib64/python2.7/ensurepip/rewheel/__init__.pyR   :   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   VersionR5   t   Tagt   -i    t   .i   i   (   R	   R
   R   R6   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__.pyR9   V   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)
    RS   s   utf-8Ns	   dist-infot   datat   ,i   i    s   ..s   .pycs   .pyo(   R	   R
   R   RZ   R[   R_   R6   R7   R    R$   t
   splitlinesRb   t   isabst
   startswitht   endswithR%   (
   RG   RH   t   record_file_patht   record_filet   record_contentst   data_dirRI   RJ   t   lt   spl(    (    s?   /opt/alt/python27/lib64/python2.7/ensurepip/rewheel/__init__.pyR8   n   s"    !)&#(   R   RZ   R?   t   email.parserR\   R	   R=   R"   R   t
   subprocessR   R:   R   R0   R   R9   R8   (    (    (    s?   /opt/alt/python27/lib64/python2.7/ensurepip/rewheel/__init__.pyt   <module>   s   				