ó
+Yc        
   @   sy  d  d l  Z  d  d l Z d  d l Z d  d l m Z d  d l m Z d d l m Z m	 Z	 m
 Z
 m Z d d l m Z e j d e j d d	   j d
  Z e j   d    Z e j d d  e j d d e d d d     Z e j d d  e j d d e d d e j d d e d d d e d      Z e j d d  e j d d e d d d     Z d S(   i˙˙˙˙N(   t
   AsciiTable(   t   EnvsValueExceptioni   (   t   convert_modulet
   import_modt   list_envs_modulet	   raw_input(   t   envt   loadert   envst	   templatess   settings.jinja2c           C   s   d  S(   N(    (    (    (    s&   /home/brian/workspace/envs/envs/cli.pyR      s    t   helps3   Converts an existing settings file so it uses envs.s   --settings-filet   prompts1   Settings Module? ex. settings or yourapp.settingsc         C   s   t  t |    } t j d |  } t d  } | sE t d   n  t | d   } | j |  Wd  QXt j	 t j
 d j |  d d  d  S(   Nt	   attr_listst   What should we name this new settings file? (DO NOT NAME IT THE SAME AS THE ORIGINAL BECAUSE THERE ARE NO IMPORTS): s   Settings filename is required.s   w+s   Your new settings file {}t   fgt   green(   R   R   t   SETTINGS_TEMPLATEt   renderR   t
   ValueErrort   opent   writet   clickt   echot   stylet   format(   t   settings_fileR   t   templatet   new_settings_filenamet   f(    (    s&   /home/brian/workspace/envs/envs/cli.pyt   convert_settings   s    s5   Shows a list of env instances set in a settings file.s   --keep-results$   Keep the result file (.envs_result)?t   defaultc         C   s§   t  |   } d d d d g g } | j g  | D]B } | j d  | j d  t | j d   | j d  g ^ q.  t j t |  j  | sŁ t j	 d	  n  d  S(
   Ns   Env Vars   Var Types   Has Defaults   Environment Valuet   keyt   var_typeR   t   values   .envs_result(
   R   t   extendt   gett   boolR   R   R    t   tablet   ost   remove(   R   t   keep_resultt   envs_resultt
   table_datat   row(    (    s&   /home/brian/workspace/envs/envs/cli.pyt	   list_envs!   s    VsZ   Make sure that the defined envs with no default value have a value set in the environment.c         C   s   t  |   } xe | D]] } t | j d  | j d  d | j d  } | s t d j | j d     q q Wt j d  d  S(   NR   R   R   s    {}: Environment Variable Not Sets   .envs_result(   R   R   R"   R   R   R%   R&   (   R   R(   R*   R    (    (    s&   /home/brian/workspace/envs/envs/cli.pyt
   check_envs1   s    0%(   R%   R   t   jinja2t   terminaltablesR    t   envs.exceptionsR   t   utilR   R   R   R   t    R   t   Environmentt   PackageLoadert   get_templateR   t   groupR   t   commandt   optiont   TrueR   t   FalseR+   R,   (    (    (    s&   /home/brian/workspace/envs/envs/cli.pyt   <module>   s&   "0