σ
lz]c           @` s‘  d  d l  m Z m Z m Z m Z d  d l m 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 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 d l m Z d d  d d  Z d d e d  Z d   Z e e d  Z  e d  Z! e
 j" d e
 j#  Z$ d   Z% d   Z& e d  Z' d   Z( d   Z) e d    Z* e+ d  Z, e+ d  Z- d   Z. d S(!   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literals(   t	   getLogger(   t   basenamet   dirnameNi   (   t   dals(   t   ROOT_ENV_NAME(   t   context(   t   NULL(   t   swallow_broken_pipe(   t   paths_equal(   t	   json_dump(   t	   MatchSpecu   Proceedu   yesu   noc         C` sG  | | k s t  |   t j r= d d l m } |    n  g  } xC | D]; } | | k rt | j d | d  qJ | j | d  qJ Wd |  d j |  f }  d   | D } | | d <x t rBt j	 j
 |   t j	 j   t j j   j   j   } | | k rt d	 |  qΏ t j	 j
 d
  t j	 j   | | SqΏ Wd  S(   Ni   (   t
   DryRunExitu   [%s]i    u	   %s (%s)? u   /c         S` s0   i  |  ]& } | | d  g D] } | |  q q S(   i    (    (   t   .0t   choicet   alt(    (    s/   lib/python2.7/site-packages/conda/cli/common.pys
   <dictcomp>"   s   	u    u   Invalid choice: %su   
(   t   AssertionErrorR	   t   dry_runt
   exceptionsR   t   appendt   joint   Truet   syst   stdoutt   writet   flusht   stdint   readlinet   stript   lowert   print(   t   messaget   choicest   defaultR   t   optionst   optiont   user_choice(    (    s/   lib/python2.7/site-packages/conda/cli/common.pyt   confirm   s,    	

	c         C` sΘ   | t  k r t j n | } | r= d d l m } |    n  t j rJ t Sy t d |  d d d |  } Wn- t k
 r d d l m	 } | d	   n X| d k rΔ d d l m	 } | d
   n  t S(   Ni   (   R   R"   R#   u   yesu   noR$   (   t   CondaSystemExitu   
Operation aborted.  Exiting.u   Exiting.(   u   yesu   no(
   R
   R	   R   R   R   t
   always_yesR   R(   t   KeyboardInterruptR)   (   R"   R$   R   R   R   R)   (    (    s/   lib/python2.7/site-packages/conda/cli/common.pyt
   confirm_yn3   s    	c         C` s9   |  j  p |  j s5 d d l m } | d |   n  d  S(   Ni   (   t   CondaValueErroruO   either -n NAME or -p PREFIX option required,
try "conda %s -h" for more details(   t   namet   prefixR   R-   (   t   argst   commandR-   (    (    s/   lib/python2.7/site-packages/conda/cli/common.pyt   ensure_name_or_prefixE   s    c         C` s    y t  |   } Wn' d d l m } | d |    n X| j } | j   r | r d d l m } | d | d t |   t |  |  f   n  t |  S(   Ni   (   R-   u!   invalid package specification: %sue   version specifications not allowed with 'update'; use
    conda update  %s%s  or
    conda install %su    (   R   R   R-   R.   t
   _is_simplet   lent   str(   t   argt   jsont   updatet   specR-   R.   (    (    s/   lib/python2.7/site-packages/conda/cli/common.pyt   arg2specL   s    	-c         C` s#   g  |  D] } t  | d | ^ q S(   NR7   (   R:   (   R0   R7   R6   (    (    s/   lib/python2.7/site-packages/conda/cli/common.pyt   specs_from_args]   s    uM   (?P<name>[^=<>!\s]+)\s*((?P<cc>=[^=]+(=[^=]+)?)|(?P<pc>(?:[=!]=|[><]=?).+))?$c         C` s   |  j  d  d j   S(   Nu   #i    (   t   splitt   rstrip(   t   line(    (    s/   lib/python2.7/site-packages/conda/cli/common.pyt   strip_commentk   s    c         C` s   t  j t |    } | d  k r% d  S| j d  j   | j d  | j d  } } } | rt | | j d d  S| r | d | j d d  S| Sd  S(   Nu   nameu   ccu   pcu   =u    u    (   t   spec_patt   matchR?   t   Nonet   groupR    t   replace(   R>   t   mR.   t   cct   pc(    (    s/   lib/python2.7/site-packages/conda/cli/common.pyt   spec_from_lineo   s    5c      	   C` s/  d d l  m } t } | |  d t } g  } yΏ xΈ t |  D]ͺ } | j   } | sA | j d  ro qA n  | d k r t } n  | r | j |  qA n  t |  } | d  k rή d d l
 m } | d | |  f   n  | j |  qA WWn2 t k
 r$}	 d d l
 m }
 |
 | |	   n XWd  QX| S(	   Ni   (   t   TmpDownloadt   verboseu   #u	   @EXPLICIT(   R-   u   could not parse '%s' in: %s(   t   CondaFileIOError(   t   gateways.connection.downloadRI   t   Falset   openR   t
   startswithR   R   RH   RB   R   R-   t   IOErrorRK   (   t   urlR7   RI   t   explicitt   patht   specsR>   R9   R-   t   eRK   (    (    s/   lib/python2.7/site-packages/conda/cli/common.pyt   specs_from_url|   s0    	c         ` s   t    f d   | D  S(   Nc         3` s%   |  ] } | j    d    k Vq d S(   i    N(   R<   (   R   R9   (   t   names(    s/   lib/python2.7/site-packages/conda/cli/common.pys	   <genexpr>   s    (   t   any(   RW   RT   (    (   RW   s/   lib/python2.7/site-packages/conda/cli/common.pyt   names_in_specs   s    c         C` s   |  r d d j  |   Sd Sd  S(   Nu   [%s]u    u    (   R   (   t   features(    (    s/   lib/python2.7/site-packages/conda/cli/common.pyt   disp_features   s    c         C` s   t  d  j t |    d  S(   Nu   conda.stdout(   R   t   infoR   (   t   d(    (    s/   lib/python2.7/site-packages/conda/cli/common.pyt   stdout_json£   s    c         K` sΉ   i |  d 6} | j  d d   } | r d | k r[ g  | d D] } | j   ^ q< | d <n  d | k r g  | d D] } | j   ^ qr | d <n  | | d <n  | j |  t |  d  S(   Nu   successu   actionsu   LINKu   UNLINK(   t   popRB   t   dist_fields_dumpR8   R^   (   t   successt   kwargst   resultt   actionst   prec(    (    s/   lib/python2.7/site-packages/conda/cli/common.pyt   stdout_json_success¨   s    **c         ` s^     r t  d  t  d  n    f d   } x |  D] } | |  q3 W  rZ t  d  n  d  S(   Nu   # conda environments:u   #c         ` s   d }   t  j k r d n d }   t  j k r9 t } n4 t   f d   t  j D  rg t    } n d }  r t | | |   f  n  d  S(   Nu   %-20s  %s  %su   *u    c         3` s$   |  ] } t  | t     Vq d  S(   N(   R   R   (   R   t   envs_dir(   R/   (    s/   lib/python2.7/site-packages/conda/cli/common.pys	   <genexpr>ΐ   s    u    (   R	   t   default_prefixt   root_prefixR   RX   t	   envs_dirsR   R!   (   R/   t   fmtR$   R.   (   t   output(   R/   s/   lib/python2.7/site-packages/conda/cli/common.pyt   disp_env»   s    	u    (   R!   (   t   known_conda_prefixesRl   Rm   R/   (    (   Rl   s/   lib/python2.7/site-packages/conda/cli/common.pyt   print_envs_list΅   s    
c          C` sM   d d l  m }  t j rI |    rI d d l m } | t d    n  d  S(   Ni   (   t   is_admin(   t   OperationNotAllowedu   
            The create, install, update, and remove operations have been disabled
            on your system for non-privileged users.
        (   t
   common._osRp   R	   t   non_admin_enabledR   Rq   R   (   Rp   Rq   (    (    s/   lib/python2.7/site-packages/conda/cli/common.pyt   check_non_adminΞ   s
    (   u   yesu   no(/   t
   __future__R    R   R   R   t   loggingR   t   os.pathR   R   t   reR   t   _vendor.auxlib.ishR   t   base.constantsR   t   base.contextR	   t   common.constantsR
   t	   common.ioR   t   common.pathR   t   common.serializeR   t   models.match_specR   R(   R,   R2   RM   R:   R;   t   compilet   VERBOSER@   R?   RH   RV   RY   R[   R^   R   Rf   Ro   Rt   (    (    (    s/   lib/python2.7/site-packages/conda/cli/common.pyt   <module>   s8   "						