
p^c           @` s  d  Z  d d l m Z m Z 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 l Z d d l m Z d d l Z d d	 l m Z m Z m Z m Z m Z m Z m Z m Z d d
 l m Z d d l Z d d l Z d d l Z y e Wn e  k
 re! Z n Xd d l" m# Z# m$ Z$ m% Z& d d l' m( Z( d d l) m* Z* d d l+ m, Z, m- Z- m. Z. m/ Z/ m0 Z0 d d l1 m2 Z2 d d l3 m4 Z4 m5 Z5 m6 Z6 m7 Z7 m8 Z8 m9 Z9 m: Z: d d l; m< Z< m= Z= m> Z> m? Z? m@ Z@ d d lA mB ZB d d lC mD ZD mE ZE d d lF mG ZG d d lH mI ZI d d lJ mK ZK d d lL mM ZM d d lN mO ZO e9 re4 rd d lP ZQ n d d lQ ZQ d d lR mS ZS mT ZT d d lU mV ZV n  e eW  ZX d ZY d ZZ d dT d     YZ[ d    Z\ e] d!  Z^ d d d"  Z` d#   Za e] d$  Zb d%   Zc d&   Zd d'   Ze d(   Zf d d)  Zg d*   Zh d+   Zi d,   Zj d-   Zk d.   Zl d/   Zm d0   Zn d1   Zo d2   Zp d3   Zq d4   Zr d5   Zs d6   Zt d7   Zu d8   Zv d9   Zw d:   Zx d;   Zy d<   Zz d=   Z{ d>   Z| d?   Z} d@   Z~ dA   Z dB   Z dC   Z e] dD  Z e] dE  Z dF   Z dG   Z e] dH  Z dI   Z dJ   Z dK   Z dL   Z dM   Z dN   Z dO   Z dP   Z dQ   Z eW dR k re9 re j dS Z ef e  qee   n  d S(U   u  
Sections in this module are

  1. top-level functions
  2. plan creators
  3. plan runners
  4. individual operations
  5. helper functions

The top-level functions compose and execute full plans.

A plan is created by composing various individual operations.  The plan data structure is a
list of dicts, where each dict represents an individual operation.  The dict contains two
keys--`function` and `kwargs`--where function is the name of the individual operation function
within this module.

Each individual operation must

  a) return a `Result` (i.e. NEEDS_SUDO, MODIFIED, or NO_CHANGE)
  b) have no side effects if context.dry_run is True
  c) be verbose and descriptive about the changes being made or proposed is context.verbosity >= 1

The plan runner functions take the plan (list of dicts) as an argument, and then coordinate the
execution of each individual operation.  The docstring for `run_plan_elevated()` has details on
how that strategy is implemented.

i    (   t   absolute_importt   divisiont   print_functiont   unicode_literals(   t   unified_diff(   t   ENOENT(   t   glob(   t   chainN(   t	   getLogger(   t   abspatht   basenamet   dirnamet   existst
   expandusert   isdirt   isfilet   join(   t   randinti   (   t   CONDA_PACKAGE_ROOTt
   CondaErrort   __version__(   t   Utf8NamedTemporaryFile(   t   dals(   t   CshActivatort   FishActivatort   PosixActivatort   XonshActivatort   PowerShellActivator(   t   context(   t   PY2t   ensure_binaryt   ensure_utf8_encodingt   ensure_text_typet   on_mact   on_wint   open(   t   expandt   get_bin_directory_short_patht   get_python_short_patht#   get_python_site_packages_short_patht   win_path_ok(   t   CondaValueError(   t   copyt   mkdir_p(   t   rm_rf(   t   lexists(   t   make_executable(   t   compute_md5sum(   t   subprocess_call(   t   get_folder_patht   FOLDERID(   t   create_shortcutuV   ^# >>> conda initialize >>>(?:\n|\r\n)([\s\S]*?)# <<< conda initialize <<<(?:\n|\r\n)?uD   ^#region conda initialize(?:\n|\r\n)([\s\S]*?)#endregion(?:\n|\r\n)?t   Resultc           B` s   e  Z d  Z d Z d Z RS(   u
   needs sudou   modifiedu	   no change(   t   __name__t
   __module__t
   NEEDS_SUDOt   MODIFIEDt	   NO_CHANGE(    (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR4   Z   s   c         C` sM   t  |   } t |  t j s? t d   | D  s? t  n  t |  d S(   Nc         s` s"   |  ] } | d  t  j k Vq d S(   u   resultN(   R4   R7   (   t   .0t   step(    (    s4   lib/python2.7/site-packages/conda/core/initialize.pys	   <genexpr>h   s    i    (   t   make_install_plant   run_planR   t   dry_runt   anyt   AssertionErrort   print_plan_results(   t   conda_prefixt   plan(    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyt   installd   s    
	 
c   	      C` s   g  } t  j d  d k rJ t |   } t |  t j sJ t |  qJ n  t |  | | | | d | } t |  t j s t |  n  | | } t |  t	 d   | D  r t
 d d t j d Sd  S(   Nu   CONDA_PIP_UNINITIALIZEDu   truet   reversec         s` s"   |  ] } | d  t  j k Vq d S(   u   resultN(   R4   R7   (   R:   R;   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pys	   <genexpr>~   s    u   Operation failed.t   filei   (   t   ost   getenvR<   R=   R   R>   t   run_plan_elevatedt   make_initialize_planRA   R?   t   printt   syst   stderr(	   RB   t   shellst   for_usert
   for_systemt   anaconda_promptRE   t   plan1t   plan2RC   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyt
   initializem   s     
	
	

c      
   C` s  t  | p t j  } t  | p' t j    } t |  \ } } } t t | d d   sm t d |   n  t	 |  } | j
 i t j d 6i | d 6d 6 | j
 i t j d 6i t | d  d 6| d 6d 6 | j
 i t j d 6i t | d	  d 6| d 6d 6 | j
 i t j d 6i t | d
  d 6d 6 t |  t j sRt j ret | t j  n  t d   | D  rt d   n  i d d 6t t d d   d 6| d d 6t rd n d d 6} d6 } |  d  k rg  }	 |	 g  | D] }
 d! |
 ^ q7}	 |	 g  t |  D] } d" | | | f ^ q7}	 t t j  } t rWd# | } n  |	 d$ | d% | g 7}	 t d& j |	   n=|  d' k rt j rd( } n d) } g  }	 |	 d* g 7}	 |	 g  | D] }
 d+ |
 ^ q7}	 |	 g  t |  D] } d, | | | f ^ q7}	 |	 d- t | d. d/  | f d0 d1 t | d. d2  | | f d0 g 7}	 t j st  d3 d4   } | j! d& j |	   Wd  QXn  t j rt d& j |	   n  t d5  n	 t"    d S(7   Nu   condau   __main__.pyu(   Directory is not a conda source root: %su   functionu   target_pathu   kwargsu   conda.egg-linku   conda_source_rootu   easy-install.pthu   conda.egg-infoc         s` s"   |  ] } | d  t  j k Vq d S(   u   resultN(   R4   R7   (   R:   R;   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pys	   <genexpr>   s    uG   Operation failed. Privileged install disallowed for 'conda init --dev'.u6   --cov-report xml --cov-report term-missing --cov condau   ADD_COVi    I       u   PYTHONHASHSEEDu   PYTHON_MAJOR_VERSIONu   winu   unixu   TEST_PLATFORMu   CONDA_DEFAULT_ENVu	   CONDA_EXEu   _CE_Mu	   _CE_CONDAu   CONDA_PREFIXu   CONDA_PREFIX_1u   CONDA_PREFIX_2u   CONDA_PYTHON_EXEu   CONDA_PROMPT_MODIFIERu   CONDA_SHLVLu   bashu   unset %su   export %s='%s'u   $(cygpath '%s')u+   eval "$("%s" -m conda "shell.bash" "hook")"u   conda activate '%s'u   
u   cmd.exeu   --devu    uo   @IF NOT "%CONDA_PROMPT_MODIFIER%" == "" @CALL SET "PROMPT=%%PROMPT:%CONDA_PROMPT_MODIFIER%=%_empty_not_set_%%%"u   @SET %s=u   @SET "%s=%s"u   @CALL "%s" %su   condabinu   conda_hook.batu,   @IF %errorlevel% NEQ 0 @EXIT /B %errorlevel%u   @CALL "%s" activate %s "%s"u	   conda.batu   dev-init.batu   wu   now run  > .\dev-init.bat(
   u   CONDA_DEFAULT_ENVu	   CONDA_EXEu   _CE_Mu	   _CE_CONDAu   CONDA_PREFIXu   CONDA_PREFIX_1u   CONDA_PREFIX_2u   CONDA_PYTHON_EXEu   CONDA_PROMPT_MODIFIERu   CONDA_SHLVL(#   R$   RL   t   prefixRG   t   getcwdt   _get_python_infoR   R   R)   R<   t   appendt   remove_conda_in_sp_dirR5   t   make_conda_egg_linkt   modify_easy_install_ptht   make_dev_egg_info_fileR=   R   R>   t	   verbosityRA   RM   R?   R   t   strR   R"   t   sortedR	   t
   executableRK   t   devR#   t   writet   NotImplementedError(   t   shellt   dev_env_prefixt   conda_source_roott
   python_exet   python_versiont   site_packages_dirRC   t   env_varst   unset_env_varst   buildert   unset_env_vart   keyt   sys_executablet   dev_argt   fh(    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyt   initialize_dev   s    	
	
	
	

         !1		!1

			c      	   C` s  y t  |   \ } } } Wn  t k
 r; d+ \ } } } n Xg  } t r t |  d d  } t |  d d  } | j i t j d 6i t |  d d  d 6|  d 6d 6 | j i t j d 6i t |  d d	  d 6|  d 6d 6 nj | j i t j d 6i t |  d
 d  d 6|  d 6d d 6d d 6d 6 t |  d d  } t |  d d  } | j i t j d 6i | d 6|  d 6d d 6d d 6d 6 | j i t j d 6i | d 6|  d 6d d 6d d 6d 6 t r| j i t	 j d 6i t |  d
 d  d 6|  d 6d 6 | j i t
 j d 6i t |  d d d  d 6|  d 6d 6 | j i t j d 6i t |  d
 d  d 6|  d 6d 6 | j i t j d 6i t |  d
 d  d 6|  d 6d 6 | j i t j d 6i t |  d
 d  d 6|  d 6d 6 | j i t j d 6i t |  d
 d  d 6|  d 6d 6 | j i t j d 6i t |  d d  d 6|  d 6d 6 | j i t j d 6i t |  d
 d  d 6|  d 6d 6 | j i t j d 6i t |  d
 d  d 6|  d 6d 6 n  | j i t j d 6i t |  t   d  d 6|  d 6d 6 | j i t j d 6i t |  t   d  d 6|  d 6d 6 | j i t j d 6i t |  d d d  d 6|  d 6d 6 | j i t j d 6i t |  d d  d! d"  d 6|  d 6d 6 | j i t j d 6i t |  d# d
 d$  d 6|  d 6d 6 | j i t j d 6i t |  d# d
 d%  d 6|  d 6d 6 | rg| j i t j d 6i t | d& d'  d 6|  d 6d 6 n t d( |  d) t j | j i t j d 6i t |  d d d*  d 6|  d 6d 6 | S(,   Nu   Scriptsu   conda-script.pyu   conda-env-script.pyu   functionu	   conda.exeu   target_pathu   conda_prefixu   kwargsu   conda-env.exeu   condabinu   condau	   conda.cliu   moduleu   mainu   funcu   binu	   conda-envu   conda_env.cli.mainu	   conda.batu   Libraryu   _conda_activate.batu   rename_tmp.batu   conda_auto_activate.batu   conda_hook.batu   activate.batu   deactivate.batu   activateu
   deactivateu   etcu	   profile.du   conda.shu   fishu   conf.du
   conda.fishu   shellu
   Conda.psm1u   conda-hook.ps1u   xontribu	   conda.xshuP   WARNING: Cannot install xonsh wrapper without a python interpreter in prefix: %sRF   u	   conda.csh(   NNN(   RW   t   EnvironmentErrort   NoneR"   R   RX   t   make_entry_point_exeR5   t   make_entry_pointt   install_condabin_conda_batt   install_library_bin_conda_batt#   install_condabin_conda_activate_batt   install_condabin_rename_tmp_batt(   install_condabin_conda_auto_activate_batt   install_condabin_hook_batt   install_Scripts_activate_batt   install_activate_batt   install_deactivate_batt   install_activateR%   t   install_deactivatet   install_conda_sht   install_conda_fisht   install_conda_psm1t   install_conda_hook_ps1t   install_conda_xshRK   RL   RM   t   install_conda_csh(   RB   Rg   Rh   Ri   RC   t   conda_exe_patht   conda_env_exe_path(    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR<      s   	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
c         ` s@  t  |   } t |  } | d d h @rAd | k r | r t t d t sO t rU d n d   } | j i t j d 6i | d 6|  d 6d d	 6| d
 6d 6 n  d | k r| rt t d d   } | j i t j d 6i | d 6|  d 6d d	 6| d
 6d 6 n  | rA| j i t	 j d 6i d d 6|  d 6| d
 6d 6 qAn  d | k r| rt t d d d d   }	 | j i t
 j d 6i |	 d 6|  d 6| d
 6d 6 n  | rt t d d d d   }	 | j i t
 j d 6i |	 d 6|  d 6| d
 6d 6 qn  d | k r| r[t t d d   }
 | j i t j d 6i |
 d 6|  d 6| d
 6d 6 n  | rt rt t d d d   }
 n d }
 | j i t j d 6i |
 d 6|  d 6| d
 6d 6 qn  d | k r%| r%t t d d   } | j i t j d 6i | d 6|  d 6d d	 6| d
 6d 6 n  d | k r| r@d   n  | rOd   n    f d   } t | d d d   } xS | D]H } | d  k	 r}| j i t j d 6i | d 6|  d 6| d
 6d 6 q}q}Wn  d | k r<| r| j i t j d 6i d d 6|  d 6| d
 6d 6 n  | ru| j i t j d 6i d  d 6|  d 6| d
 6d 6 | j i t j d 6i d! d 6d 6 n  | r<| j i t j d 6i t |  d" d#  d 6|  d 6| d
 6d 6 t rt t j  \ } } | st  n t t d  d$  } | j i t j d 6i t | d#  d 6|  d 6| d
 6d 6 q<n  | S(%   Nu   bashu   zshu   ~u   .bash_profileu   .bashrcu   functionu   target_pathu   conda_prefixu   shellu   reverseu   kwargsu   .zshrcu   /etc/profile.d/conda.shu   fishu   .configu   config.fishu   xonshu   .xonshrcu   %ALLUSERSPROFILE%u   xonshrcu   /etc/xonshrcu   tcshu   .tcshrcu
   powershellu   $PROFILE.CurrentUserAllHostsu   $PROFILE.AllUsersAllHostsc          7` sM   xF |  D]> } y$ t  | d d   f  j j   VWq t k
 rD q Xq Wd  S(   Nu
   -NoProfileu   -Command(   R0   t   stdoutt   stript	   Exception(   t	   exe_namest   exe_name(   t   profile(    s4   lib/python2.7/site-packages/conda/core/initialize.pyt   find_powershell_paths#  s    !u   pwshu   pwsh-previewu   cmd.exeu>   HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRunu?   HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRunuO   HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabledu   condabinu   Anaconda Prompt.lnku   Desktop(   R<   t   setR$   R   R!   R"   RX   t   init_sh_userR5   t   init_sh_systemt   init_fish_usert   init_xonsh_userRt   t   init_powershell_usert   init_cmd_exe_registryt   init_long_patht   install_anaconda_promptR1   R2   t   DesktopR@   R   (   RB   RN   RO   RP   RQ   RE   RC   t   bashrc_patht
   zshrc_patht   config_fish_patht   config_xonsh_patht   tcshrc_pathR   t   config_powershell_pathst   config_patht   desktop_dirt	   exception(    (   R   s4   lib/python2.7/site-packages/conda/core/initialize.pyRJ     s    '	
	
	
	
	
	
	
	
				
	
	
	
	
	
c         C` s   x |  D] } | j  d d   } | t j t j f k r= q n  y6 t   | d | j  d d  | j  d i     } Wn9 t k
 r } t j d | d | d t	 t j
 } n X| | d <q Wd  S(   Nu   resultu   functionu   argsu   kwargsu   %s: %rt   exc_info(    (   t   getRt   R4   R8   R9   t   globalsRs   t   logt   infot   TrueR7   (   RC   R;   t   previous_resultt   resultt   e(    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR=   w  s    6c         C` s  t  d   |  D  rt r6d d l m } d } z t d d d d t 5 } | j t j	 |  d t d	 d
    | j
 } Wd QXd t t j  } | | d d d | f  \ } } | d k	 r t d | d t j n  t |  " } t j t | j     } Wd QXWd | r2t |  r2t |  n  Xn t j	 |  d t d	 d   }	 t d t j d i  d t j   d |	 }
 |
 j j   } | rt | d t j n  t j |
 j j    } |  2|  j |  n  d S(   u  
    The strategy of this function differs between unix and Windows.  Both strategies use a
    subprocess call, where the subprocess is run with elevated privileges.  The executable
    invoked with the subprocess is `python -m conda.core.initialize`, so see the
    `if __name__ == "__main__"` at the bottom of this module.

    For unix platforms, we convert the plan list to json, and then call this module with
    `sudo python -m conda.core.initialize` while piping the plan json to stdin.  We collect json
    from stdout for the results of the plan execution with elevated privileges.

    For Windows, we create a temporary file that holds the json content of the plan.  The
    subprocess reads the content of the file, modifies the content of the file with updated
    execution status, and then closes the file.  This process then reads the content of that file
    for the individual operation execution results, and then deletes the file.

    c         s` s"   |  ] } | d  t  j k Vq d S(   u   resultN(   R4   R7   (   R:   R;   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pys	   <genexpr>  s    i   (   t   run_as_adminu   w+t   suffixu   .jsont   deletet   ensure_asciit   defaultc         S` s   |  j  S(   N(   t   __dict__(   t   x(    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyt   <lambda>  s    Nu   "%s"u   -mu   conda.core.initializeu)   ERROR during elevated execution.
  rc: %sRF   c         S` s   |  j  S(   N(   R   (   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR     s    u    sudo %s -m conda.core.initializet   envt   patht   stdin(   R?   R"   t   common._os.windowsR   Rt   R   t   FalseRb   t   jsont   dumpst   nameR	   RL   R`   RK   RM   R#   t   loadsR    t   readR-   R,   R0   RG   RV   R   R   t   extend(   RC   R   t	   temp_patht   tfRg   t	   hinstancet
   error_codeRq   t   _planR   R   RM   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyRI     s<    %%	c          C` sK   t  j j   j   }  t j |   } t |  t  j j t j	 |   d  S(   N(
   RL   R   R   R   R   R   R=   R   Rb   R   (   R   RC   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyt   run_plan_from_stdin  s    
c         C` sx   t  |   " } t j t | j     } Wd  QXt |  t  |  d  ) } | j t t j | d t	   Wd  QXd  S(   Nu   w+bR   (
   R#   R   R   R    R   R=   Rb   R   R   R   (   R   Rq   RC   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyt   run_plan_from_temp_file  s
    !
c         C` s   | s t  j } n  x9 |  D]1 } t d | j d  | d d f d | q Wt d   |  D  } | r} t d d | n t d d | d  S(	   Nu   %-14s%su   resultu   kwargsu   target_pathRF   c         s` s'   |  ] } | j  d   t j k Vq d S(   u   resultN(   R   R4   R8   (   R:   R;   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pys	   <genexpr>  s    uK   
==> For changes to take effect, close and re-open your current shell. <==
u   No action taken.(   RL   R   RK   R   R?   (   RC   t   streamR;   t   changed(    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyRA     s    /	
c   
      C` sM  |  } t  |  r6 t |   } | j   } Wd  QXn d } t rK d } n d t | t    } t d  } | t d  i | d k r | n d d 6| d 6| d 67} | | k rBt j r t	 d	  t	 |   t	 t
 | |   n  t j s;t t |   t | d
   }	 |	 j |  Wd  QXt s;t |  q;n  t j St j Sd  S(   Nu    u   #!%s
u  
    # Before any more imports, leave cwd out of sys.path for internal 'conda shell.*' commands.
    # see https://github.com/conda/conda/issues/6549
    if len(sys.argv) > 1 and sys.argv[1].startswith('shell.') and sys.path and sys.path[0] == '':
        # The standard first entry in sys.path is an empty string,
        # and os.path.abspath('') expands to os.getcwd().
        del sys.path[0]
    u   
    # -*- coding: utf-8 -*-
    import sys
    %(extra)s
    if __name__ == '__main__':
        from %(module)s import %(func)s
        sys.exit(%(func)s())
    u	   conda.cliu   extrau   moduleu   funcu   
u   w(   R   R#   R   R"   R   R&   R   R   R]   RK   t	   make_diffR>   R+   R   Rb   R.   R4   R8   R9   (
   t   target_pathRB   t   modulet   funct   conda_ep_pathRq   t   original_ep_contentt   new_ep_contentt   conda_extrat   fdst(    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyRv     s8    				

	c         C` s   |  } d t  j d  } t t d d |  } t |  r] t |  t |  k r] t j Sn  t j	 s t
 t |   s t t |   n  t | |  n  t j S(   Ni   u   Pu   shellu
   cli-%d.exe(   t   structt   calcsizeR   R   R   R/   R4   R9   R   R>   R   R   R+   R*   R8   (   R   RB   t   exe_patht   bitst   source_exe_path(    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyRu     s    
	c         C` s   t  t d d  } t  t j d d d  } d d t  | d d	  t  | d d
  f f } t j } t j s t d d d |  d j  |  d t	 d  d |  t j
 } n  | r t j j |  r t j |  t j
 } q n  | S(   Nu   shellu   conda_icon.icou   HOMEPATHu   Desktopu   Anaconda Prompt.lnku   /Ku   ""%s" && "%s""u   condabinu   conda_hook.batu   conda_auto_activate.batu   %windir%\System32\cmd.exeu   Anconda Promptu    u    u   ~(   R   R   RG   t   environR4   R9   R   R>   R3   R   R8   R   R   t   remove(   R   RB   RE   t	   icon_patht   targett   argsR   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR   '  s(    		c         C` s   t  |   r0 t |    } | j   } Wd  QXn d } | } | | k r t j r{ t d  t |   t t | |   n  t j s t t	 |    t |  d   } | j
 |  Wd  QXn  t j St j Sd  S(   Nu    u   
u   w(   R   R#   R   R   R]   RK   R   R>   R+   R   Rb   R4   R8   R9   (   R   t   file_contentRq   t   original_contentt   new_contentR   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyt   _install_fileG  s     	

	c         C` s"   t    j d t  } t |  |  S(   Nt   auto_activate_base(   R   t   hookR   R   (   R   RB   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR   ^  s    c         C` sC   t  t d d d  } t |   } | j   } Wd  QXt |  |  S(   Nu   shellu   Scriptsu   activate.bat(   R   R   R#   R   R   (   R   RB   t   src_patht   fsrcR   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR}   d  s    c         C` sC   t  t d d d  } t |   } | j   } Wd  QXt |  |  S(   Nu   shellu   condabinu   activate.bat(   R   R   R#   R   R   (   R   RB   R   R   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR~   l  s    c         C` sC   t  t d d d  } t |   } | j   } Wd  QXt |  |  S(   Nu   shellu   condabinu   deactivate.bat(   R   R   R#   R   R   (   R   RB   R   R   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR   t  s    c         C` sQ   t  t d d d  } d | } t |   } | | j   7} Wd  QXt |  |  S(   Nu   shellu   binu   activateu   #!/bin/sh
_CONDA_ROOT="%s"
(   R   R   R#   R   R   (   R   RB   R   R   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR   |  s    c         C` sQ   t  t d d d  } d | } t |   } | | j   7} Wd  QXt |  |  S(   Nu   shellu   binu
   deactivateu   #!/bin/sh
_CONDA_ROOT="%s"
(   R   R   R#   R   R   (   R   RB   R   R   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR     s    c         C` sC   t  t d d d  } t |   } | j   } Wd  QXt |  |  S(   Nu   shellu   condabinu	   conda.bat(   R   R   R#   R   R   (   R   RB   t   conda_bat_src_pathR   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyRw     s    c         C` sF   t  t d d d d  } t |   } | j   } Wd  QXt |  |  S(   Nu   shellu   Libraryu   binu	   conda.bat(   R   R   R#   R   R   (   R   RB   R   R   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyRx     s    c         C` sC   t  t d d d  } t |   } | j   } Wd  QXt |  |  S(   Nu   shellu   condabinu   _conda_activate.bat(   R   R   R#   R   R   (   R   RB   R   R   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyRy     s    c         C` sC   t  t d d d  } t |   } | j   } Wd  QXt |  |  S(   Nu   shellu   condabinu   rename_tmp.bat(   R   R   R#   R   R   (   R   RB   R   R   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyRz     s    c         C` sC   t  t d d d  } t |   } | j   } Wd  QXt |  |  S(   Nu   shellu   condabinu   conda_auto_activate.bat(   R   R   R#   R   R   (   R   RB   R   R   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR{     s    c         C` sC   t  t d d d  } t |   } | j   } Wd  QXt |  |  S(   Nu   shellu   condabinu   conda_hook.bat(   R   R   R#   R   R   (   R   RB   R   R   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR|     s    c         C` s"   t    j d t  } t |  |  S(   NR   (   R   R   R   R   (   R   RB   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR     s    c         C` sC   t  t d d d  } t |   } | j   } Wd  QXt |  |  S(   Nu   shellu   condabinu
   Conda.psm1(   R   R   R#   R   R   (   R   RB   t   conda_psm1_pathR   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR     s    c         C` s"   t    j d t  } t |  |  S(   NR   (   R   R   R   R   (   R   RB   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR     s    c         C` s"   t    j d t  } t |  |  S(   NR   (   R   R   R   R   (   R   RB   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR     s    c         C` s"   t    j d t  } t |  |  S(   NR   (   R   R   R   R   (   R   RB   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR     s    c         C` s^   t  r1 d d l m } | t |  d d   } n t |  d d  } t d  i | d 6} | S(	   Ni   (   t   native_path_to_unixu   Scriptsu	   conda.exeu   binu   condau   
    # >>> conda initialize >>>
    # !! Contents within this block are managed by 'conda init' !!
    eval %(conda_exe)s "shell.fish" "hook" $argv | source
    # <<< conda initialize <<<
    u	   conda_exe(   R"   t   activateR   R   R   (   RB   R   t	   conda_exet   conda_initialize_content(    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyt   _config_fish_content  s    	c   
      C` sA  |  } y% t  |   } | j   } Wd  QXWn  t k
 rD d } n
   n X| } d } t |  } | r t j d j |  d | d t j } t j d t d | d t j	 t j B} n t
 s t j d t |  d j |  | d t j } n  t j d	 d
 j |  | d t j } t j d d j |  | d t j } d }	 t j t |	 | d t j } | j |	 |  } d | k r| d | 7} n  | | k r6t j rt d  t |   t t | |   n  t j s/t t |   st t |   n  t  | d   } | j |  Wd  QXn  t j St j Sd  S(   Nu    u#   # commented out by conda initializeu   #\s(.*?)\s*{}u   \1t   flagsu   ^\s*u:   ^[ \t]*?(set -gx PATH ([\'\"]?).*?%s\/bin\2 [^\n]*?\$PATH)u   # \1  {}u^   ^[ \t]*[^#\n]?[ \t]*((?:source|\.) .*etc\/fish\/conf\.d\/conda\.fish.*?)\n(conda activate.*?)$u   # \1  {0}\n# \2  {0}uJ   ^[ \t]*[^#\n]?[ \t]*((?:source|\.) .*etc\/fish\/conda\.d\/conda\.fish.*?)$u   __CONDA_REPLACE_ME_123__u   # >>> conda initialize >>>u   
%s
u   
u   w(   R#   R   t   FileNotFoundErrorR   t   ret   subt   formatt	   MULTILINEt   CONDA_INITIALIZE_RE_BLOCKt   DOTALLR"   R
   t   replaceR   R]   RK   R   R>   R   R   R+   Rb   R4   R8   R9   (
   R   RB   RE   t   user_rc_pathRq   t
   rc_contentt   rc_original_contentt   conda_init_commentR   t   replace_str(    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR     sx    	
	

	c         C` s_   t  r1 d d l m } | t |  d d   } n t |  d d  } t d  j d |  } | S(	   Ni   (   R   u   Scriptsu	   conda.exeu   binu   condau@  
    # >>> conda initialize >>>
    # !! Contents within this block are managed by 'conda init' !!
    import sys as _sys
    from types import ModuleType as _ModuleType
    _mod = _ModuleType("xontrib.conda",
                       "Autogenerated from $({conda_exe} shell.xonsh hook)")
    __xonsh__.execer.exec($("{conda_exe}" "shell.xonsh" "hook"),
                          glbs=_mod.__dict__,
                          filename="$({conda_exe} shell.xonsh hook)")
    _sys.modules["xontrib.conda"] = _mod
    del _sys, _mod, _ModuleType
    # <<< conda initialize <<<
    R   (   R"   R   R   R   R   R   (   RB   R   R   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyt   _config_xonsh_contentH  s    c   
      C` s  |  } y% t  |   } | j   } Wd  QXWn  t k
 rD d } n
   n X| } d } t |  } | r t j d j |  d | d t j } t j d t d | d t j	 t j B} nX d }	 t j t |	 | d t j } | j
 |	 |  } d | k r| d	 j |  7} n  | | k rt j rVt d
  t |   t t | |   n  t j st t |   st t |   n  t  | d   } | j |  Wd  QXn  t j St j Sd  S(   Nu    u#   # commented out by conda initializeu   #\s(.*?)\s*{}u   \1R   u   ^\s*u   __CONDA_REPLACE_ME_123__u   # >>> conda initialize >>>u   
{0}
u   
u   w(   R#   R   R   R   R   R   R   R   R   R   R   R   R]   RK   R   R>   R   R   R+   Rb   R4   R8   R9   (
   R   RB   RE   R   Rq   R   R   R   R   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR   _  sV    		

	c         C` s   t  rO d d l m } | t |  d d   } t d  i | d 6| d 6} n t |  d d	  } | d k r t d  i | d 6| d 6t |  d 6|  d 6} n2 t d  i | d 6| d 6t |  d 6|  d 6} | S(   Ni   (   R   u   Scriptsu	   conda.exeu   
        # >>> conda initialize >>>
        # !! Contents within this block are managed by 'conda init' !!
        eval "$('%(conda_exe)s' 'shell.%(shell)s' 'hook')"
        # <<< conda initialize <<<
        u	   conda_exeu   shellu   binu   condau   cshu   tcshu  
            # >>> conda initialize >>>
            # !! Contents within this block are managed by 'conda init' !!
            if ( -f "%(conda_prefix)s/etc/profile.d/conda.csh" ) then
                source "%(conda_prefix)s/etc/profile.d/conda.csh"
            else
                setenv PATH "%(conda_bin)s:$PATH"
            endif
            # <<< conda initialize <<<
            u	   conda_binu   conda_prefixuk  
            # >>> conda initialize >>>
            # !! Contents within this block are managed by 'conda init' !!
            __conda_setup="$('%(conda_exe)s' 'shell.%(shell)s' 'hook' 2> /dev/null)"
            if [ $? -eq 0 ]; then
                eval "$__conda_setup"
            else
                if [ -f "%(conda_prefix)s/etc/profile.d/conda.sh" ]; then
                    . "%(conda_prefix)s/etc/profile.d/conda.sh"
                else
                    export PATH="%(conda_bin)s:$PATH"
                fi
            fi
            unset __conda_setup
            # <<< conda initialize <<<
            (   u   cshu   tcsh(   R"   R   R   R   R   R   (   RB   Rd   R   R   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyt   _bashrc_content  s,    				c         C` sd  |  } y% t  |   } | j   } Wd  QXWn  t k
 rD d } n
   n X| } t | |  } d }	 | r t j d j |	  d | d t j } t j d t d | d t j	 t j B} n t
 s t j d t |  d j |	  | d t j } n  t j d	 d
 j |	  | d t j } t j d d j |	  | d t j } t
 rqt j d d | d t j } n t j d d | d t j } d }
 t j t |
 | d t j } | j |
 |  } d | k r| d | 7} n  | | k rYt j r!t d  t |   t t | |   n  t j sRt  | d   } | j |  Wd  QXn  t j St j Sd  S(   Nu    u#   # commented out by conda initializeu   #\s(.*?)\s*{}u   \1R   u   ^\s*u3   ^[ \t]*?(export PATH=[\'\"].*?%s\/bin:\$PATH[\'\"])u   # \1  {}uY   ^[ \t]*[^#\n]?[ \t]*((?:source|\.) .*etc\/profile\.d\/conda\.sh.*?)\n(conda activate.*?)$u   # \1  {0}\n# \2  {0}uD   ^[ \t]*[^#\n]?[ \t]*((?:source|\.) .*etc\/profile\.d\/conda\.sh.*?)$uE   ^[ \t]*^[ \t]*[^#\n]?[ \t]*((?:source|\.) .*Scripts[/\\]activate.*?)$u)   # \1  # commented out by conda initializeu=   ^[ \t]*^[ \t]*[^#\n]?[ \t]*((?:source|\.) .*bin/activate.*?)$u   __CONDA_REPLACE_ME_123__u   # >>> conda initialize >>>u   
%s
u   
u   w(   R#   R   R   R   R   R   R   R   R   R   R"   R
   R   R   R]   RK   R   R>   Rb   R4   R8   R9   (   R   RB   Rd   RE   R   Rq   R   R   R   R   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR     s    	
	

	c         C` s  |  } t  |  r6 t |   } | j   } Wd  QXn d } | re t  |  rt j |  t j Sn t | d  } | | k rt j	 r t
 d  t
 |   t
 t | |   n  t j st |  r t |  n  t t |   t | d   } | j |  Wd  QXn  t j St j S(   Nu    u   posixu   
u   w(   R   R#   R   RG   R   R4   R8   R   R   R]   RK   R   R>   R-   R,   R+   R   Rb   R9   (   R   RB   RE   t   conda_sh_system_pathRq   t   conda_sh_system_contentst   conda_sh_contents(    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR   7  s.    
	

	c   
      C` s  |  j  d d  \ } } | j d d  \ } } t t |  } y t j | | d t j  } Wn) t k
 r } | j t k r   n  d SXzx yR t j
 | |  } | d } t | t  r | j   } n  | d }	 | |	 f SWn t k
 r t j |  d SXWd  t j |  Xd  S(   Nu   \i   i    (   NN(   NN(   t   splitt   rsplitt   getattrt   winregt   OpenKeyt   KEY_READRs   t   errnoR   Rt   t   QueryValueExt
   isinstanceR^   R   R   t   CloseKey(
   R   t   main_keyt   the_restt
   subkey_strt
   value_nameRn   R   t   value_tuplet   value_valuet
   value_type(    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyt   _read_windows_registryU  s*     

	c   	      C` s   |  j  d d  \ } } | j d d  \ } } t t |  } y t j | | d t j  } Wn: t k
 r } | j t k r   n  t j	 | |  } n Xz t j
 | | d | |  Wd  t j |  Xd  S(   Nu   \i   i    (   R   R   R   R  R  t	   KEY_WRITERs   R  R   t	   CreateKeyt
   SetValueExR  (	   R   R  R  R  R	  R
  R  Rn   R   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyt   _write_windows_registrys  s    c      	   ` sY  t  |   \ } } | d  k r0 d } t j } n  d t | d d    | r} | j d  } d j   f d   | D  } no d } t j d	 | | d
 d d t j t j	 B} | j
 |    }   | k r | r | d   7} q   } n  | | k rNt j r+t d  t |   t t | |   n  t j sGt |  | |  n  t j St j Sd  S(   Nu    u   "%s"u   condabinu   conda_hook.batu   &u    & c         3` s'   |  ] }   | k r | j    Vq d  S(   N(   R   (   R:   t   part(   t	   hook_path(    s4   lib/python2.7/site-packages/conda/core/initialize.pys	   <genexpr>  s    u   __CONDA_REPLACE_ME_123__u   (\"[^\"]*?conda[-_]hook\.bat\")t   counti   R   u   
(   R  Rt   R  t   REG_EXPAND_SZR   R   R   R   t
   IGNORECASEt   UNICODER   R   R]   RK   R   R>   R  R4   R8   R9   (   R   RB   RE   t
   prev_valueR  t   autorun_partst	   new_valueR   (    (   R  s4   lib/python2.7/site-packages/conda/core/initialize.pyR     s:    "		

	c         C` s   t  j d j d  \ } } } t |  d k r t |  d k r t |   \ } } t |  d k r t  j r t d  t |   t t t |  d   n  t  j	 s t
 |  d t j  n  t j St j Sn$ t  j r t d  t d  t j Sd  S(   Ni   u   .i
   i8  u   1u   
uy   Not setting long path registry key; Windows version must be at least 10 with the fall 2016 "Anniversary update" or newer.(   R   t   os_distribution_name_versionR   t   intR  R^   R]   RK   R   R>   R  R  t	   REG_DWORDR4   R8   R9   (   R   t   win_vert   _t   win_revR  R  (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR     s     $	

	
	

c         C` sI   t  r t |  d d  } n t |  d d  } t d j d |   } | S(   Nu   Scriptsu	   conda.exeu   binu   condau   
    #region conda initialize
    # !! Contents within this block are managed by 'conda init' !!
    (& "{conda_exe}" "shell.powershell" "hook") | Out-String | Invoke-Expression
    #endregion
    R   (   R"   R   R   R   (   RB   R   t   conda_powershell_module(    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyt   _powershell_profile_content  s    c      
   C` s  |  } t  j j |  r< t |   } | j   } Wd  QXn d } | } | r| t j t d | d d d t j t j	 B} ne t
 |  } d | k r | d j |  7} n7 t j t d | d d d t j t j	 Bj d |  } | | k r}t j r t d  t |   t t | |   n  t j svt t |   sNt t |   n  t | d	   } | j |  Wd  QXn  t j St j Sd  S(
   Nu    R  i   R   u   #region conda initializeu   
{}
u   __CONDA_REPLACE_ME_123__u   
u   w(   RG   R   R   R#   R   R   R   t   CONDA_INITIALIZE_PS_RE_BLOCKR   R   R$  R   R   R   R]   RK   R   R>   R   R+   Rb   R4   R8   R9   (   R   RB   RE   t   profile_patht   fpt   profile_contentt   profile_original_contentR   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR     sD    				

	c         C` s7  t  } |  } t j t t | d   t t | d   t t | d   f  } d   | D } xS | D]K } t d t | |  d t j t j	 s t
 t | |   n  t } qh Wd	 } x_ | D]W } t | |  } t |  r t d | d t j t j	 st
 |  n  t } q q W| r,t j St j Sd  S(
   Nu   conda-*infou   conda.*u   conda-*.eggc         s` s$   |  ] } | j  d   s | Vq d S(   u   conda.egg-linkN(   t   endswith(   R:   t   p(    (    s4   lib/python2.7/site-packages/conda/core/initialize.pys	   <genexpr>  s    u	   rm -rf %sRF   u   condau	   conda_env(   u   condau	   conda_env(   R   R   t   from_iterableR   R   RK   RL   RM   R   R>   R,   R   R-   R4   R8   R9   (   R   t   modifiedRi   t   rm_rf_theset   fnt   otherst   otherR   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyRY   
  s0     	
 	c         C` s   | t  j } t |   r@ t |  d   } | j   } Wd  QXn d } | | k r t j r t d d t j	 t |  d t j	 t t
 | |  d t j	 n  t j s t |  d   } | j t |   Wd  QXn  t j St j Sd  S(   Nu   rbu    u   
RF   u   wb(   RG   t   linesepR   R#   R   R   R]   RK   RL   RM   R   R>   Rb   R   R4   R8   R9   (   R   Rf   t   conda_egg_link_contentsRq   t   conda_egg_link_contents_old(    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyRZ   *  s    		c         ` s4  | } t  |   r6 t |    } | j   } Wd  QXn d } | j   } | | k r[ t j St j d   t   f d   | D  } | t j	 t j	 j
 |  t j	 } t j r t d d t j t |  d t j t t | |  d t j n  t j s-t |  d   } | j t |   Wd  QXn  t j S(   Nu    u   condac         3` s$   |  ] } | j     s | Vq d  S(   N(   R*  (   R:   t   ln(   t   ln_end(    s4   lib/python2.7/site-packages/conda/core/initialize.pys	   <genexpr>P  s    u   
RF   u   wb(   R   R#   R   t
   splitlinesR4   R9   RG   t   sept   tupleR2  R   R   R]   RK   RL   RM   R   R>   Rb   R   R8   (   R   Rf   t   easy_install_new_lineRq   t   old_contentst   old_contents_linest   new_contents(    (   R6  s4   lib/python2.7/site-packages/conda/core/initialize.pyR[   A  s&    $		c         C` s   t  |   r0 t |    } | j   } Wd  QXn d } t d  t } | | k rY t j St j r t	 d d t
 j t	 |  d t
 j t	 t | |  d t
 j n  t j s t |   r t |   n  t |  d   } | j |  Wd  QXn  t j S(   Nu    u   
    Metadata-Version: 1.1
    Name: conda
    Version: %s
    Platform: UNKNOWN
    Summary: OS-agnostic, system-level binary package manager.
    u   
RF   u   w(   R   R#   R   R   t   CONDA_VERSIONR4   R9   R   R]   RK   RL   RM   R   R>   R-   R,   Rb   R8   (   R   Rq   R;  R=  (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR\   ^  s$    		c         C` s"   d j  t |  j   | j     S(   Nu   
(   R   R   R7  (   t   oldt   new(    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyR     s    c         C` s   t  |  t    } t d |  } | j j   | j j   } } | rZ | j   d } n% | rs | j   d } n t d   t  |  t t	 |    } | | | f S(   Nu   %s --versioni   u(   No python version information available.(
   R   R&   R0   R   R   RM   R   t
   ValueErrorR(   R'   (   RU   Rg   R   R   RM   Rh   Ri   (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyRW     s    u   __main__i   (    (   t   __doc__t
   __future__R    R   R   R   t   difflibR   R  R   R   t	   itertoolsR   R   t   loggingR   RG   t   os.pathR	   R
   R   R   R   R   R   R   t   randomR   R   RL   R   R   t	   NameErrort   IOErrort    R   R   R   R>  t   _vendor.auxlib.compatR   t   _vendor.auxlib.ishR   R   R   R   R   R   R   t   base.contextR   t   common.compatR   R   R   R    R!   R"   R#   t   common.pathR$   R%   R&   R'   R(   t
   exceptionsR)   t   gateways.disk.createR*   R+   t   gateways.disk.deleteR,   t   gateways.disk.linkR-   t   gateways.disk.permissionsR.   t   gateways.disk.readR/   t   gateways.subprocessR0   t   _winregR  t   menuinst.knownfoldersR1   R2   t   menuinst.winshortcutR3   R5   R   R   R%  R4   RD   R   RT   Rt   Rr   R<   RJ   R=   RI   R   R   RA   Rv   Ru   R   R   R   R}   R~   R   R   R   Rw   Rx   Ry   Rz   R{   R|   R   R   R   R   R   R   R   R   R   R   R   R   R  R  R   R   R$  R   RY   RZ   R[   R\   R   RW   t   argvR   (    (    (    s4   lib/python2.7/site-packages/conda/core/initialize.pyt   <module>   s   ":
(4(
		o			:			6		 																				U		>	8b		,			6	 			$		