ó
Ò:\c           @   s¶  d  Z  d d l Z d d l Z d d l m Z d d l m Z m Z m Z d d l	 m
 Z
 d d l m Z m Z m Z d d l Z d d l m Z m Z m Z m Z m Z d d l m Z m Z m Z m Z m Z m Z m Z m Z m Z d d	 l  m! Z! e r	d
 Z" n d Z" d e! f d „  ƒ  YZ# d e# f d „  ƒ  YZ$ d e# f d „  ƒ  YZ% d e# f d „  ƒ  YZ& d e# f d „  ƒ  YZ' d e# f d „  ƒ  YZ( d „  Z) e* d k r²e) ƒ  n  d S(   s/   Environment creation, import, deletion dialogs.iÿÿÿÿN(   t   getopenfilename(   t   QRegExpt   Qtt   Signal(   t   QRegExpValidator(   t   QGridLayoutt   QHBoxLayoutt   QVBoxLayout(   t   BITS_64t   LINUXt   MACt   MAC_VERSION_INFOt   WIN(	   t   ButtonDangert   ButtonNormalt   ButtonPrimaryt   CheckBoxBaset   ComboBoxBaset	   LabelBaset   LineEditBaset   SpacerHorizontalt   SpacerVertical(   t
   DialogBases   ^[A-Za-z][A-Za-z0-9_- ]{0,30}$s   ^[A-Za-z][A-Za-z0-9_-]{0,30}$t   EnvironmentActionsDialogc           B   s›   e  Z d  Z d Z e Z e ƒ  Z d d d „ Z	 d d d d „ Z
 d „  Z d „  Z d „  Z e d „  ƒ Z e d „  ƒ Z e d	 „  ƒ Z e d
 „  ƒ Z RS(   s0   Base dialog with common methods for all dialogs.ià  c         C   s\   t  t |  ƒ j d | ƒ d |  _ d |  _ d |  _ | |  _ d |  _ d |  _	 d |  _
 d S(   s0   Base dialog with common methods for all dialogs.t   parentN(   t   superR   t   __init__t   Nonet   infot	   envs_dirst   environmentst   apit   channelst	   text_namet   label_prefix(   t   selfR   R   (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyR   0   s    						c         C   s}   | ry | j  d i  ƒ } | |  _ | j  d ƒ |  _ | d |  _ | d |  _ | j  d ƒ |  _ |  j ƒ  |  j j ƒ  n  d S(   sA   Setup the dialog conda information as a result of a conda worker.t   processed_infot   packagest   __envs_dirs_writablet   __environmentsR    N(	   t   getR   t	   _packagesR   R   R    t   refresht   sig_setup_readyt   emit(   R#   t   workert
   conda_datat   errort
   conda_info(    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyt   setup>   s    	
c         C   sm   |  j  j t ƒ |  j ri |  j j ƒ  } | j |  j t j	 d ƒ } |  j j
 | ƒ |  j j |  j ƒ n  d S(   s"   Update the location (prefix) text.i,  N(   t	   button_okt   setDisabledt   TrueR   R"   t   fontMetricst
   elidedTextt   prefixR   t	   ElideLeftt   setTextt
   setToolTip(   R#   t   fmR7   (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyt   update_locationJ   s    	c         C   s   |  t  ‚ d S(   s0   Update the status of buttons based data entered.N(   t   NotImplementedError(   R#   (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyR*   S   s    c         C   sk   |  j  r |  j  j ƒ  n g  } t j d k r[ | j ƒ  } g  | D] } | j ƒ  ^ q@ } n  | oj | | k S(   sf   
        Check that an environment has a valid name.

        On Windows is case insensitive.
        t   nt(   R   t   valuest   ost   namet   lower(   R#   t   env_namet	   env_namest   e(    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyt   is_valid_env_nameX   s
    "c         C   s,   x% |  D] } | j  t j t j Bƒ q Wd S(   s!   Align label widgets to the right.N(   t   setAlignmentR   t
   AlignRightt   AlignVCenter(   t   widgetst   widget(    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyt   align_labelse   s    c         C   s   t  |  j ƒ } t | ƒ S(   s&   Helper that creates a regex validator.(   R   t   REGEX_ENV_NAMER   (   t   clst   regex(    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyt   get_regex_validatork   s    c         C   s+   d } |  j  r' |  j  j ƒ  j ƒ  } n  | S(   s@   Return the content without extra spaces for the name of the env.t    (   R!   t   textt   strip(   R#   RR   (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyRA   q   s    	c         C   sG   d } |  j  r: |  j r: t j j |  j  d |  j ƒ } n	 |  j } | S(   s;   Return the full prefix (location) as entered in the dialog.RQ   i    (   R   RA   R@   t   patht   join(   R#   R7   (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyR7   y   s
    "	N(   t   __name__t
   __module__t   __doc__t   BASE_DIALOG_WIDTHt   REGEX_ENVIRONMENT_NAMESRM   R   R+   R   R   R1   R<   R*   RF   t   staticmethodRL   t   classmethodRP   t   propertyRA   R7   (    (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyR   )   s   					t   CreateDialogc           B   s›   e  Z d  Z d Z d Z d d d d g Z d Z d d d	 „ Z d
 „  Z	 d „  Z
 d d „ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z RS(   s   Create new environment dialog.t   mrot   ru   2.7u   3.5u   3.6u   3.7i
   i   c         C   s   t  t |  ƒ j d | d | ƒ t d ƒ |  _ t d ƒ |  _ t d ƒ |  _ t ƒ  |  _ t d ƒ |  _	 t d ƒ |  _
 t ƒ  |  _ t d ƒ |  _ t d	 ƒ |  _ t ƒ  |  _ t d
 ƒ |  _ t d ƒ |  _ |  j |  j |  j |  j
 g ƒ |  j j d ƒ |  j |  j ƒ |  j d ƒ |  j j |  j ƒ  ƒ |  j j d ƒ |  j j d ƒ |  j j d ƒ |  j j t ƒ |  j g } |  j j  ƒ  |  j j! | ƒ |  j j" d ƒ |  j j# t$ | ƒ d k ƒ t% ƒ  } | j& |  j d d ƒ | j& t' ƒ  d d ƒ | j& |  j d d ƒ | j& t( ƒ  d d ƒ | j& |  j d d ƒ | j& t' ƒ  d d ƒ | j& |  j d d ƒ t% ƒ  } | j& |  j d d d d ƒ | j& t' ƒ  d d d d ƒ | j& |  j d d d d ƒ | j& t( ƒ  d d d d ƒ | j& |  j d d d d ƒ | j& t' ƒ  d d d d ƒ | j& |  j d d d d ƒ | j& t( ƒ  d d d d ƒ | j& |  j
 d d d d ƒ | j& t' ƒ  d d d d ƒ | j) | d d d d ƒ t* ƒ  } | j+ ƒ  | j& |  j ƒ | j& t' ƒ  ƒ | j& |  j ƒ t, ƒ  } | j) | ƒ | j& t( ƒ  ƒ | j& t( ƒ  ƒ | j) | ƒ |  j- | ƒ |  j j. j/ |  j0 ƒ |  j j. j/ |  j1 ƒ |  j j2 j/ |  j3 ƒ |  j j4 j/ |  j3 ƒ |  j j4 j/ |  j3 ƒ |  j5 j/ |  j6 ƒ |  j5 j/ |  j7 ƒ |  j j8 ƒ  |  j j9 t ƒ |  j j9 t: ƒ |  j3 ƒ  d S(   s   Create new environment dialog.R   R   s   Name:s	   Location:RQ   s   Python versions	   Packages:t   Pythont   Rt   Createt   Cancels   New environment names   Create new environments   environment-locations   package-versions   r-typei    i   i   i   i   N(;   R   R^   R   R   t
   label_namet   label_locationR"   R   R!   t   label_versiont   label_packagesR   t   combo_versionR   t   check_pythont   check_rt   combo_r_typeR   R2   R   t   button_cancelRL   t   setPlaceholderTextt   setMinimumWidthRY   t   setWindowTitlet   setValidatorRP   t   setObjectNameR3   R4   Rb   t   cleart   addItemst   setCurrentIndext
   setEnabledt   lenR   t	   addWidgetR   R   t	   addLayoutR   t
   addStretchR   t	   setLayoutt   clickedt   connectt   acceptt   rejectt   textChangedR*   t   stateChangedR+   t
   update_mrot   update_pyversionst   setFocust
   setCheckedt   False(   R#   R   R   t   r_typest   layout_packagest   gridt   layout_buttonst   main_layout(    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyR   Œ   sŒ    			
	c   	      C   s.  |  j  j d i  ƒ } | j d g  ƒ } t g  | D]" } d j | j d ƒ d  ƒ ^ q1 ƒ } g  } x- |  j D]" } | | k rl | j | ƒ ql ql W|  j } d j t j	 j
 t j	 j ƒ } | | k rß | j | ƒ | j ƒ  n  t t | ƒ ƒ } |  j j | ƒ |  j j | j | ƒ ƒ |  j j t ƒ d S(   RQ   t   pythont   versionst   .i   s   {}.{}N(   R)   R(   t   setRU   t   splitt   PYTHON_VERSIONSt   appendt   formatt   syst   version_infot   majort   minort   sortt   listt   reversedRi   Rt   Ru   t   indexRv   R4   (	   R#   t
   python_pkst   python_versionst   vt   pyverst   final_pyverst   pyverR   t   now(    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyRƒ   ç   s     5	c         C   sÈ   |  j  g } |  j r{ |  j j j d d |  j ƒ} | r{ t r{ t rT t |  j k s` t	 s` t
 rx |  j  |  j g } qx q{ n  |  j j ƒ  |  j j | ƒ |  j j d ƒ |  j j t | ƒ d k ƒ d S(   RQ   s   mro-baseR    i    i   N(   Rb   R   t
   _conda_apit   is_package_availableR    R   R
   R   t   MRO_MAC_MIN_VERSIONR   R	   t   MRORl   Rs   Rt   Ru   Rv   Rw   (   R#   R‡   t   is_mro_available(    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyR‚   þ   s    	RQ   c         C   s“   |  j  } |  j ƒ  |  j ri |  j p+ |  j } | rV |  j | ƒ rV |  j j t ƒ qi |  j j t	 ƒ n  |  j
 j |  j ƒ |  j j |  j ƒ d S(   s'   Update status of buttons based on data.N(   RA   R<   R   t   install_pythont	   install_rRF   R2   R3   R†   R4   Ri   Rv   Rl   (   R#   RR   RA   t   check(    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyR*     s    	
	c         C   s%   d } |  j r! |  j j ƒ  } n  | S(   s=   Return the python version if python was selected for install.N(   R   R¨   Ri   t   currentText(   R#   t   version(    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyt   python_version   s    	c         C   s   t  |  j j ƒ  ƒ S(   s*   Return if python was selected for install.(   t   boolRj   t
   checkState(   R#   (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyR¨   (  s    c         C   s   t  |  j j ƒ  ƒ S(   s%   Return if r was selected for install.(   R®   Rk   R¯   (   R#   (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyR©   -  s    c         C   s   t  |  j j ƒ  ƒ S(   s%   Return if r was selected for install.(   R®   Rl   R«   (   R#   (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyt   r_type2  s    (   i
   i   N(   RV   RW   RX   R¦   Rb   R‘   R¥   R   R   Rƒ   R‚   R*   R]   R­   R¨   R©   R°   (    (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyR^   „   s   [		t   ImportDialogc           B   sP   e  Z d  Z d Z d Z d Z d	 d „ Z d „  Z d d „ Z	 e
 d „  ƒ Z RS(
   s9   Import environment from environment specification dialog.s&   Conda environment files (*.yaml *.yml)s*   Conda explicit specification files (*.txt)s   Pip requirement files (*.txt)c         C   s¤  t  t |  ƒ j d | ƒ d |  _ d |  _ d |  _ t d ƒ |  _ t d ƒ |  _	 t d ƒ |  _
 t ƒ  |  _ t d ƒ |  _ t ƒ  |  _ t d ƒ |  _ t d ƒ |  _ t d ƒ |  _ |  j |  j |  j	 |  j
 g ƒ |  j j d ƒ |  j j d	 ƒ |  j j t ƒ |  j j d
 ƒ |  j j d ƒ |  j |  j ƒ |  j d ƒ |  j j |  j ƒ  ƒ t ƒ  } | j |  j ƒ | j t  ƒ  ƒ | j |  j ƒ t! ƒ  } | j |  j d d ƒ | j t  ƒ  d d ƒ | j |  j d d ƒ | j t" ƒ  d d ƒ | j |  j	 d d ƒ | j t  ƒ  d d ƒ | j |  j d d ƒ | j t" ƒ  d d ƒ | j |  j
 d d ƒ | j t  ƒ  d d ƒ | j# | d d ƒ t ƒ  } | j$ ƒ  | j |  j ƒ | j t  ƒ  ƒ | j |  j ƒ t% ƒ  } | j# | ƒ | j t" ƒ  ƒ | j t" ƒ  ƒ | j# | ƒ |  j& | ƒ |  j j' j( |  j) ƒ |  j j' j( |  j* ƒ |  j j' j( |  j+ ƒ |  j j, j( |  j- ƒ |  j j, j( |  j- ƒ |  j j. ƒ  |  j- ƒ  d S(   s9   Import environment from environment specification dialog.R   s   Name:s	   Location:s   Specification FileRQ   Rd   t   Imports   environment-locationt   imports   File to import froms   New environment names   Import new environmenti    i   i   i   i   N(/   R   R±   R   R   R   t   env_dirst   selected_file_filterR   Re   Rf   t
   label_pathR   R!   R"   t	   text_pathR   t   button_pathRm   R   R2   RL   Rr   t
   setDefaultR4   Rn   Ro   RY   Rp   Rq   RP   R   Rx   R   R   R   Ry   Rz   R   R{   R|   R}   R~   R   t   chooseR€   R*   R„   (   R#   R   t   layout_infilet   layout_gridRŠ   t   layout(    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyR   ?  sr    						
	c         C   s  t  d d d t j j d ƒ d d	 d d j |  j |  j |  j ƒ ƒ \ } } | r|  j	 } | |  _
 |  j j | ƒ |  j | ƒ | |  j k rï yI t | d ƒ  } | j ƒ  } Wd	 QXt j | ƒ } | j d
 | ƒ } Wqï t k
 rë qï Xn  |  j j | ƒ n  d	 S(   s8   Display file dialog to select environment specification.t   captions   Import Environmentt   basedirt   ~R   t   filterss   {0};;{1};;{2}R`   NRA   (   R    R@   RT   t
   expanduserR   R“   t   CONDA_ENV_FILESt   CONDA_SPEC_FILESt   PIP_REQUIREMENT_FILESRA   Rµ   R·   R9   R*   t   opent   readt   yamlt   loadR(   t	   ExceptionR!   (   R#   RT   t   selected_filterRA   t   ft   rawt   data(    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyRº   ‹  s*    		RQ   c         C   s“   |  j  } |  j } |  j ƒ  | ro | ro t j j |  j ƒ ro |  j | ƒ ro |  j j t ƒ |  j j	 t
 ƒ n  |  j j t
 ƒ |  j j	 t
 ƒ d S(   s0   Update the status of buttons based data entered.N(   RA   RT   R<   R@   t   existsRF   R2   R3   R†   R¹   R4   Rm   (   R#   RR   RA   RT   (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyR*   ¨  s    		
!c         C   s7   d } t j j |  j j ƒ  ƒ r3 |  j j ƒ  } n  | S(   s5   Return the content of the selected path if it exists.N(   R   R@   RT   t   isfileR·   RR   (   R#   RT   (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyRT   ·  s    N(   RV   RW   RX   RÃ   RÄ   RÅ   R   R   Rº   R*   R]   RT   (    (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyR±   8  s   L	t   CloneDialogc           B   s)   e  Z d  Z d d d „ Z d d „ Z RS(   s   Clone environment dialog.c         C   sZ  t  t |  ƒ j d | ƒ t d ƒ |  _ t ƒ  |  _ t d ƒ |  _ t ƒ  |  _ t	 d ƒ |  _
 t d ƒ |  _ |  j |  j |  j g ƒ |  j |  j ƒ |  j d | ƒ |  j j d ƒ |  j j |  j ƒ  ƒ |  j j d ƒ t ƒ  } | j |  j d	 d
 ƒ | j t ƒ  d	 d ƒ | j |  j d	 d	 ƒ | j t ƒ  d d
 ƒ | j |  j d d
 ƒ | j |  j d d	 ƒ t ƒ  } | j ƒ  | j |  j ƒ | j t ƒ  ƒ | j |  j
 ƒ t ƒ  } | j | ƒ | j t ƒ  ƒ | j t ƒ  ƒ | j | ƒ |  j | ƒ |  j j j |  j  ƒ |  j
 j! j |  j" ƒ |  j j! j |  j# ƒ |  j j$ ƒ  |  j  ƒ  d S(   s   Clone environment dialog.R   s   Name:s	   Location:t   CloneRd   s   Clone from environment: s   New environment names   environment-locationi   i    i   i   i   N(%   R   RÑ   R   R   Re   R   R!   Rf   R"   R   R2   R   Rm   RL   Ro   RY   Rp   Rn   Rq   RP   Rr   R   Rx   R   R   R   Rz   R   Ry   R{   R€   R}   R*   R|   R~   R   R„   (   R#   R   t   clone_from_nameR‰   RŠ   R½   (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyR   Ã  sH    		
	RQ   c         C   s=   |  j  } |  j ƒ  |  j r9 |  j j |  j | ƒ ƒ n  d S(   s5   Update status of buttons based on combobox selection.N(   RA   R<   R   R2   R3   RF   (   R#   RR   RA   (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyR*   ø  s    	
	N(   RV   RW   RX   R   R   R*   (    (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyRÑ   À  s   5t   RemoveDialogc           B   s    e  Z d  Z d d d d „ Z RS(   s#   Remove existing environment dialog.c         C   se  t  t |  ƒ j d | ƒ t d ƒ |  _ t d ƒ |  _ t | ƒ |  _ t d ƒ |  _ t | ƒ |  _ t	 d ƒ |  _
 t d ƒ |  _ |  j |  j |  j g ƒ |  j j d ƒ |  j d ƒ |  j d	 ƒ |  j j d
 ƒ |  j j d
 ƒ t ƒ  } | j |  j ƒ | j t ƒ  ƒ | j |  j ƒ | j ƒ  t ƒ  } | j |  j ƒ | j t ƒ  ƒ | j |  j ƒ | j ƒ  t ƒ  } | j ƒ  | j |  j
 ƒ | j t ƒ  ƒ | j |  j ƒ t ƒ  } | j | ƒ | j t ƒ  ƒ | j | ƒ | j t ƒ  ƒ | j t ƒ  ƒ | j | ƒ |  j | ƒ |  j j j |  j ƒ |  j
 j j |  j ƒ |  j ƒ  |  j j t ƒ d S(   s*   Remove existing environment `name` dialog.R   s&   Do you want to remove the environment?s   Name:s	   Location:Rd   t   Removes   environment-locations   Remove environmenti|  i<   N(    R   RÔ   R   R   t
   label_textRe   t   label_name_valueRf   R"   R   Rm   R   R2   RL   Rr   Rp   Ro   R   Rx   R   Rz   R   Ry   R   R{   R|   R}   R~   R   R<   R3   R†   (   R#   R   RA   R7   t   layout_namet   layout_locationRŠ   R½   (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyR     sR    	
	
	
	
N(   RV   RW   RX   R   R   (    (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyRÔ      s   t   ConflictDialogc           B   sM   e  Z d  Z d d d d d „ Z d „  Z d „  Z d „  Z e d „  ƒ Z	 RS(   s?   Create new environment dialog if navigator conflicts with deps.RQ   c   
      C   se  t  t |  ƒ j d | ƒ | j d ƒ } d | k r> | d n | |  _ d | k r] | d n d |  _ | |  _ d j | ƒ } | p‡ | } t | d j | ƒ ƒ |  _	 t d ƒ |  _
 t d	 d
 ƒ |  _ t d ƒ |  _ t ƒ  |  _ t d ƒ |  _ t d ƒ |  _ |  j |  j
 |  j g ƒ |  j j t ƒ |  j j d ƒ |  j j |  j ƒ  ƒ |  j |  j ƒ |  j d j | ƒ ƒ |  j j d ƒ |  j j d ƒ t ƒ  } | j |  j
 d d ƒ | j t  ƒ  d d ƒ | j |  j d d ƒ | j t! ƒ  d d ƒ | j |  j d d ƒ | j t  ƒ  d d ƒ | j |  j d d ƒ t" ƒ  } | j# ƒ  | j |  j ƒ | j t  ƒ  ƒ | j |  j ƒ t$ ƒ  }	 |	 j |  j	 ƒ |	 j t! ƒ  ƒ |	 j t! ƒ  ƒ |	 j% | ƒ |	 j t! ƒ  ƒ |	 j t! ƒ  ƒ |	 j% | ƒ |  j& |	 ƒ |  j j' j( |  j) ƒ |  j j' j( |  j* ƒ |  j j+ |  j ƒ |  j j, j( |  j- ƒ |  j j. t ƒ d S(   s?   Create new environment dialog if navigator conflicts with deps.R   t   =i    iÿÿÿÿRQ   s3   <b>{0}</b> cannot be installed on this environment.sf   <br><br>Do you want to install the package in an existing environment or <br>create a new environment?s   Name:t    id   s	   Location:Rc   Rd   s   Create new environment for '{}'s   environment-locations   environment-selectioni   i   N(/   R   RÚ   R   R   t   packaget   package_versiont   current_prefixR“   R   t
   label_infoRe   R"   Rf   R   t
   combo_nameR   R2   R   Rm   RL   t   setEditableR4   t   setCompleterR   Rq   RP   Ro   RY   Rp   Rr   R   Rx   R   R   R   Rz   R   Ry   R{   R|   R}   R~   R   t   setCurrentTextt   currentTextChangedR*   R3   (
   R#   R   RÝ   t   extra_messageRß   t   partst   base_messaget   grid_layoutRŠ   R‹   (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyR   A  sh    					
	c         C   s¼   |  j  d |  j } |  j r¯ |  j  |  j j ƒ  k rA |  j  } q¸ | |  j j ƒ  k r_ | } q¸ xV t d d ƒ D]9 } | d t | ƒ } | |  j j ƒ  k ro | } Pqo qo Wn	 |  j  } | S(   s#   Generate a unique environment name.t   -i   iè  t   _(   RÝ   RÞ   R   R?   t   ranget   str(   R#   t   pkg_name_versionRC   t   it   new_pkg_name(    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyt   new_env_nameŒ  s    			c         C   sí   t  t |  ƒ j | | | ƒ |  j j t ƒ |  j j ƒ  |  j ƒ  } xw t |  j	 j
 ƒ  ƒ D]` \ } \ } } |  j | k r[ |  j j | | ƒ |  j j | ƒ |  j j | | t j ƒ q[ q[ W|  j j | ƒ |  j j t ƒ |  j ƒ  d S(   s;   Setup the dialog conda information as a result of a worker.N(   R   RÚ   R1   Rá   t   blockSignalsR4   Rs   Rñ   t	   enumerateR   t   itemsRß   t   addItemRä   t   setItemDataR   t   ToolTipRoleR†   R*   (   R#   R-   R   R/   Rñ   Rï   t
   env_prefixRC   (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyR1   ž  s    ( c         C   s3   |  j  ƒ  |  j r/ |  j j t |  j ƒ ƒ n  d S(   s*   Refresh state of buttons based on content.N(   R<   R   R2   Rv   R®   RA   (   R#   (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyR*   ®  s    
	c         C   s   |  j  j ƒ  S(   s#   Return the name of the environment.(   Rá   R«   (   R#   (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyRA   µ  s    N(
   RV   RW   RX   R   R   Rñ   R1   R*   R]   RA   (    (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyRÚ   >  s   J			c          C   s@   d d l  m }  |  ƒ  } t d d ƒ } | j ƒ  | j ƒ  d S(   s   Run local tests.iÿÿÿÿ(   t   qapplicationR   N(   t"   anaconda_navigator.utils.qthelpersRù   R^   R   t   showt   exec_(   Rù   t   appt   widget_create(    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyt
   local_test½  s
    	
t   __main__(+   RX   R@   R”   t   qtpy.compatR    t   qtpy.QtCoreR   R   R   t
   qtpy.QtGuiR   t   qtpy.QtWidgetsR   R   R   RÈ   t   anaconda_navigator.configR   R	   R
   R   R   t   anaconda_navigator.widgetsR   R   R   R   R   R   R   R   R   t"   anaconda_navigator.widgets.dialogsR   RZ   R   R^   R±   RÑ   RÔ   RÚ   Rÿ   RV   (    (    (    sM   lib/python2.7/site-packages/anaconda_navigator/widgets/dialogs/environment.pyt   <module>   s,   (@	[´ˆ@>	(