ó
{[c           @   sp   d  d l  Z  d  d l Z d  d l Z d  d l Z d d l m Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   iÿÿÿÿNi   (   t   Distributiont   SDistc           B   s,   e  Z d d  „ Z e d „  ƒ Z d „  Z RS(   c         C   s    | |  _  | |  _ |  j ƒ  d  S(   N(   t   filenamet   metadata_versiont   extractMetadata(   t   selfR   R   (    (    s,   lib/python2.7/site-packages/pkginfo/sdist.pyt   __init__
   s    		c            sÌ   t  j j | ƒ s% t d | ƒ ‚ n  | j d ƒ ra t j | ƒ ‰  ˆ  j ƒ  } ‡  f d †  } n^ | j d ƒ s | j d ƒ r¯ t j	 j
 | ƒ ‰  ˆ  j ƒ  } ‡  f d †  } n t d | ƒ ‚ ˆ  | | f S(   Ns   No such file: %ss   .zipc            s   ˆ  j  |  ƒ S(   N(   t   read(   t   name(   t   archive(    s,   lib/python2.7/site-packages/pkginfo/sdist.pyt	   read_file   s    t   gzt   bz2c            s   ˆ  j  |  ƒ j ƒ  S(   N(   t   extractfileR   (   R   (   R	   (    s,   lib/python2.7/site-packages/pkginfo/sdist.pyR
      s    s   Not a known archive format: %s(   t   ost   patht   existst
   ValueErrort   endswitht   zipfilet   ZipFilet   namelistt   tarfilet   TarFilet   opent   getnames(   t   clst   fqnt   namesR
   (    (   R	   s,   lib/python2.7/site-packages/pkginfo/sdist.pyt   _get_archive   s    c         C   s  t  j j t  j j |  j ƒ ƒ } |  j | ƒ \ } } } z° g  | D]! } d | k rC | j d ƒ ^ qC } t g  | D] } t | ƒ | f ^ qt ƒ } xP g  | D] } | d ^ qŸ D]1 } d j	 | ƒ }	 | |	 ƒ }
 d |
 k r³ |
 Sq³ WWd  | j
 ƒ  Xt d | ƒ ‚ d  S(   Ns   PKG-INFOt   /i   s   Metadata-Versions   No PKG-INFO in archive: %s(   R   R   t   abspatht   normpathR   R   t   splitt   sortedt   lent   joint   closeR   (   R   R   R	   R   R
   t   xt   tuplest   schwarzR   t	   candidatet   data(    (    s,   lib/python2.7/site-packages/pkginfo/sdist.pyR   $   s    	.+$N(   t   __name__t
   __module__t   NoneR   t   classmethodR   R   (    (    (    s,   lib/python2.7/site-packages/pkginfo/sdist.pyR      s   t   UnpackedSDistc           B   s   e  Z d d  „ Z d „  Z RS(   c         C   sl   t  j j | ƒ r n7 t  j j | ƒ r< t  j j | ƒ } n t d | ƒ ‚ t t |  ƒ j | d | ƒd  S(   Ns   No such file: %sR   (	   R   R   t   isdirt   isfilet   dirnameR   t   superR/   R   (   R   R   R   (    (    s,   lib/python2.7/site-packages/pkginfo/sdist.pyR   9   s    c         C   sw   yD t  j j |  j d ƒ } t j | d d ƒ } | j ƒ  SWd  QXWn, t k
 rr } t d |  j | f ƒ ‚ n Xd  S(   Ns   PKG-INFOt   errorst   ignores*   Could not load %s as an unpacked sdist: %s(	   R   R   R$   R   t   ioR   R   t	   ExceptionR   (   R   t   pkg_infot   ft   e(    (    s,   lib/python2.7/site-packages/pkginfo/sdist.pyR   D   s    N(   R+   R,   R-   R   R   (    (    (    s,   lib/python2.7/site-packages/pkginfo/sdist.pyR/   8   s   (   R6   R   R   R   t   distributionR    R   R/   (    (    (    s,   lib/python2.7/site-packages/pkginfo/sdist.pyt   <module>   s   0