ó
¼S]c           @@ s–   d  Z  d d l m Z m Z d d l Z y d d l m Z Wn! e k
 r_ d d l m Z n Xd d l	 m
 Z
 d d l m Z d „  Z d „  Z d S(	   se   The ``activate`` command which prepares a project to run and prints commands to source in your shell.i    (   t   absolute_importt   print_functionN(   t   quote(   t$   prepare_with_ui_mode_printing_errors(   t   load_projectc   
      C@ sÈ   t  |  ƒ } t | d | d | d | ƒ} | j r7 d Sg  } t | j j ƒ  ƒ } | j ƒ  xe | D]] } | j | }	 | t j k s˜ t j | |	 k rc | j	 d j
 d | d t |	 ƒ ƒ ƒ qc qc W| S(   s¹   Prepare project and return lines to be sourced.

    Future direction: should also activate the proper conda env.

    Returns:
        None on failure or a list of lines to print.
    t   ui_modet   env_spec_namet   command_names   export {key}={value}t   keyt   valueN(   R   R   t   failedt   Nonet   listt   environt   keyst   sortt   ost   appendt   formatR   (
   t   dirnameR   t   conda_environmentR   t   projectt   resultt   exportst   sorted_keysR   R	   (    (    sE   lib/python2.7/site-packages/anaconda_project/internal/cli/activate.pyt   activate   s    	
",c         C@ sT   t  |  j |  j |  j |  j ƒ } | d k r1 d Sx | D] } t | ƒ q8 Wd Sd S(   s7   Start the activate command and return exit status code.i   i    N(   R   t	   directoryt   modet   env_spect   commandR   t   print(   t   argsR   t   line(    (    sE   lib/python2.7/site-packages/anaconda_project/internal/cli/activate.pyt   main/   s    !(   t   __doc__t
   __future__R    R   R   t   shlexR   t   ImportErrort   pipest/   anaconda_project.internal.cli.prepare_with_modeR   t*   anaconda_project.internal.cli.project_loadR   R   R!   (    (    (    sE   lib/python2.7/site-packages/anaconda_project/internal/cli/activate.pyt   <module>   s   	