ó
>ò†[c           @  sÝ   d  d l  m Z d  d l m Z d  d l m Z 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 i d d 6d	 d
 6Z e j d ƒ Z d „  Z d „  Z d „  Z d „  Z e d k rÙ e ƒ  n  d S(   iÿÿÿÿ(   t   print_function(   t   path(   t   pprintNi   (   t   data_uri_fromt   darwint   osxt   win32t   wins   ^([=><]+)(.*)$c   	      C  s¨  g  } x”|  D]Œ} | j  ƒ  } | j d d ƒ } t | ƒ d k rj | \ } | j i | d 6g  d 6ƒ q t | ƒ d k rû | \ } } | j d ƒ r¤ | d  } n  t j | ƒ } | rÎ | j ƒ  \ } } n d } | j i | d 6| | g g d 6ƒ q t | ƒ d	 k r | \ } } } | j d ƒ r8| d  } n  t j | ƒ } | rb| j ƒ  \ } } n d } | j i | d 6d d
 | | f g g d 6ƒ q q Wi | d 6S(   s:   
    Format dependencies into a common binstar format
    t    i   t   namet   specsi   t   *iÿÿÿÿs   ==i   s   %s+%st   depends(   t   stript   splitt   lent   appendt   endswitht   specs_ret   matcht   groups(	   t   depsR   t   dept	   name_specR	   t   specR   t   opt	   build_str(    (    sc   lib/python2.7/site-packages/anaconda_client-1.7.2-py2.7.egg/binstar_client/inspect_package/conda.pyt   transform_conda_deps   s4    	'5c         C  sw   y |  d SWnd t  k
 rr |  j d ƒ } | d
 k r; d Si d d 6d d 6} d |  j d	 ƒ | j | | ƒ f SXd
 S(   sž  
    Return the sub-directory given the index dictionary.  The return
    value is obtained in the following order:

    1. when the 'subdir' key exists, it's value is returned
    2. if the 'arch' is None, or does not exist, 'noarch' is returned
    3. otherwise, the return value is constructed from the 'platform' key
       and the 'arch' key (where 'x86' is replaced by '32',
       and 'x86_64' by '64')
    t   subdirt   archt   noarcht   32t   x86t   64t   x86_64s   %s-%st   platformN(   t   KeyErrort   gett   None(   t   indexR   t	   intel_map(    (    sc   lib/python2.7/site-packages/anaconda_client-1.7.2-py2.7.egg/binstar_client/inspect_package/conda.pyt
   get_subdir;   s    c         O  sq  d  i  t } } } t j |  d | d d ƒ-} x#| D] } | j d k r{ | j | ƒ } t j | j ƒ  j	 ƒ  ƒ } n¢ | j d k rÉ | j | ƒ }	 t j |	 j ƒ  j	 ƒ  ƒ }	 |	 j
 d i  ƒ } nT | j d k r| j | ƒ } t j | j ƒ  j	 ƒ  ƒ } n | j d k rt } n  | d  k	 r9 | i  k r9 Pq9 q9 W| d  k rXt d	 ƒ ‚ n  Wd  QX| j d
 ƒ d  }
 | j d ƒ } | r)t j |  d | d d ƒ} x… | D]z } | j d j | ƒ k r¨| j | ƒ j ƒ  } t j ƒ  \ } } t | d ƒ  } | j | ƒ Wd  QXt | ƒ }
 Pq¨q¨Wn  t | ƒ } | d } t j | d | d ƒ } i
 | j
 d ƒ d 6| j d d ƒ d 6| j d d ƒ d 6| j d ƒ d 6| j d ƒ d 6| j d ƒ d 6| j d ƒ d 6| j d ƒ d 6| j d ƒ d 6| j d ƒ d 6} i | j
 d ƒ d 6| j d ƒ d 6| j d d ƒ d 6| j d d ƒ d 6| j d ƒ d 6| j d ƒ d 6| j d ƒ d 6| j d ƒ d 6| j d ƒ d 6|
 d 6| j d ƒ d 6| j d ƒ d 6| j d ƒ d 6} i d | t j |  ƒ f d 6i | d  6| d! 6d" | | f d# 6| d$ 6d% 6} | d% j | ƒ | j d& | j d' g  ƒ ƒ } t | ƒ | d( <| | | f S()   Nt   fileobjt   modes   r|bz2s   info/index.jsons   info/recipe.jsont   abouts   info/about.jsons   info/has_prefixs)   info/index.json required in conda packagei    t   icons   info/{0}t   wbR   R#   R	   t   summaryt    t   descriptiont   licenset   license_urlt   license_familyt   dev_urlt   doc_urlt   homet   source_git_urlt   versiont	   home_paget   source_git_tags   %s/%st   basenamet   operatingsystemt   machines	   %s-any-%ss   target-triplett
   has_prefixt   attrsR   t   requirest   dependencies(   R&   t   Falset   tarfilet   openR	   t   extractfilet   jsont   loadst   readt   decodet   popt   Truet	   TypeErrort   seekR%   t   formatt   tempfilet   mkstempt   writeR   R)   t   os_mapR   R<   t   updateR   (   t   filenameR*   t   argst   kwargsR'   R,   R?   t   tart   infot   recipet   icon_b64t	   icon_patht	   icon_datat   ft	   temp_pathR   R>   R=   t   package_datat   release_datat	   file_datat   conda_depends(    (    sc   lib/python2.7/site-packages/anaconda_client-1.7.2-py2.7.egg/binstar_client/inspect_package/conda.pyt   inspect_conda_packageP   sŽ    	
c          C  sp   t  j d }  t |  ƒ  } t |  | ƒ \ } } } Wd  QXt | ƒ t d ƒ t | ƒ t d ƒ t | ƒ d  S(   Ni   s   --(   t   syst   argvRE   Rd   R   t   print(   RU   R*   R`   Ra   Rb   (    (    sc   lib/python2.7/site-packages/anaconda_client-1.7.2-py2.7.egg/binstar_client/inspect_package/conda.pyt   main­   s    



t   __main__(   t
   __future__R    t   osR   R   RG   t   reRe   RD   RP   t   utils.notebook.data_uriR   RS   t   compileR   R   R)   Rd   Rh   t   __name__(    (    (    sc   lib/python2.7/site-packages/anaconda_client-1.7.2-py2.7.egg/binstar_client/inspect_package/conda.pyt   <module>   s    	'		]	
