ó
¼S]c           @@ s¦  d  Z  d d l m Z m Z d d l Z d d l Z d d l 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
 „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z  d „  Z! d „  Z" d „  Z# d „  Z$ d „  Z% d „  Z& d „  Z' d „  Z( d „  Z) d  „  Z* d! „  Z+ d" „  Z, d# „  Z- d$ „  Z. d% „  Z/ d& „  Z0 d S('   s-   Commands related to the environments section.i    (   t   absolute_importt   print_functionN(   t   execv(   t   joint   exists(   t   load_project(   t   project_ops(   t   console_utils(   t	   conda_apic         C@ sE   |  r0 t  |  j ƒ | d  k	 r, t  | ƒ n  d St j |  ƒ d Sd  S(   Ni    i   (   t   printt   status_descriptiont   NoneR   t   print_status_errors(   t   statust   success_message(    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt   _handle_status   s    c         C@ sC   t  |  ƒ } t j | d | d | d | ƒ} t | d j | ƒ ƒ S(   sH   Add an environment with packages from specified channels to the project.t   namet   packagest   channelss)   Added environment {} to the project file.(   R   R   t   add_env_specR   t   format(   t   project_dirR   R   R   t   projectR   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyR   !   s    !c         C@ s7   t  |  ƒ } t j | d | ƒ} t | d j | ƒ ƒ S(   s5   Remove an environment with packages from the project.R   s-   Removed environment {} from the project file.(   R   R   t   remove_env_specR   R   (   R   R   R   R   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyR   (   s    c         C@ s1   t  |  ƒ } t j | d | d | ƒ} t | ƒ S(   s   Save an environment.yml file.R   t   filename(   R   R   t   export_env_specR   (   R   R   R   R   R   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyR   /   s    c         C@ sr   t  |  ƒ }  t j |  d | d | d | ƒ} d j | ƒ } | d k rU d | } n d | | f } t | | ƒ S(   s   Add packages to the project.t   env_spec_nameR   R   s   , s#   Added packages to project file: %s.s5   Added packages to environment %s in project file: %s.N(   R   R   t   add_packagesR   R   R   (   R   t   environmentR   R   R   t   package_listR   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyR   6   s    !c         C@ sl   t  |  ƒ }  t j |  d | d | ƒ} d j | ƒ } | d k rO d | } n d | | f } t | | ƒ S(   s!   Remove packages from the project.R   R   s   , s'   Removed packages from project file: %s.s9   Removed packages from environment %s in project file: %s.N(   R   R   t   remove_packagesR   R   R   (   R   R   R   R   R   R   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyR   B   s    c         C@ sl   t  |  ƒ }  t j |  d | d | ƒ} d j | ƒ } | d k rO d | } n d | | f } t | | ƒ S(   s   Add platforms to the project.R   t	   platformss   , s$   Added platforms to project file: %s.s6   Added platforms to environment %s in project file: %s.N(   R   R   t   add_platformsR   R   R   (   R   R   R   R   R   R   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyR    N   s    c         C@ sl   t  |  ƒ }  t j |  d | d | ƒ} d j | ƒ } | d k rO d | } n d | | f } t | | ƒ S(   s"   Remove platforms from the project.R   R   s   , s(   Removed platforms from project file: %s.s:   Removed platforms from environment %s in project file: %s.N(   R   R   t   remove_platformsR   R   R   (   R   R   R   R   R   R   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyR!   Z   s    c         C@ sL   t  |  ƒ } t j | ƒ r d St d j |  ƒ ƒ t j | j j ƒ  ƒ d S(   s!   List environments in the project.i   s   Environments for project: {}
i    (   R   R   t   print_project_problemsR	   R   t   print_names_and_descriptionst	   env_specst   values(   R   R   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt   list_env_specsf   s    c         C@ s´   t  |  ƒ } t j | ƒ r d S| d	 k r7 | j } n  | j j | d	 ƒ } | d	 k rx t d j | ƒ d t	 j
 ƒd St d j | j ƒ ƒ t d j t | j ƒ ƒ d d ƒd S(
   s4   List the packages for an environment in the project.i   s/   Project doesn't have an environment called '{}'t   files   Packages for environment '{}':
s   
t   ends   

i    N(   R   R   R"   R   t   default_env_spec_nameR$   t   getR	   R   t   syst   stderrR   R   t   sortedt   conda_packages(   R   R   R   t   env(    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt   list_packagesp   s    "c         C@ s´   t  |  ƒ } t j | ƒ r d S| d	 k r7 | j } n  | j j | d	 ƒ } | d	 k rx t d j | ƒ d t	 j
 ƒd St d j | j ƒ ƒ t d j t | j ƒ ƒ d d ƒd S(
   s5   List the platforms for an environment in the project.i   s/   Project doesn't have an environment called '{}'R'   s    Platforms for environment '{}':
s   
R(   s   

i    N(   R   R   R"   R   R)   R$   R*   R	   R   R+   R,   R   R   R-   R   (   R   R   R   R/   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt   list_platforms€   s    "c         C@ s>   t  |  ƒ } t j | ƒ r d St j | d | ƒ} t | ƒ S(   s   Lock dependency versions.i   R   (   R   R   R"   R   t   lockR   (   R   R   R   R   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyR2      s
    c         C@ s>   t  |  ƒ } t j | ƒ r d St j | d | ƒ} t | ƒ S(   s   Update dependency versions.i   R   (   R   R   R"   R   t   updateR   (   R   R   R   R   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyR3   ™   s
    c         C@ s>   t  |  ƒ } t j | ƒ r d St j | d | ƒ} t | ƒ S(   s   Unlock dependency versions.i   R   (   R   R   R"   R   t   unlockR   (   R   R   R   R   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyR4   ¢   s
    c         C@ s   t  |  j |  j |  j |  j ƒ S(   s>   Start the add-environment command and return exit status code.(   R   t	   directoryR   R   t   channel(   t   args(    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt   main_add«   s    c         C@ s   t  |  j |  j ƒ S(   sA   Start the remove-environment command and return exit status code.(   R   R5   R   (   R7   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt   main_remove°   s    c         C@ s   t  |  j |  j |  j ƒ S(   s>   Start the export env spec command and return exit status code.(   R   R5   R   R   (   R7   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt   main_exportµ   s    c         C@ s   t  |  j |  j |  j |  j ƒ S(   s;   Start the add-packages command and return exit status code.(   R   R5   t   env_specR   R6   (   R7   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt   main_add_packagesº   s    c         C@ s   t  |  j |  j |  j ƒ S(   s>   Start the remove-packages command and return exit status code.(   R   R5   R;   R   (   R7   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt   main_remove_packages¿   s    c         C@ s   t  |  j |  j |  j ƒ S(   s<   Start the add-platforms command and return exit status code.(   R    R5   R;   R   (   R7   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt   main_add_platformsÄ   s    c         C@ s   t  |  j |  j |  j ƒ S(   s?   Start the remove-platforms command and return exit status code.(   R!   R5   R;   R   (   R7   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt   main_remove_platformsÉ   s    c         C@ s   t  |  j ƒ S(   s@   Start the list environments command and return exit status code.(   R&   R5   (   R7   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt   main_list_env_specsÎ   s    c         C@ s   t  |  j |  j ƒ S(   s<   Start the list packages command and return exit status code.(   R0   R5   R;   (   R7   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt   main_list_packagesÓ   s    c         C@ s   t  |  j |  j ƒ S(   s=   Start the list platforms command and return exit status code.(   R1   R5   R;   (   R7   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt   main_list_platformsØ   s    c         C@ s   t  |  j |  j ƒ S(   s5   Lock dependency versions and return exit status code.(   R2   R5   R   (   R7   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt	   main_lockÝ   s    c         C@ s   t  |  j |  j ƒ S(   s7   Update dependency versions and return exit status code.(   R3   R5   R   (   R7   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt   main_updateâ   s    c         C@ s   t  |  j |  j ƒ S(   s7   Unlock dependency versions and return exit status code.(   R4   R5   R   (   R7   (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt   main_unlockç   s    c         C@ s[   t  |  j ƒ sW |  j d } t | j | j ƒ } t j d |  j d | d | j ƒ n  d S(   so   Create a project bootstrap env, if it doesn't exist.

    Input:
        project(project.Project): project
    s   bootstrap-envt   prefixt   pkgsR   N(	   R   t   bootstrap_env_prefixR$   t   listR.   t   pip_packagesR   t   createR   (   R   R;   t   command_line_packages(    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt   create_bootstrap_envì   s    c         C@ sJ   t  j ƒ  d k r d } n d } t |  j | d ƒ } t | t j ƒ d S(   sn   Run the current command in a project bootstrap env.

    Input:
        project(project.Project): project
    t   Windowst   Scriptst   bins   anaconda-projectN(   t   platformt   systemR   RH   R   R+   t   argv(   R   t
   script_dirt   anaconda_project_exec(    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt   run_on_bootstrap_envø   s
    	(1   t   __doc__t
   __future__R    R   R+   RQ   t   osR   t   os.pathR   R   t*   anaconda_project.internal.cli.project_loadR   t   anaconda_projectR   t   anaconda_project.internal.cliR   t   anaconda_project.internalR   R   R   R   R   R   R   R   R    R!   R&   R0   R1   R2   R3   R4   R8   R9   R:   R<   R=   R>   R?   R@   RA   RB   RC   RD   RE   RM   RV   (    (    (    sQ   lib/python2.7/site-packages/anaconda_project/internal/cli/environment_commands.pyt   <module>   sL   								
																						