ó
Ý²k^c           @` sw  d  d l  m Z m Z m Z m Z d  d l m 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 Z d  d l Z d d l m Z m Z d d	 l m Z d d
 l m Z d d l m Z m Z m Z d  d l  m! Z! y d  d l" m# Z# m$ Z$ Wn1 e% k
 rOd  d l& m# Z# d  d l' m$ Z$ n Xe e( ƒ Z) d Z* d „  Z+ d „  Z, d „  Z- e d „  ƒ Z. d „  Z/ d „  Z0 d „  Z1 e2 d „ Z3 d „  Z4 d „  Z5 d „  Z6 d d „ Z8 d „  Z9 e: d „ Z; d „  Z< d  „  Z= d! „  Z> d" „  Z? d# d$ „ Z@ d% „  ZA d& „  ZB d' „  ZC d( „  ZD d) „  ZE d* d+ „ ZF d, „  ZG d- „  ZH d. „  ZI d S(/   i    (   t   absolute_importt   divisiont   print_functiont   unicode_literals(   t   reduce(   t	   getLoggerN(   t   abspatht   basenamet
   expandusert
   expandvarst   joint   normcaset   splitt   splitexti   (   t   on_wint   string_typesi   (   t
   CondaError(   t   memoize(   t
   accumulatet   concatt   take(   t   find_executable(   t   unquotet   urlsplit(   R   (   R   u#   \./|\.\.|~|/|[a-zA-Z]:[/\\]|\\\\|//c         C` s    d |  k r t  St j t |  ƒ S(   Nu   ://(   t   Falset   ret   matcht   PATH_MATCH_REGEX(   t   value(    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   is_path(   s    c         C` s   t  t t |  ƒ ƒ ƒ S(   N(   R   R   R	   (   t   path(    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   expand.   s    c         C` sB   t  r( t t |  ƒ ƒ t t | ƒ ƒ k St |  ƒ t | ƒ k Sd S(   uR   
    Examples:
        >>> paths_equal('/a/b/c', '/a/b/c/d/..')
        True

    N(   R   R   R   (   t   path1t   path2(    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   paths_equal4   s    "c         C` sÓ   t  |  ƒ r |  S|  j d ƒ s2 t d |  ƒ ‚ n  t |  ƒ \ } } } } } d d l m } | | ƒ } | d k r” | j d	 ƒ sË d
 | } qË n7 d } t j d | t j ƒ rË | d d | d } n  | | S(   ul   Convert a file:// URL to a path.

    Relative file URLs (i.e. `file:relative/path`) are not supported.
    u   file://u9   You can only turn absolute file: urls into paths (not %s)i   (   t   percent_decodeu    u	   localhostu	   127.0.0.1u   ::1u   \\u   //u   ^/([a-z])[:|]u   :i   (   u    u	   localhostu	   127.0.0.1u   ::1(	   R   t
   startswithR   R   t   urlR#   R   R   t   I(   R%   t   _t   netlocR   R#   (    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   url_to_path@   s    c         C` s   t  d „  t |  | ƒ Dƒ ƒ S(   Nc         s` s!   |  ] \ } } | | k Vq d  S(   N(    (   t   .0t   tt   sw(    (    s0   lib/python2.7/site-packages/conda/common/path.pys	   <genexpr>Z   s    (   t   allt   zip(   t   test_iterablet   startswith_iterable(    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   tokenized_startswithY   s    c         C` s!   t  t d „  |  Dƒ ƒ d h ƒ S(   Nc         s` s(   |  ] } t  | j d  ƒ d  ƒ Vq d S(   u   /iÿÿÿÿN(   t   tupleR   (   R*   t   f(    (    s0   lib/python2.7/site-packages/conda/common/path.pys	   <genexpr>^   s    (    (   t   sortedt   set(   t   files(    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   get_all_directories]   s    c         ` s‹   t  |  ƒ } | s d Sg  ‰  ‡  f d †  } t | | ƒ } ˆ  sT ˆ  j | d ƒ n# t | ˆ  d ƒ sw ˆ  j | ƒ n  t d „  ˆ  Dƒ ƒ S(   Nc         ` s#   t  | |  ƒ s ˆ  j |  ƒ n  | S(   N(   R1   t   append(   t   xt   y(   t   leaves(    s0   lib/python2.7/site-packages/conda/common/path.pyt   _processk   s    iÿÿÿÿc         s` s   |  ] } d  j  | ƒ Vq d S(   u   /N(   R
   (   R*   t   leaf(    (    s0   lib/python2.7/site-packages/conda/common/path.pys	   <genexpr>v   s    (    (   R7   R   R8   R1   R2   (   R6   t   directoriesR<   t   last(    (   R;   s0   lib/python2.7/site-packages/conda/common/path.pyt   get_leaf_directoriesa   s    c         ` s/   ‡  f d †  ‰ t  t ‡ f d †  |  Dƒ ƒ ƒ S(   Nc         ` s   ˆ  r
 |  S|  j  d ƒ S(   Nu   /(   R   (   R9   (   t   already_split(    s0   lib/python2.7/site-packages/conda/common/path.pyt   <lambda>|   s    c         3` s*   |  ]  } | r t  t ˆ  | ƒ ƒ Vq d  S(   N(   R   R
   (   R*   t	   directory(   t   maybe_split(    s0   lib/python2.7/site-packages/conda/common/path.pys	   <genexpr>}   s   (   R5   R   (   t   child_directoriesRA   (    (   RA   RD   s0   lib/python2.7/site-packages/conda/common/path.pyt   explode_directoriesy   s    c         C` sƒ   | j  d d ƒ } | j d ƒ r) |  d St |  ƒ \ } } t | ƒ \ } } d
 d | | | f } | r{ d | d | f S| Sd	 S(   u	  
    This must not return backslashes on Windows as that will break
    tests and leads to an eventual need to make url_to_path return
    backslashes too and that may end up changing files on disc or
    to the result of comparisons with the contents of them.
    u   .u    u   2u   cu   __pycache__u   /u   %s.cpython-%s%scu   %s%s%sNu   __pycache__/(   t   replaceR$   R   R   (   t   py_patht   python_major_minor_versiont   pyver_stringRC   t   py_filet   basename_roott	   extensiont   pyc_file(    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   pyc_path   s    c         ` sF   d „  ˆ  Dƒ } ‡ f d †  | Dƒ } t  ‡  f d †  | Dƒ ƒ } | S(   Nc         s` s$   |  ] } | j  d  ƒ r | Vq d S(   u   .pyN(   t   endswith(   R*   R3   (    (    s0   lib/python2.7/site-packages/conda/common/path.pys	   <genexpr>•   s    c         3` s$   |  ] } | t  | ˆ  ƒ f Vq d  S(   N(   RO   (   R*   RK   (   RI   (    s0   lib/python2.7/site-packages/conda/common/path.pys	   <genexpr>–   s   c         3` s%   |  ] } | d  ˆ  k r | Vq d S(   i   N(    (   R*   R   (   R6   (    s0   lib/python2.7/site-packages/conda/common/path.pys	   <genexpr>˜   s    (   R2   (   RI   R6   t   py_filest   pyc_matchest   result(    (   R6   RI   s0   lib/python2.7/site-packages/conda/common/path.pyt   missing_pyc_files“   s
    
c         C` sc   |  j  d d ƒ \ } } | j  d d ƒ \ } } | j ƒ  | j ƒ  | j ƒ  } } } | | | f S(   Nu   :i   u   =(   t   rsplitt   strip(   t   ep_definitiont   cmd_modt   funct   commandt   module(    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   parse_entry_point_defœ   s    &c         C` sE   t  r
 d S|  r. d |  k r. d j |  ƒ }  n  t d d |  p@ d ƒ S(   Nu
   python.exeu   .u   binu   python%su    (   R   R
   (   t   python_version(    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   get_python_short_path£   s
    c         C` s2   |  d  k r d  St r d St |  ƒ } d | Sd  S(   Nu   Lib/site-packagesu   lib/python%s/site-packages(   t   NoneR   t   get_major_minor_version(   R]   t   py_ver(    (    s0   lib/python2.7/site-packages/conda/common/path.pyt#   get_python_site_packages_short_path«   s    c         C` sj   t  |  t ƒ s t ‚ t t d d „  |  Dƒ ƒ ƒ } t | ƒ d k rf | rY d j | ƒ Sd j | ƒ Sd  S(   Ni   c         s` s!   |  ] } | j  ƒ  r | Vq d  S(   N(   t   isdigit(   R*   t   c(    (    s0   lib/python2.7/site-packages/conda/common/path.pys	   <genexpr>¾   s    u   .u    (   t
   isinstanceR   t   AssertionErrorR2   R   t   lenR
   R_   (   t   stringt   with_dott   digits(    (    s0   lib/python2.7/site-packages/conda/common/path.pyR`   µ   s
     c           C` s   t  r
 d Sd S(   Nu   Scriptsu   bin(   R   (    (    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   get_bin_directory_short_pathÄ   s    c         C` s   t  r |  j d d ƒ S|  S(   Nu   /u   \(   R   RG   (   R   (    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   win_path_okÈ   s    c         C` s   t  r |  j d d ƒ S|  S(   Nu   \u   \\(   R   RG   (   R   (    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   win_path_double_escapeÌ   s    c         C` s   t  j d d |  ƒ j d d ƒ S(   Nu	   (\\(?! ))u   /u   :////u   ://(   R   t   subRG   (   R   (    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   win_path_backoutÐ   s    u   _c         C` sD   |  s+ |  d |  d k o& | k n r/ |  Sd | |  | f Sd S(   u¡   

    Examples:
        >>> ensure_pad('conda')
        '_conda_'
        >>> ensure_pad('_conda')
        '__conda_'
        >>> ensure_pad('')
        ''

    i    iÿÿÿÿu   %s%s%sN(    (   t   namet   pad(    (    s0   lib/python2.7/site-packages/conda/common/path.pyt
   ensure_pad×   s    +c         C` s&   |  o% |  d |  d k o# d k SS(   u…   

    Examples:
        >>> is_private_env_name("_conda")
        False
        >>> is_private_env_name("_conda_")
        True

    i    iÿÿÿÿu   _(    (   t   env_name(    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   is_private_env_nameé   s    
c         C` sB   |  d k	 r> t |  ƒ \ } } t | ƒ d k r4 t St | ƒ St S(   uª   

    Examples:
        >>> is_private_env_path('/some/path/to/envs/_conda_')
        True
        >>> is_private_env_path('/not/an/envs_dir/_conda_')
        False

    u   envsN(   R_   R   R   R   Rt   (   t   env_patht   envs_directoryRs   (    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   is_private_env_pathö   s    

c         C` s!   |  j  t j ƒ r |  S|  t j S(   N(   RP   t   ost   sep(   R   (    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   right_pad_os_sep  s    c         C` s8   t  |  ƒ \ } } d | k r. | p' d  | f S|  d  f S(   Nu   .(   R   R_   (   t   path_or_urlt   dnt   fn(    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   split_filename  s    c         C` s[   |  j  d ƒ r( | } |  j d | d ƒ S|  j  d ƒ rS t ƒ  } |  j d | d ƒ S|  Sd  S(   Nu   site-packages/u   site-packagesi   u   python-scripts/u   python-scripts(   R$   RG   Rk   (   t   source_short_patht   target_site_packages_short_patht   sp_dirt   bin_dir(    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   get_python_noarch_target_path  s    	u    c         ` sý   |  s
 d St  d ƒ } | rO t j j d t j j t j j | ƒ d ƒ ƒ } n t j j d d ƒ } y2 t j | d |  g ƒ j	 d ƒ j
 d ƒ d }  Wn` t k
 rø } t j d	 | d
 t ƒ‡  f d †  } d } t j | | |  ƒ j d d ƒ }  n X|  S(   Nu    u   bashu   CYGPATHu   cygpath.exeu   -upu   asciiu   
i    u   %rt   exc_infoc         ` s?   |  j  d ƒ j d d ƒ j d d ƒ j d d ƒ } ˆ  d | S(   Ni   u   \u   /u   :u    u   //(   t   groupRG   (   t
   found_patht   found(   t   root_prefix(    s0   lib/python2.7/site-packages/conda/common/path.pyt   _translation/  s    3uW   (?<![:/^a-zA-Z])([a-zA-Z]:[\/\\]+(?:[^:*?"<>|]+[\/\\]+)*[^:*?"<>|;\/\\]+?(?![a-zA-Z]:))u   ;/u   :/(   t   whichRx   t   environt   getR   R
   t   dirnamet
   subprocesst   check_outputt   decodeR   t	   Exceptiont   logt   debugt   TrueR   Rn   RG   (   R   Rˆ   t   basht   cygpatht   eR‰   t   path_re(    (   Rˆ   s0   lib/python2.7/site-packages/conda/common/path.pyt   win_path_to_unix  s    32%c         C` s
   t  |  ƒ S(   N(   R   (   t
   executable(    (    s0   lib/python2.7/site-packages/conda/common/path.pyRŠ   7  s    c         C` sh   |  d d k r |  d  d f S|  d d k r< |  d  d f S|  d d k rZ |  d  d f S|  d f Sd S(   uf  
    Examples:
        >>> strip_pkg_extension("/path/_license-1.1-py27_1.tar.bz2")
        ('/path/_license-1.1-py27_1', '.tar.bz2')
        >>> strip_pkg_extension("/path/_license-1.1-py27_1.conda")
        ('/path/_license-1.1-py27_1', '.conda')
        >>> strip_pkg_extension("/path/_license-1.1-py27_1")
        ('/path/_license-1.1-py27_1', None)
    iúÿÿÿu   .condaiøÿÿÿu   .tar.bz2iûÿÿÿu   .jsonN(   R_   (   R   (    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   strip_pkg_extension;  s    c         C` s   |  d d k p |  d d k S(   uô   
    Examples:
        >>> is_package_file("/path/_license-1.1-py27_1.tar.bz2")
        True
        >>> is_package_file("/path/_license-1.1-py27_1.conda")
        True
        >>> is_package_file("/path/_license-1.1-py27_1")
        False
    iúÿÿÿu   .condaiøÿÿÿu   .tar.bz2(    (   R   (    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   is_package_fileQ  s    (J   t
   __future__R    R   R   R   t	   functoolsR   t   loggingR   Rx   t   os.pathR   R   R   R	   R
   R   R   R   R   RŽ   t   compatR   R   t    R   t   _vendor.auxlib.decoratorsR   t   _vendor.toolzR   R   R   t   distutils.spawnR   t   urllib.parseR   R   t   ImportErrort   urllibt   urlparset   __name__R’   R   R   R   R"   R)   R1   R7   R@   R   RF   RO   RT   R\   R_   R^   Rb   R”   R`   Rk   Rl   Rm   Ro   Rr   Rt   Rw   Rz   R~   Rƒ   R™   RŠ   R›   Rœ   (    (    (    s0   lib/python2.7/site-packages/conda/common/path.pyt   <module>   s\   ":
											
											