ó
€¾^Yc           @   sË   d  Z  d d l Z d d l Z d d l Z d d l m Z d d d g Z e d „ Z e d „ Z	 d	 „  Z
 d
 „  Z d „  Z d „  Z d „  Z e j d ƒ Z e j d ƒ Z d „  Z d „  Z d „  Z d S(   sÊ   
Filename globbing utility. Mostly a copy of `glob` from Python 3.5.

Changes include:
 * `yield from` and PEP3102 `*` removed.
 * `bytes` changed to `six.binary_type`.
 * Hidden files are not ignored.
iÿÿÿÿN(   t   binary_typet   globt   iglobt   escapec         C   s   t  t |  d | ƒƒ S(   sy  Return a list of paths matching a pathname pattern.

    The pattern may contain simple shell-style wildcards a la
    fnmatch. However, unlike fnmatch, filenames starting with a
    dot are special cases that are not matched by '*' and '?'
    patterns.

    If recursive is true, the pattern '**' will match any files and
    zero or more directories and subdirectories.
    t	   recursive(   t   listR   (   t   pathnameR   (    (    s3   /tmp/pip-build-LNwBEI/setuptools/setuptools/glob.pyR      s    c         C   sA   t  |  | ƒ } | r= t |  ƒ r= t | ƒ } | s= t ‚ n  | S(   sŒ  Return an iterator which yields the paths matching a pathname pattern.

    The pattern may contain simple shell-style wildcards a la
    fnmatch. However, unlike fnmatch, filenames starting with a
    dot are special cases that are not matched by '*' and '?'
    patterns.

    If recursive is true, the pattern '**' will match any files and
    zero or more directories and subdirectories.
    (   t   _iglobt   _isrecursivet   nextt   AssertionError(   R   R   t   itt   s(    (    s3   /tmp/pip-build-LNwBEI/setuptools/setuptools/glob.pyR       s
    c         c   sn  t  j j |  ƒ \ } } t |  ƒ se | rG t  j j |  ƒ ra |  Vqa n t  j j | ƒ ra |  Vn  d  S| sÂ | rŸ t | ƒ rŸ x> t | | ƒ D] } | Vq Wn x t | | ƒ D] } | Vq¯ Wd  S| |  k rì t | ƒ rì t	 | | ƒ } n	 | g } t | ƒ r%| rt | ƒ rt } q+t } n t
 } x< | D]4 } x+ | | | ƒ D] } t  j j | | ƒ VqHWq2Wd  S(   N(   t   ost   patht   splitt	   has_magict   lexistst   isdirR   t   glob2t   glob1R   t   glob0t   join(   R   R   t   dirnamet   basenamet   xt   dirst   glob_in_dirt   name(    (    s3   /tmp/pip-build-LNwBEI/setuptools/setuptools/glob.pyR   2   s4    				c         C   sn   |  s6 t  | t ƒ r* t j j d ƒ }  q6 t j }  n  y t j |  ƒ } Wn t k
 r] g  SXt j | | ƒ S(   Nt   ASCII(	   t
   isinstanceR    R   t   curdirt   encodet   listdirt   OSErrort   fnmatcht   filter(   R   t   patternt   names(    (    s3   /tmp/pip-build-LNwBEI/setuptools/setuptools/glob.pyR   ]   s    c         C   sN   | s" t  j j |  ƒ rJ | g Sn( t  j j t  j j |  | ƒ ƒ rJ | g Sg  S(   N(   R   R   R   R   R   (   R   R   (    (    s3   /tmp/pip-build-LNwBEI/setuptools/setuptools/glob.pyR   j   s    
!c         c   s;   t  | ƒ s t ‚ | d  Vx t |  ƒ D] } | Vq( Wd  S(   Ni    (   R   R
   t	   _rlistdir(   R   R%   R   (    (    s3   /tmp/pip-build-LNwBEI/setuptools/setuptools/glob.pyR   z   s    	c         c   sÇ   |  s6 t  |  t ƒ r* t t j d ƒ }  q6 t j }  n  y t j |  ƒ } Wn t j k
 r` d  SXx_ | D]W } | V|  r t j j |  | ƒ n | } x( t | ƒ D] } t j j | | ƒ Vq¡ Wqh Wd  S(   NR   (	   R   R    R   R   R!   t   errorR   R   R'   (   R   R&   R   R   t   y(    (    s3   /tmp/pip-build-LNwBEI/setuptools/setuptools/glob.pyR'   ‚   s    !s   ([*?[])c         C   s:   t  |  t ƒ r! t j |  ƒ } n t j |  ƒ } | d  k	 S(   N(   R   R    t   magic_check_bytest   searcht   magic_checkt   None(   R   t   match(    (    s3   /tmp/pip-build-LNwBEI/setuptools/setuptools/glob.pyR   —   s    c         C   s'   t  |  t ƒ r |  d k S|  d k Sd  S(   Ns   **(   R   R    (   R%   (    (    s3   /tmp/pip-build-LNwBEI/setuptools/setuptools/glob.pyR   Ÿ   s    
c         C   sV   t  j j |  ƒ \ } }  t |  t ƒ r< t j d |  ƒ }  n t j d |  ƒ }  | |  S(   s#   Escape all special characters.
    s   [\1](   R   R   t
   splitdriveR   R    R*   t   subR,   (   R   t   drive(    (    s3   /tmp/pip-build-LNwBEI/setuptools/setuptools/glob.pyR   ¦   s
    (   t   __doc__R   t   reR#   t   setuptools.extern.sixR    t   __all__t   FalseR   R   R   R   R   R   R'   t   compileR,   R*   R   R   R   (    (    (    s3   /tmp/pip-build-LNwBEI/setuptools/setuptools/glob.pyt   <module>   s"   	+						