ó
>ň[c           @  s   d  Z  d d l m Z d d l Z d d l 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 e j d  Z d	   Z d
   Z d S(   uK   
Usage:
    anaconda download notebook
    anaconda download user/notebook
i˙˙˙˙(   t   unicode_literalsN(   t   errors(   t   get_server_api(   t   PACKAGE_TYPES(   t
   Downloadert   parset   has_environmentu   binstar.downloadc      
   C  sŐ   d } |  j  d d t j d | d | d t } | j d d d d	 d
 | j d d d d d	 d | j d d d d d d d j t t j     } | j d d d d j	 |  d	 d | j
 d t  d  S(   Nu0   Download notebooks from your Anaconda repositoryu   downloadt   formatter_classt   helpt   descriptiont   epilogu   handleu   user/notebookt   actionu   storeu   -fu   --forceu	   Overwriteu
   store_trueu   -ou   --outputu   Download ast   defaultu   .u   , u   -tu   --package-typeuO   Set the package type [{0}]. Defaults to downloading all package types availableu   appendt   main(   t
   add_parsert   argparset   RawDescriptionHelpFormattert   __doc__t   add_argumentt   joint   listR   t   keyst   formatt   set_defaultsR   (   t
   subparsersR	   t   parsert	   pkg_types(    (    s_   lib/python2.7/site-packages/anaconda_client-1.7.2-py2.7.egg/binstar_client/commands/download.pyR      s4    						c         C  sŞ  t  |  j |  j  } t |  j  \ } } | p= | j   d } t | | |  } |  j pj t t	 j
    } x> | D]6 } | t t	 j
    k rt t d j |    qt qt WyŔ | j | d |  j d |  j } x | j   D] \ } }	 | j |	  t j d j |  j |   t |  rß t j d j |   t j d  t j d j |   t j d	  qß qß WWn5 t j t j t j t f k
 rĽ}
 t j |
  n Xd  S(
   Nu   loginu   Invalid package type '{}'t   outputt   forceu   {} has been downloaded as {}u   {} has an environment embedded.u   Run:u       conda env create {}u)   To install the environment in your system(   R   t   tokent   siteR   t   handlet   userR   t   package_typeR   R   R   t	   ExceptionR   t   list_download_filesR   R   t   itemst   downloadt   loggert   infoR   R   t   DestionationPathExistst   NotFoundt   BinstarErrort   OSError(   t   argst   aserver_apit   usernamet   notebookt
   downloadert   packages_typest   tyt   download_filest   download_filet   download_distt   err(    (    s_   lib/python2.7/site-packages/anaconda_client-1.7.2-py2.7.egg/binstar_client/commands/download.pyR   9   s(    !$(   R   t
   __future__R    R   t   loggingt   binstar_clientR   t   binstar_client.utilsR   t   binstar_client.utils.configR   t   binstar_client.utils.notebookR   R   R   t	   getLoggerR&   R   R   (    (    (    s_   lib/python2.7/site-packages/anaconda_client-1.7.2-py2.7.egg/binstar_client/commands/download.pyt   <module>   s   	%