ó
žS]c           @@ sē   d  Z  d d l m Z m 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 d d l m Z d	   Z d
   Z d   Z d   Z d   Z d   Z d S(   s*   Commands related to the downloads section.i    (   t   absolute_importt   print_functionN(   t   load_project(   t   project_ops(   t   console_utils(   t   prepare_without_interaction(   t   PROVIDE_MODE_CHECKc   	      C@ sŊ   t  |   } | s | rB t | o$ |  rB t d d t j d St j | d | d | d | d | d | d	 | } | r t | j  t d
 |  d St j	 |  d Sd S(   s%   Add an item to the downloads section.sH   Error: mutually dependant parameters: --hash-algorithm and --hash-value.t   filei   t   env_spec_namet   env_vart   urlt   filenamet   hash_algorithmt
   hash_values   Added %s to the project file.i    N(
   R   t   boolt   printt   syst   stderrR   t   add_downloadt   status_descriptionR   t   print_status_errors(	   t   project_dirR   t   filename_variablet   download_urlR   R   R   t   projectt   status(    (    sN   lib/python2.7/site-packages/anaconda_project/internal/cli/download_commands.pyR      s$    	c      
   C@ s   t  |   } | j    t | d | d t } Wd QXt j | d | d | d | } | r t | j  t d j |   d St	 j
 |  d Sd S(	   s@   Remove a download requirement from project and from file system.R   t   modeNR	   t   prepare_results!   Removed {} from the project file.i    i   (   R   t   null_frontendR   R   R   t   remove_downloadR   R   t   formatR   R   (   R   R   R   R   t   resultR   (    (    sN   lib/python2.7/site-packages/anaconda_project/internal/cli/download_commands.pyR   +   s    c         C@ sn   t  |   } t j |  r d S| j |  r` t d j |    t j | j |  d d n
 t d  d S(   s&   List the downloads present in project.i   s   Downloads for project: {}
t	   name_attrt   titles   No downloads found in project.i    (   R   R   t   print_project_problemst	   downloadsR   R   t   print_names_and_descriptionst   download_requirements(   R   R   R   (    (    sN   lib/python2.7/site-packages/anaconda_project/internal/cli/download_commands.pyt   list_downloads=   s    
c         C@ s1   t  |  j |  j |  j |  j |  j |  j |  j  S(   s7   Start the download command and return exit status code.(   R   t	   directoryt   env_specR   R   R   R   R   (   t   args(    (    sN   lib/python2.7/site-packages/anaconda_project/internal/cli/download_commands.pyt   main_addK   s    !c         C@ s   t  |  j |  j |  j  S(   s>   Start the remove download command and return exit status code.(   R   R'   R(   R   (   R)   (    (    sN   lib/python2.7/site-packages/anaconda_project/internal/cli/download_commands.pyt   main_removeQ   s    c         C@ s   t  |  j |  j  S(   s<   Start the list download command and return exit status code.(   R&   R'   R(   (   R)   (    (    sN   lib/python2.7/site-packages/anaconda_project/internal/cli/download_commands.pyt	   main_listV   s    (   t   __doc__t
   __future__R    R   R   t*   anaconda_project.internal.cli.project_loadR   t   anaconda_projectR   t   anaconda_project.internal.cliR   t   anaconda_project.prepareR   t   anaconda_project.provideR   R   R   R&   R*   R+   R,   (    (    (    sN   lib/python2.7/site-packages/anaconda_project/internal/cli/download_commands.pyt   <module>   s   					