σ
έ²k^c        *   @` sΘ  d  d l  m Z m Z m Z m Z d  d l Z d  d l m 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 m Z d d l m Z m Z d d	 l m Z d  d
 l m Z m Z m Z m Z d  d l m Z d  d l m Z e j  e!  Z" e Z# d   Z$ d d  Z% d   Z& d   Z' d   Z( d   Z) e* d d d d d d d d d e$ d e$ d d d  d! d" d# d$ d% d& d' d( d) d* d+ d, d- d. g d/ d d0 d\ d2 d3 d4 d d5 d6  Z+ e* e+ d e% d e d d d" d7 Z, e ri e* d d8 d5 d9 d d: d2 d; d4 d d d< d* d= d/ d> d d> d$ d? d& d@ d  dA d" dB dC dD d, dE dF g d e$ d e$ d0 d] d( d1 d dG  dD 6e* e+ dC dH d dI d e' d e& dJ 6e* e, dC dH dH 6e* e, dC dK dK 6e* e, dC dL dL 6e* e, dC dM dM 6e* e, dC dN dN 6Z- n^ i e* e+ dC dK dK 6e* e+ dC dO d2 dP dO 6e* e+ dC dN dN 6e* e+ dC dQ d dR dQ 6Z- e Z. Z/ dS   Z0 dT dU  Z1 e dV    Z2 d dW  Z4 dX dY  Z5 dZ   Z6 d[   Z7 d S(^   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literalsN(   t   dirnamei   (   t   memoize(   t   shlex_split_unicodet   string_typest   Utf8NamedTemporaryFile(   t   on_wint
   isiterable(   t   win_path_to_unixt   which(   t   path_to_url(   t   abspatht   joint   isfilet   basename(   t   environ(   t   list2cmdlinec         C` s   |  S(   u<   Used as a dummy path converter where no conversion necessary(    (   t   path(    (    s*   lib/python2.7/site-packages/conda/utils.pyt   path_identity   s    u    c         ` s   t  |   d k rS d |  k sC |  d d k rS |  j d  d k rS |  j d d  S  d }   f d   } t j | | |   } t j d d	   |  } | S(
   u   Convert a path or :-separated string of paths into a Windows representation

    Does not add cygdrive.  If you need that, set root_prefix to "/cygdrive"
    i   u   ;u   :u   /u   \u$   (/[a-zA-Z]/(?:(?![:\s]/)[^:*?"<>])*)c         ` sG   |  j  d  } d j | t    d | t    d j d d   S(   Ni    u   {0}:{1}i   i   u   /u   \(   t   groupt   formatt   lent   replace(   t
   found_pathR   (   t   root_prefix(    s*   lib/python2.7/site-packages/conda/utils.pyt   _translation*   s    u   :([a-zA-Z]):\\c         S` s   d |  j  d  d d S(   Nu   ;i    i   u   :\(   R   (   t   match(    (    s*   lib/python2.7/site-packages/conda/utils.pyt   <lambda>0   s    (   R   t   countR   t   ret   sub(   R   R   t   path_reR   t   translation(    (   R   s*   lib/python2.7/site-packages/conda/utils.pyt   unix_path_to_win    s    C
		c         C` s   t  |  d  S(   Nu	   /cygdrive(   R   (   R   (    (    s*   lib/python2.7/site-packages/conda/utils.pyt   win_path_to_cygwin6   s    c         C` s   t  |  d  S(   Nu	   /cygdrive(   R$   (   R   (    (    s*   lib/python2.7/site-packages/conda/utils.pyt   cygwin_path_to_win:   s    c         ` s&   d j    f d   |  j d  D  S(   Nu   
c         3` s   |  ] }   |  Vq d  S(   N(    (   t   .0t   line(   t
   translator(    s*   lib/python2.7/site-packages/conda/utils.pys	   <genexpr>?   s    (   R   t   split(   t   streamR)   (    (   R)   s*   lib/python2.7/site-packages/conda/utils.pyt   translate_stream>   s    c         C` sh   |  d k  r d |  S|  d } | d k  r8 d t  |  S| d } | d k  rV d | S| d } d | S(   u  
    Return the number of bytes n in more human readable form.

    Examples:
        >>> human_bytes(42)
        '42 B'
        >>> human_bytes(1042)
        '1 KB'
        >>> human_bytes(10004242)
        '9.5 MB'
        >>> human_bytes(100000004242)
        '93.13 GB'
    i   u   %d Bu   %d KBu   %.1f MBu   %.2f GB(   t   round(   t   nt   kt   mt   g(    (    s*   lib/python2.7/site-packages/conda/utils.pyt   human_bytesB   s    


t   binpathu   /bin/t   echou   echot   env_script_suffixu   .sht   nulu   2>/dev/nullt	   path_fromt   path_tot   pathsepu   :t   printdefaultenvu   echo $CONDA_DEFAULT_ENVt	   printpathu
   echo $PATHt   printps1u   echo $CONDA_PROMPT_MODIFIERt	   promptvaru   PS1t   sepu   /t   set_varu   export t
   shell_argsu   -lu   -ct   shell_suffixt   slash_convertu   \t   source_setupu   sourcet   test_echo_extrat
   var_formatu   ${}u_   python -c "import os; print(';'.join(os.environ['PATH'].split(';')[1:]))" | cygpath --path -f -u   @echou   %{}%u	   \Scripts\u   callu
   1>NUL 2>&1u   set u   .batu   @echo %PROMPT%u   PROMPTuM   IF NOT "%CONDA_DEFAULT_ENV%" == "" (
echo %CONDA_DEFAULT_ENV% ) ELSE (
echo()u   @echo %PATH%t   exeu   cmd.exeu   /du   /cu   ;u   bash.exeu	   /Scripts/u   cygwinu   bashu   sh.exeu   zsh.exeu   zshu   dashu   .u   fishu    c         C` s   d d l  m } | |   S(   Ni   (   t   compute_md5sum(   t   gateways.disk.readRG   (   R   RG   (    (    s*   lib/python2.7/site-packages/conda/utils.pyt   md5_fileα   s    u   md5c         C` sp   d d  l  } | j |  } t |  d  : } x0 t r_ | j d  } | sO Pn  | j |  q0 WWd  QX| j   S(   Ni    u   rbi   (   t   hashlibt   newt   opent   Truet   readt   updatet	   hexdigest(   R   t   modeRJ   t   ht   fit   chunk(    (    s*   lib/python2.7/site-packages/conda/utils.pyt   hashsum_fileζ   s    	c          C` s{   y_ t  t t j   j     }  x |  j r9 |  j }  q$ W|  j } | j } t t |   } Wn t	 k
 rv t j
 SX| S(   u  Since conda is installed into non-root environments as a symlink only
    and because sys.prefix follows symlinks, this function can be used to
    get the 'unfollowed' sys.prefix.

    This value is usually the same as the prefix of the environment into
    which conda has been symlinked. An example of when this is necessary
    is when conda looks for external sub-commands in find_commands.py
    (   t   nextt   itert   syst   _current_framest   valuest   f_backt   f_codet   co_filenameR   t	   Exceptiont   prefix(   t   framet   codet   filenamet
   unfollowed(    (    s*   lib/python2.7/site-packages/conda/utils.pyt   sys_prefix_unfollowedς   s    
		c         ` sΓ   | s t  r d n d } n  | d k r1 t |   Sg  } xx |  D]p   d   k rY d } n@ d   k rn d } n+ t   f d   d	 D  s d } n d } | j |   |  q> Wd j |  Sd  S(
   Nu   cmd.exeu   bashu   "u   'c         3` s   |  ] } |   k Vq d  S(   N(    (   R'   t   _(   t   arg(    s*   lib/python2.7/site-packages/conda/utils.pys	   <genexpr>  s    u    u   
u    (   u    u   
(   R	   R   t   anyt   appendR   (   t	   argumentst   shellt   quotedt   quote(    (   Rf   s*   lib/python2.7/site-packages/conda/utils.pyt   quote_for_shell  s    
			u   assertc         C` s¦   t  |  t  rL | d k r0 t sI t d   qL t |   }  t j d  n  t |   sd |  f }  n  t g  |  D] } t |  ^ qn  s t d   t	 |   }  |  S(   Nu   assertu'   Please ensure arguments are not stringsuK   Please ensure arguments is not a string; used `shlex_split_unicode()` on itu)   Individual arguments must not be iterable(
   t
   isinstanceR   t   Falset   AssertionErrorR   t   logt   warningR
   Rg   t   list(   Ri   t   errorsRf   (    (    s*   lib/python2.7/site-packages/conda/utils.pyt   massage_arguments%  s    2c      	   C` s=  |  r t    n  t |  } t t | d   } d  } t } t |  d k rh d | d k rh t } n  |  r7t t	 d  }	 | r¬ d d l
 m }
 t |
 d d d	  } n$ t j d
 t t | d d	    } t d d d | d d d t  /} | r d n d } | j d j |   | j d j |   | j d j |   | j d j |   | j d j |   | r
d d l m }
 | j d j |   | j d j | t |
    | j d j | t j   | j d j |   | j d j |   n  | r-| j d  | j d  n  | j d j | | |   | j d  j |   | r| j d!  | j d  n  | r₯| j d" j | d   nB t d#   | D  sΘt d$   | j d% j | t |    | j d  j |   | j d& j |   | j } Wd  QX|	 d' d( | g } nόt d)  pLt d*  } | d  k rjt d+   n  | r£t t | d, d-   d. d/ g } d0 } | g } n3 t j d1 t t | d, d/    g } d } g  } t d d d | d t  } | r(d d l m }
 | j d2 t |
  d  n  t | d3 d4 g |  } | rn| j d5  | j d6 j |   n  | j d7 j |   | j d8 j | t | f    | rΌ| j d9  n  | rδ| j d" j d: j |    n | j d" j t |    | j } Wd  QX| r'| d; | g } n | | g } | | f S(<   Nu   .tmpi   u   
i    u   COMSPEC(   t   CONDA_PACKAGE_ROOTu   shellu   condabinu	   conda.batu	   CONDA_BATRQ   u   wR_   t   suffixu   .batt   deleteu    u   @u   {}ECHO OFF
u   {}SET PYTHONIOENCODING=utf-8
u   {}SET PYTHONUTF8=1
u_   {}FOR /F "tokens=2 delims=:." %%A in ('chcp') do for %%B in (%%A) do set "_CONDA_OLD_CHCP=%%B"
u   {}chcp 65001 > NUL
u   {}SET CONDA_DEV=1
u   {}SET PYTHONPATH={}
u   {}SET CONDA_EXE={}
u   {}SET _CE_M=-m
u   {}SET _CE_CONDA=conda
u%   echo *** environment before *** 1>&2
u	   SET 1>&2
u   {0}CALL "{1}" activate "{2}"
u-   {}IF %ERRORLEVEL% NEQ 0 EXIT /b %ERRORLEVEL%
u$   echo *** environment after *** 1>&2
u   {0}
c         s` s   |  ] } d  | k Vq d S(   u   
N(    (   R'   Rf   (    (    s*   lib/python2.7/site-packages/conda/utils.pys	   <genexpr>w  s    uW  Support for scripts where arguments contain newlines not implemented.
.. requires writing the script to an external file and knowing how to transform the command-line (e.g. `python -c args` => `python file`) in a tool dependent way, or attempting something like:
.. https://stackoverflow.com/a/15032476 (adds unacceptable escapingrequirements)u   {0}{1}
u   {}chcp %_CONDA_OLD_CHCP%>NUL
u   /du   /cu   bashu   shu   No compatible shell found!u   binu   pythonu   -mu   condau   --devu	   CONDA_EXEu   >&2 export PYTHONPATH=u   shell.posixu   hooku.   >&2 echo '*** environment before ***'
>&2 env
u   >&2 echo "$({0})"
u   eval "$({0})"
u   conda activate {0} {1}
u-   >&2 echo '*** environment after ***'
>&2 env
u    u   -x(   t   ensure_comspec_setRu   R   R   t   NoneRo   R   RM   R   t   strt   condaRv   t   getR   t   writeR   t   conda.core.initializeR   RX   t
   executableRg   Rp   Rm   t   nameR   R^   (   R	   R   R_   t   dev_modet   debug_wrapper_scriptsRi   t
   tmp_prefixt   script_callert	   multilinet   comspecRv   t	   conda_batt   fht   silencert   command_argst
   shell_patht	   conda_exet   dev_argt   dev_argst   hook_quoted(    (    s*   lib/python2.7/site-packages/conda/utils.pyt   wrap_subprocess_callC  s    
"			!'
""c          C` s   t  t j d d   j   d k r t t j d  d d  }  t |   si t t j d  d d  }  n  t |   s t j d  q |  t d <n  d  S(   Nu   COMSPECu    u   cmd.exeu
   SystemRootu   System32u   windiruF   cmd.exe could not be found. Looked in SystemRoot and windir env vars.
(   R   R   R}   t   lowerR   R   Rq   t   warn(   t   cmd_exe(    (    s*   lib/python2.7/site-packages/conda/utils.pyRy   ²  s    $(   u   \u   /(   u   /u   \(8   t
   __future__R    R   R   R   t   loggingt   os.pathR   R    RX   t   _vendor.auxlib.decoratorsR   t   _vendor.auxlib.compatR   R   R   t   common.compatR	   R
   t   common.pathR   R   t
   common.urlR   R   R   R   R   t   osR   t
   subprocessR   t	   getLoggert   __name__Rq   t   memoizedR   R$   R%   R&   R,   R2   t   dictt   unix_shell_baset   msys2_shell_baset   shellst   urlpatht   url_pathRI   RU   Rd   Rz   Rm   Ru   R   Ry   (    (    (    s*   lib/python2.7/site-packages/conda/utils.pyt   <module>   sΠ   ""							


	
		o