ó
Ò:\c           @   s§   d  Z  d d l Z d d l Z d d l Z d d l Z e j j e j j e ƒ ƒ Z	 e j j e	 ƒ Z
 e j j e
 d d d d ƒ Z d „  Z e d k r£ e ƒ  n  d S(	   sn   
Script to download and bundle the latest metadata while the mechanism
is implemented on bith repo and cloud.
iÿÿÿÿNt   anaconda_navigatort   statict   contents   metadata.json.bz2c    
      C   s  d }  t  } t j |  d t ƒ} t j ƒ  \ } } d |  f GHd | f GHd | j f GHt | d ƒ : } x0 | j d d ƒ D] } | r| | j	 | ƒ q| q| WWd	 QXd
 } t | d ƒ * } | j
 ƒ  } d GHt j | | ƒ }	 Wd	 QXd GHt | d ƒ  } | j	 |	 ƒ Wd	 QXd GHd	 S(   s>   Download latest metadata.json file, compress it and budnle it.s,   https://repo.anaconda.com/pkgs/metadata.jsont   streams   Downloading:s   File:s   Status:t   wbt
   chunk_sizei   Ni	   t   rbs   Compressing files   Writing compressed files	   Finished!(   t   METADATA_PATHt   requestst   gett   Truet   tempfilet   mkstempt   status_codet   opent   iter_contentt   writet   readt   bz2t   compress(
   t   urlt   filepatht   responset   handlet   temppatht   chunkt   compression_levelt   ft   datat   compressed_contents(    (    s6   lib/python2.7/site-packages/scripts/update_metadata.pyt   update_bundled_metadata   s(    t   __main__(   t   __doc__R   t   osR   R   t   patht   dirnamet   realpatht   __file__t	   HERE_PATHt   NAVIGATOR_PATHt   joinR   R   t   __name__(    (    (    s6   lib/python2.7/site-packages/scripts/update_metadata.pyt   <module>   s   			