
    C`p                         d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	 	 ddl
mZ n# e$ r eZY nw xY w G d d	e          Z e            Zej        Zej        Z[ ej        d
          Z ej        d          Zd Zd ZddZdS )zFilename globbing utility.    )absolute_importN)join   )fnmatch)imapc                       e Zd Z eej                  Z eej        j                  Z eej        j                  Z eej        j	                  Z
d	dZ	 	 d
dZ	 	 d
dZd Zd ZdS )GlobberFNc              #   N  K   	 |                      |          }n# t          j        $ r}Y d}~dS d}~ww xY wg }|D ]}|                    |           ||fV  |D ]I}t	          ||g|          }|s|                     |          s|                     ||          D ]}	|	V  JdS )zA simplified version of os.walk (code copied) that uses
        ``self.listdir``, and the other local filesystem methods.

        Because we don't care about file/directory distinctions, only
        a single list is returned.
        Nsep)listdiroserrorappend_join_pathsislinkwalk)
selftopfollowlinksr   nameserritemsnamenew_pathxs
             *lib/python3.11/site-packages/glob2/impl.pyr   zGlobber.walk   s      	LL%%EEx 	 	 	FFFFF	  	 	DLL5j 	 	D"C;C888H $++h"7"7 8[99  AGGGG		 	s    44Tc           
      P    t          |                     ||||||                    S )a  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 ``include_hidden`` is True, then files and folders starting with
        a dot are also returned.
        )listiglob)r   pathnamewith_matchesinclude_hidden	recursive
norm_pathscase_sensitiver   s           r   globzGlobber.glob0   s8     DJJx~)>3@ @ A A 	A    c                 `    |                      |d||||          }|r|S t          d |          S )a  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 ``with_matches`` is True, then for each matching path
        a 2-tuple will be returned; the second element if the tuple
        will be a list of the parts of the path that matched the individual
        wildcards.

        If ``include_hidden`` is True, then files and folders starting with
        a dot are also returned.
        Tc                     | d         S )Nr    )ss    r   <lambda>zGlobber.iglob.<locals>.<lambda>U   s
    ad r(   )_iglobr   )	r   r!   r"   r#   r$   r%   r&   r   results	            r   r    zGlobber.iglob?   sC    $ Xt^'> > 	MNNF+++r(   c           
   #     K   t          |          s|                     |          r|dfV  dS t          j                            |          \  }}||k    r*t          |          r|                     |d||||          }	n|dfg}	|	D ]A\  }}
|                     ||| ||||          D ]\  }}t          ||g|          |
|z   fV   BdS )ai  Internal implementation that backs :meth:`iglob`.

        ``rootcall`` is required to differentiate between the user's call to
        iglob(), and subsequent recursive calls, for the purposes of resolving
        certain special cases of ** wildcards. Specifically, "**" is supposed
        to include the current directory for purposes of globbing, but the
        directory itself should never be returned. So if ** is the lastmost
        part of the ``pathname`` given the user to the root call, we want to
        ignore the current directory. For this, we need to know which the root
        call is.
        r+   NFr   )	has_magicexistsr   pathsplitr.   resolve_patternr   )r   r!   rootcallr#   r%   r&   r   dirnamebasenamedirs
dir_groupsr   groupss                r   r.   zGlobber._iglobW   s8      "" 	{{8$$ #l"""F GMM(33 h9W#5#5 ;;w~)>3@ @DD bM?D $( 	Q 	QGZ $ 4 4Wh9A\>5?QT!V !V Q Qf "7D/s;;;Z&=PPPPPPQ	Q 	Qr(   c                    t           j        d         dk    r0t          |t                    rt          t          j        d          n^t          |t                    rIt          t                    s4t          t          j                    pt          j                              t          |          sN|dk    r| 
                              r|dfgS n+|                     t          |g                    r|dfgS g S st          j        	 |dk    rQ|rdgng }|                               D ]/\  }	fd}
|                    t          |
|	                     0d	}n|                               }n# t          j        $ r g cY S w xY w|s t%          |          st'          d
 |          }t)          j        ||||          S )aw  Apply ``pattern`` (contains no path elements) to the
        literal directory in ``dirname``.

        If pattern=='', this will filter for directories. This is
        a special case that happens when the user's glob expression ends
        with a slash (in which case we only want directories). It simpler
        and faster to filter here than in :meth:`_iglob`.
        r      ASCII r+   r   z**c                 Z    t          t                    dz   d          | g          S )Nr   r   )r   len)r,   r7   r   r   s    r   r-   z)Globber.resolve_pattern.<locals>.<lambda>   s0    {CGq8H8I8I4JA3NTW'X'X'X r(   *c                 (    |  pt          |            S N)	_ishidden)r   s    r   r-   z)Globber.resolve_pattern.<locals>.<lambda>   s    U%>)A,,.> r(   )sysversion_info
isinstancebytesr   curdirunicodegetfilesystemencodinggetdefaultencodingr1   isdirr2   r   r   extendmapr   r   rE   filterr   )r   r7   patternglobstar_with_rootr#   r%   r&   r   r   entries_mkabsr   s    `     `   @r   r5   zGlobber.resolve_pattern   s    A!##'5)) 4	733'7++ EJw4P4P E!'3+D+F+F ,D+.+A+C+CE E !! 	"}}::g&& +$bM?*+ ;;{GW+=3GGGHH +$bM?*I 	 iG	$ !3:$(IIg3I$?$? 7 7LCXXXXXXFLLVW!5!56666 W--x 	 	 	III	  	Gi&8&8 	G >>FFE~eWj.#NNNs   A,F FF)FN)FFTTTN)__name__
__module____qualname__staticmethodr   r   r3   rN   r   lexistsr2   r   r'   r    r.   r5   r+   r(   r   r	   r	      s        l2:&&GL''E\"'.))F\"'/**F   0 RV7;A A A A SW8<, , , ,0+Q +Q +QZ6O 6O 6O 6O 6Or(   r	   z[*?[]s   [*?[]c                     t          | t                    rt                              |           }nt                              |           }|d uS rD   )rH   rI   magic_check_bytessearchmagic_check)r,   matchs     r   r1   r1      sG    !U &!((++""1%%r(   c                     | d         dv S )Nr   )..   r+   )r3   s    r   rE   rE      s    7n$$r(   c                 H    t          |  }|rt          j        d||          }|S )Nz\/)r   resub)pathsr   r3   s      r   r   r      s+    <D
 (veS$''Kr(   rD   )__doc__
__future__r   rF   r   rd   os.pathr   r?   r   	itertoolsr   ImportErrorrP   objectr	   default_globberr'   r    compiler^   r\   r1   rE   r   r+   r(   r   <module>ro      sV       & & & & & & 



 				 				               DDDiO iO iO iO iOf iO iO iOX ')) bj!!BJx((   % % %     s   ) 33