ó
{[c           @   sv   d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l Z d d l m Z d d l m Z d e f d „  ƒ  YZ	 d S(   iÿÿÿÿNi   (   t   Distribution(   t   STRING_TYPESt	   Installedc           B   s   e  Z d d  „ Z d „  Z RS(   c         C   s|   t  | t ƒ rP | |  _ y t | ƒ Wn t k
 r? d  } q\ Xt j | } n | j |  _ | |  _	 | |  _
 |  j ƒ  d  S(   N(   t
   isinstanceR   t   package_namet
   __import__t   ImportErrort   Nonet   syst   modulest   __name__t   packaget   metadata_versiont   extractMetadata(   t   selfR   R   (    (    s0   lib/python2.7/site-packages/pkginfo/installed.pyt   __init__   s    	
		c            s«  t  j j } |  j d  k	 r“|  j j } | d  k rB |  j j } n  d | } t |  j d d  ƒ } | d  k	 r“g  ‰  ‡  f d †  } xI t j D]> } | j	 | ƒ rŒ | | | d ƒ ƒ | | | | ƒ ƒ qŒ qŒ Wt  j j
 |  j j ƒ \ } } | | | | ƒ ƒ | | | d | ƒ ƒ xx ˆ  D]m }	 t  j j |	 ƒ rF| |	 d ƒ }
 n |	 }
 t  j j |
 ƒ rt j |
 d d ƒ } | j ƒ  SWd  QXqqWq“n  t j d	 |  j ƒ d  S(
   Ns   %s*.egg-infot   __file__c            s   ˆ  j  t j |  ƒ ƒ d  S(   N(   t   extendt   glob(   t   where(   t
   candidates(    s0   lib/python2.7/site-packages/pkginfo/installed.pyt   _add_candidate%   s    s   EGG-INFOs   ..s   PKG-INFOt   errorst   ignores!   No PKG-INFO found for package: %s(   t   ost   patht   joinR   R   t   __package__R
   t   getattrR   t
   startswitht   splitR   t   isdirt   existst   iot   opent   readt   warningst   warnR   (   R   t   opjR   t   patternt   fileR   t   entryt   dirt   namet	   candidateR   t   f(    (   R   s0   lib/python2.7/site-packages/pkginfo/installed.pyR#      s2    
N(   R
   t
   __module__R   R   R#   (    (    (    s0   lib/python2.7/site-packages/pkginfo/installed.pyR   
   s   (
   R   R!   R   R   R$   t   distributionR    t   _compatR   R   (    (    (    s0   lib/python2.7/site-packages/pkginfo/installed.pyt   <module>   s   