ó
Ý²k^c           @` s¨  d  d l  m Z m Z m Z m Z d  d l m Z d  d l m Z d  d l	 m
 Z
 d  d l m Z d  d l m Z d  d l Z d  d l m Z d  d l Z d  d	 l m Z d  d
 l m Z d  d l m Z m Z m Z d d l m Z m Z d d l m Z d d l m  Z  d d l! m" Z" d d l# m$ Z$ d d l% m& Z& d d l' m( Z( d d l) m* Z* m+ Z+ m, Z, m- Z- d d l. m/ Z/ m0 Z0 m1 Z1 d d l2 m3 Z3 d d l4 m5 Z5 m6 Z6 m7 Z7 d d l8 m9 Z9 m: Z: d d l; m< Z< m= Z= m> Z> m? Z? e e@ ƒ ZA e Z e e e Z Z Z d „  ZB d „  ZC d „  ZD d „  ZE d „  ZF d  „  ZG d! „  ZH d" „  ZI d# „  ZJ d$ „  ZK d% „  ZL d& „  ZM d' „  ZN d( „  ZO d) „  ZP d* „  ZQ d S(+   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literals(   t	   b64encode(   t
   namedtuple(   t   ENOENT(   t   partial(   t   globN(   t   chain(   t	   getLogger(   t   listdir(   t   isdirt   isfilet   joini   (   t   islinkt   lexists(   t   TemporaryDirectoryi   (   t   first(   t   shlex_split_unicode(   t   dals(   t   PREFIX_PLACEHOLDER(   t   open(   t   PythonDistributiont   PythonEggInfoDistributiont   PythonEggLinkDistributiont   PythonInstalledDistribution(   t   CondaUpgradeErrort   CondaVerificationErrort   PathNotFoundError(   t   Channel(   t   FileModet   PackageTypet   PathType(   t   PackageInfot   PackageMetadata(   t   PathDatat
   PathDataV1t	   PathsDatat   PrefixRecordc         c` sŒ   yW t  |  ƒ E } x; | D]3 } | j ƒ  } | s | j d ƒ rG q n  | Vq WWd QXWn. t t f k
 r‡ } | j t k r qˆ ‚  n Xd S(   uÉ   Generator function for lines in file.  Empty generator if path does not exist.

    Args:
        path (str): path to file

    Returns:
        iterator: each line in file, not starting with '#'

    u   #N(   R   t   stript
   startswitht   IOErrort   OSErrort   errnoR   (   t   patht   fht   linet   e(    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyt   yield_lines)   s    
c         C` s   t  | ƒ s t | ƒ ‚ n  t j |  ƒ } t | d ƒ : } x0 t t | j d ƒ d ƒ D] } | j | ƒ qX WWd  QX| j	 ƒ  S(   Nu   rbi    t    (
   R   R   t   hashlibt   newR   t   iterR   t   readt   updatet	   hexdigest(   t   algoR-   t   hasherR.   t   chunk(    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyt   _digest_pathA   s    "c         C` s   t  d |  ƒ S(   Nu   md5(   R<   (   t   file_full_path(    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyt   compute_md5sumL   s    c         C` s   t  d |  ƒ S(   Nu   sha256(   R<   (   R=   (    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyt   compute_sha256sumP   s    c          G` s<   x5 |  D]- } x$ t  | ƒ D] } t | ƒ r | Sq Wq Wd  S(   N(   R   R   t   None(   t   globst   gR-   (    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyt   find_first_existingT   s
    c         C` s|   | j  } t | ƒ } t | ƒ } t | ƒ } t d | d | j d t |  j pT |  j ƒ d |  d | j	 d | d | d | ƒ S(	   Nt   extracted_package_dirt   package_tarball_full_patht   channelt   repodata_recordt   urlt   icondatat   package_metadatat
   paths_data(
   RD   t   read_icondatat   read_package_metadatat   read_paths_jsonR"   RE   R   t   schannelRF   RH   (   t   recordt   package_cache_recordt   epdRI   RJ   RK   (    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyt   read_package_info`   s    			c         C` s2   t  t |  d d ƒ ƒ  } t j | ƒ SWd  QXd  S(   Nu   infou
   index.json(   R   R   t   jsont   load(   t   extracted_package_directoryt   fi(    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyt   read_index_jsons   s    c      
   C` sh   d d  l  } t ƒ  M } | j j |  | d ƒ t t | d d ƒ ƒ  } t j | ƒ } Wd  QXWd  QX| S(   Ni    u   infou
   index.json(   t   conda_package_handling.apiR   t   apit   extractR   R   RT   RU   (   RE   t   conda_package_handlingt   tmpdirt   ft	   json_data(    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyt   read_index_json_from_tarballx   s    c         C` s2   t  t |  d d ƒ ƒ  } t j | ƒ SWd  QXd  S(   Nu   infou   repodata_record.json(   R   R   RT   RU   (   RV   RW   (    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyt   read_repodata_json   s    c         C` s]   t  |  d d ƒ } t | ƒ rU t | d ƒ  } | j ƒ  } Wd  QXt | ƒ j d ƒ Sd  Sd  S(   Nu   infou   icon.pngu   rbu   utf-8(   R   R   R   R6   R   t   decodeR@   (   RV   t   icon_file_pathR^   t   data(    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyRL   †   s    c         ` s™   ‡  f d †  } t  | ƒ  d t ƒ} | s. d  St | d ƒ F } t j | j ƒ  ƒ } | j d ƒ d k r t t	 d ƒ ƒ ‚ n  Wd  QXt
 |   } | Sd  S(   Nc           3` s&   t  ˆ  d d ƒ Vt  ˆ  d d ƒ Vd  S(   Nu   infou	   link.jsonu   package_metadata.json(   R   (    (   RV   (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyt   _paths‘   s    t   keyu   ru   package_metadata_versioni   ué   
                The current version of conda is too old to install this package. (This version
                only supports link.json schema version 1.)  Please update conda to install
                this package.
                (   R   R   R@   R   RT   t   loadsR6   t   getR   R   R#   (   RV   Re   R-   R^   Rd   RJ   (    (   RV   s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyRM      s    c         ` sÿ   t  ˆ  d ƒ ‰ t  ˆ d ƒ } t | ƒ rž t | ƒ  } t j | ƒ } Wd  QX| j d ƒ d k rx t t d ƒ ƒ ‚ n  t d d d d „  | d	 Dƒ ƒ } n] t	 t  ˆ d
 ƒ ƒ ‰ t
 ˆ ƒ ‰ ‡  ‡ ‡ ‡ f d †  } t | ƒ  ƒ } t d d d | ƒ } | S(   Nu   infou
   paths.jsonu   paths_versioni   uÍ   
            The current version of conda is too old to install this package. (This version
            only supports paths.json schema version 1.)  Please update conda to install
            this package.t   paths_versiont   pathsc         s` s   |  ] } t  |   Vq d  S(   N(   R%   (   t   .0R^   (    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pys	   <genexpr>²   s    u   pathsu
   has_prefixc          3` sÚ   t  ˆ d ƒ }  xÄ d „  d „  t |  ƒ Dƒ Dƒ D]¢ } i | d 6} | ˆ j ƒ  k r| ˆ | d | d <ˆ | d | d <n  | ˆ k r• t | d	 <n  t t  ˆ  | ƒ ƒ rº t j | d
 <n t j | d
 <t |   Vq0 Wd  S(   Nu   filesc         s` s   |  ] } | r | Vq d  S(   N(    (   Rk   t   ln(    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pys	   <genexpr>º   s    c         s` s   |  ] } | j  ƒ  Vq d  S(   N(   R(   (   Rk   R/   (    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pys	   <genexpr>º   s    u   _pathi    u   prefix_placeholderi   u	   file_modeu   no_linku	   path_type(	   R   R1   t   keyst   TrueR   R!   t   softlinkt   hardlinkR$   (   t
   files_pathR^   t	   path_info(   RV   t   has_prefix_filest   info_dirt   no_link(    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyt   read_files_file¸   s    'i    (   R   R   R   RT   RU   Rh   R   R   R&   t   read_has_prefixt   read_no_linkt   tuple(   RV   t   paths_json_patht
   paths_jsonRd   RK   Rv   Rj   (    (   RV   Rs   Rt   Ru   s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyRN   ¥   s&    	c         ` sK   t  d d ƒ ‰  ‡  ‡ f d †  ‰ ‡ f d †  t ˆ ƒ Dƒ } d „  | Dƒ S(	   uû   
    reads `has_prefix` file and return dict mapping filepaths to tuples(placeholder, FileMode)

    A line in `has_prefix` contains one of
      * filepath
      * placeholder mode filepath

    mode values are one of
      * text
      * binary
    u   ParseResultu   placeholderu   filemodeu   filepathc         ` s“   t  d „  t |  d t ƒDƒ ƒ } t | ƒ d k rK ˆ  t t j | d ƒ St | ƒ d k r ˆ  | d t | d ƒ | d ƒ St d ˆ ƒ ‚ d  S(   Nc         s` s   |  ] } | j  d  ƒ Vq d S(   u   "'N(   R(   (   Rk   t   x(    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pys	   <genexpr>ß   s    t   posixi   i    i   i   u#   Invalid has_prefix file at path: %s(   Ry   R   t   Falset   lenR   R   t   textR   (   R/   t   parts(   t   ParseResultR-   (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyt
   parse_lineÝ   s    ""c         3` s   |  ] } ˆ  | ƒ Vq d  S(   N(    (   Rk   R/   (   Rƒ   (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pys	   <genexpr>ç   s    c         S` s(   i  |  ] } | j  | j f | j “ q S(    (   t   placeholdert   filemodet   filepath(   Rk   t   pr(    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pys
   <dictcomp>è   s   	 (   u   placeholderu   filemodeu   filepath(   R   R1   (   R-   t   parsed_lines(    (   R‚   Rƒ   R-   s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyRw   Ï   s    
c         C` s1   t  t t t |  d ƒ ƒ t t |  d ƒ ƒ ƒ ƒ S(   Nu   no_linku   no_softlink(   t   setR	   R1   R   (   Rt   (    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyRx   ë   s    c         ` s   t  ‡  f d †  | Dƒ ƒ S(   Nc         3` s*   |  ]  } t  t ˆ  | ƒ ƒ r | Vq d  S(   N(   R   R   (   Rk   R^   (   RV   (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pys	   <genexpr>ñ   s    (   Ry   (   RV   t   files(    (   RV   s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyt   read_soft_linksð   s    c         C` sÞ  t  j |  | | ƒ } | j ƒ  \ } } t | t ƒ r• t d ƒ } d } t j } | j ƒ  }	 t	 d d d d „  |	 Dƒ ƒ }
 t
 d „  |	 Dƒ ƒ } nñ t | t ƒ rÞ t d ƒ } d	 } t j } t	 d d d d ƒ d }
 } n¨ t | t ƒ r}t d ƒ } d } | j rUt j } | j ƒ  }	 t
 d
 „  |	 Dƒ ƒ } t	 d d d d „  | Dƒ ƒ }
 q†t j } t	 d d d d ƒ d }
 } n	 t ƒ  ‚ t d | d | j d | j d | d d d | j d | d d d |
 d | d | d | ƒ S(   uz   
    Convert a python package defined by an anchor file (Metadata information)
    into a conda prefix record object.
    u   pypiu   pypi_0Ri   i   Rj   c      
   s` s<   |  ]2 \ } } } t  d  | d t j d | d | ƒ Vq d S(   t   _patht	   path_typet   sha256t   size_in_bytesN(   R%   R!   Rp   (   Rk   R-   t   checksumt   size(    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pys	   <genexpr>  s   c         s` s   |  ] } | d  Vq d S(   i    N(    (   Rk   t   p(    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pys	   <genexpr>  s    u	   <develop>u   dev_0c         s` s   |  ] } | d  Vq d S(   i    N(    (   Rk   R’   (    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pys	   <genexpr>  s    c         s` s'   |  ] } t  d  | d t j ƒ Vq d S(   RŒ   R   N(   R$   R!   Rp   (   Rk   R-   (    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pys	   <genexpr>  s    t   package_typet   namet   versionRF   t   subdirt   fnt   buildt   build_numberi    RK   RŠ   t   dependst
   constrains(    (    (    (    (   R   t   initt   get_conda_dependenciest
   isinstanceR   R   R    t   VIRTUAL_PYTHON_WHEELt	   get_pathsR&   Ry   R   t   VIRTUAL_PYTHON_EGG_LINKR   t   is_manageablet   VIRTUAL_PYTHON_EGG_MANAGEABLEt   VIRTUAL_PYTHON_EGG_UNMANAGEABLEt   NotImplementedErrorR'   t
   conda_nameR•   t   sp_reference(   t   prefix_patht   anchor_filet   python_versiont   pydistRš   R›   RF   R˜   R“   t
   paths_tupsRK   RŠ   (    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyt   read_python_recordô   sR    									(R   t
   __future__R    R   R   R   t   base64R   t   collectionsR   R,   R   t	   functoolsR   R   R3   t	   itertoolsR	   RT   t   loggingR
   t   osR   t   os.pathR   R   R   t   linkR   R   t   createR   t   _vendor.auxlib.collectionR   t   _vendor.auxlib.compatR   t   _vendor.auxlib.ishR   t   base.constantsR   t   common.compatR   t   common.pkg_formats.pythonR   R   R   R   t
   exceptionsR   R   R   t   models.channelR   t   models.enumsR   R    R!   t   models.package_infoR"   R#   t   models.recordsR$   R%   R&   R'   t   __name__t   logR1   R<   R>   R?   RC   RS   RX   R`   Ra   RL   RM   RN   Rw   Rx   R‹   R­   (    (    (    s7   lib/python2.7/site-packages/conda/gateways/disk/read.pyt   <module>   sV   """											
		*			